Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions dart/moq/test/moq_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1081,9 +1081,11 @@ void main() {
).timeout(timeout);
final rendition = (await catalogs.next().timeout(timeout))!.audio['mic']!;

// No max delay: a zero one skips a group once its successor is a warmup old by the
// native wall clock, so a read that starts late under load never returns.
final fixedOutput = moq_audio.DecoderOutput(
format: moq_audio.SampleFormat.f32,
delay: Delay(min: Duration(milliseconds: 80)),
delay: Delay(min: Duration(milliseconds: 80), max: null),
estimate: false,
);
final fixed = await moq_audio.Consumer.subscribe(
Expand All @@ -1096,7 +1098,10 @@ void main() {
broadcast: consumer,
id: 'mic',
catalogAudio: rendition,
output: moq_audio.DecoderOutput(format: moq_audio.SampleFormat.f32),
output: moq_audio.DecoderOutput(
format: moq_audio.SampleFormat.f32,
delay: Delay(max: null),
),
).timeout(timeout);
expect(fixed.delay(), const Duration(milliseconds: 80));
final initial = estimated.delay();
Expand Down
9 changes: 7 additions & 2 deletions go/wrapper/moq_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,18 +306,23 @@ func TestAudioConsumerDelay(t *testing.T) {
t.Fatalf("catalog has no %q rendition: %v", track, catalog.Audio)
}

// No max delay: a zero one skips a group once its successor is a warmup old by the native
// wall clock, so a read that starts late under load never returns.
fixedDelay := 80 * time.Millisecond
estimate := false
fixed, err := moqaudio.Subscribe(ctx, bc, track, rendition, moqaudio.DecoderOutput{
Format: moq.AudioSampleFormatF32,
Delay: moq.Delay{Min: fixedDelay},
Delay: moq.Delay{Min: fixedDelay, MaxUnlimited: true},
Estimate: &estimate,
})
if err != nil {
t.Fatal(err)
}
defer fixed.Cancel()
estimated, err := moqaudio.Subscribe(ctx, bc, track, rendition, moqaudio.DecoderOutput{Format: moq.AudioSampleFormatF32})
estimated, err := moqaudio.Subscribe(ctx, bc, track, rendition, moqaudio.DecoderOutput{
Format: moq.AudioSampleFormatF32,
Delay: moq.Delay{MaxUnlimited: true},
})
if err != nil {
t.Fatal(err)
}
Expand Down
48 changes: 17 additions & 31 deletions kt/moq/src/jvmAndAndroidTest/kotlin/dev/moq/SmokeTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,12 @@ import kotlin.test.assertTrue
import kotlin.time.Duration.Companion.milliseconds
import kotlin.time.Duration.Companion.nanoseconds
import kotlin.time.Duration.Companion.seconds
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.async
import kotlinx.coroutines.cancelAndJoin
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.flow.toList
import kotlinx.coroutines.isActive
import kotlinx.coroutines.launch
import kotlinx.coroutines.test.runTest
import kotlinx.coroutines.withTimeoutOrNull
import kotlinx.coroutines.yield
import kotlinx.serialization.Serializable
import uniffi.moq.MoqException

Expand Down Expand Up @@ -1233,14 +1228,12 @@ class SmokeTest {
val catalog = CatalogConsumer.subscribe(consumer).next()!!
val rendition = catalog.audio["mic"]!!

// No max delay: a zero one skips a group once its successor is a warmup old by
// the native wall clock, so a read that starts late under load never returns.
val fixedOutput =
AudioDecoderOutput(
format = AudioSampleFormat.F32,
delay =
Delay(
min = java.time.Duration.ofMillis(80),
max = java.time.Duration.ZERO,
),
delay = Delay(min = java.time.Duration.ofMillis(80), max = null),
estimate = false,
)
val fixed = AudioConsumer.subscribe(consumer, "mic", rendition, fixedOutput)
Expand All @@ -1249,33 +1242,26 @@ class SmokeTest {
consumer,
"mic",
rendition,
AudioDecoderOutput(format = AudioSampleFormat.F32),
AudioDecoderOutput(
format = AudioSampleFormat.F32,
delay = Delay(min = java.time.Duration.ZERO, max = null),
),
)
assertEquals(java.time.Duration.ofMillis(80), fixed.delay())
val initial = estimated.delay()

// 20 ms Opus frames of silence at 48 kHz mono, fed until both consumers read
// one. A max delay of zero skips groups by the native wall clock, which the
// test cannot control, so a host stalled under load may skip any fixed set
// of frames; a newer one always follows.
val writer =
launch(Dispatchers.Default) {
var i = 0uL
while (isActive) {
audio.write(
AudioFrame(
timestamp = Timestamp(i++ * 960uL, 48_000uL),
data = ByteArray(960 * 4),
)
)
yield()
}
}
// A skipped group reads as a gap before the frame after it.
// Two 20 ms Opus frames of silence at 48 kHz mono.
for (i in 0uL until 2uL) {
audio.write(
AudioFrame(
timestamp = Timestamp(i * 960uL, 48_000uL),
data = ByteArray(960 * 4),
)
)
}
for (reader in listOf(fixed, estimated)) {
while (assertNotNull(reader.next()) !is AudioReadFrame) {}
assertIs<AudioReadFrame>(assertNotNull(reader.next()))
}
writer.cancelAndJoin()

assertEquals(java.time.Duration.ofMillis(80), fixed.delay())
assertTrue(
Expand Down
34 changes: 0 additions & 34 deletions quest/m1/binding-delay-tests.md

This file was deleted.

5 changes: 5 additions & 0 deletions rs/moq-ffi/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,8 @@ The UniFFI core every non-Rust binding is generated from (proc macros, no `.udl`
- UniFFI ignores `#[cfg]` inside an export impl; gate at the module.
- Default argument values don't reach Go; resolve defaults in Rust.
- Go handles must be released from the goroutine that ran the call.

# Tests

- Assert native timing and decoding once, in moq-ffi's Rust tests. A wrapper test covers only the code that wrapper owns: record mapping, cancellation, async adapters, and lifetimes.
- A test that reads decoded media passes no max delay (`None`, `max: nil`, `MaxUnlimited`, and so on). A max of zero skips a group by the native wall clock, so a read that starts late under load never returns.
6 changes: 4 additions & 2 deletions swift/Tests/MoqTests/SmokeTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -941,13 +941,15 @@ final class SmokeTests: XCTestCase {
let catalog = try XCTUnwrap(nextCatalog)
let rendition = try XCTUnwrap(catalog.audio["mic"])

// No max delay: a zero one skips a group once its successor is a warmup old by the
// native wall clock, so a read that starts late under load never returns.
let fixed = try await Audio.Consumer.subscribe(
broadcast: consumer, id: "mic", rendition: rendition,
output: AudioDecoderOutput(format: .f32, delay: Delay(min: 0.08, max: 0), estimate: false)
output: AudioDecoderOutput(format: .f32, delay: Delay(min: 0.08, max: nil), estimate: false)
)
let estimated = try await Audio.Consumer.subscribe(
broadcast: consumer, id: "mic", rendition: rendition,
output: AudioDecoderOutput(format: .f32)
output: AudioDecoderOutput(format: .f32, delay: Delay(min: 0, max: nil))
)
XCTAssertEqual(fixed.delay, 0.08, accuracy: 1e-9)
let initial = estimated.delay
Expand Down