diff --git a/tests/03-full-cycle-cs/Program.cs b/tests/03-full-cycle-cs/Program.cs index dabe81f..c3580ef 100644 --- a/tests/03-full-cycle-cs/Program.cs +++ b/tests/03-full-cycle-cs/Program.cs @@ -347,10 +347,14 @@ static void FireAndForgetPlayback(int device, short[] recordBuf, PlaybackDoneFla done.Dispose(); throw; } + // Timeout = playback wall-clock + 2 s safety margin. Test 2's beep cleanup uses + // a flat 2 s because beep is 200 ms; for a 5 s recording the same value would + // fire mid-playback, Stop the stream, and cut the audio. + double expectedSeconds = recordBuf.Length / (double)WakewordModel.SampleRate; + var waitTimeout = TimeSpan.FromSeconds(expectedSeconds + 2.0); Task.Run(() => { - // Same 2 s safety timeout as the beep cleanup. - if (!done.Wait(TimeSpan.FromSeconds(2))) + if (!done.Wait(waitTimeout)) Console.Error.WriteLine("[error] recording playback timed out — callback may have faulted"); Thread.Sleep(200); stream.Stop();