|
|
|
|
@ -6,6 +6,15 @@
|
|
|
|
|
static int64_t times[64]; |
|
|
|
|
static unsigned counts[64], seen; |
|
|
|
|
static int capture_missing; |
|
|
|
|
static unsigned overruns, underruns; |
|
|
|
|
static void notification(const ma_device_notification* event) { |
|
|
|
|
if (event->type == ma_device_notification_type_capture_overrun) overruns++; |
|
|
|
|
if (event->type == ma_device_notification_type_playback_underrun) underruns++; |
|
|
|
|
} |
|
|
|
|
static int fake_hole(const void* stream, const void** data, size_t* bytes) { |
|
|
|
|
(void)stream; *data = NULL; *bytes = 64 * 2 * sizeof(float); return 0; |
|
|
|
|
} |
|
|
|
|
static int fake_drop(void* stream) { (void)stream; return 0; } |
|
|
|
|
static int fake_latency(const void* stream, uint64_t* latency, int* negative) { |
|
|
|
|
(void)stream; *latency = 100000; *negative = 0; return 0; |
|
|
|
|
} |
|
|
|
|
@ -52,6 +61,16 @@ int main(void) {
|
|
|
|
|
after = time_us(); |
|
|
|
|
assert(seen == 1 && times[0] >= now - 100000 + 2500 && times[0] <= after - 100000 + 2500); |
|
|
|
|
assert(!audio_stream_capture_missing(&device)); // Hint действует только внутри dispatch.
|
|
|
|
|
device.onNotification = notification; |
|
|
|
|
ma_device__set_state(&device, ma_device_state_started); |
|
|
|
|
context.pulse.pa_stream_peek = (ma_proc)fake_hole; context.pulse.pa_stream_drop = (ma_proc)fake_drop; |
|
|
|
|
seen = 0; |
|
|
|
|
ma_device_on_read__pulse(device.pulse.pStreamCapture, 64 * 2 * sizeof(float), &device); |
|
|
|
|
assert(overruns == 1 && underruns == 0 && seen == 4); // Один hole, четыре converter callbacks.
|
|
|
|
|
audio_diag_pulse_overflow(device.pulse.pStreamCapture, &device); |
|
|
|
|
assert(overruns == 2 && underruns == 0); |
|
|
|
|
audio_diag_pulse_underflow(NULL, &device); |
|
|
|
|
assert(overruns == 2 && underruns == 1); |
|
|
|
|
ma_data_converter_uninit(&device.capture.converter, NULL); |
|
|
|
|
puts("audio timing: capture read index, converter offsets, explicit hole PASS"); |
|
|
|
|
puts("audio timing: capture read index, converter offsets, hole/overrun/underrun notifications PASS"); |
|
|
|
|
} |
|
|
|
|
|