From fdd58d07288f4ff1e11afa9211129e1b55db1694 Mon Sep 17 00:00:00 2001 From: Alexander Eckart Date: Sun, 6 Jan 2013 15:08:30 +0100 Subject: [PATCH] wait until rec streams have stopped (max 5ms) before starting new ones --- Vocaluxe/Lib/Sound/CPortAudioRecord.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Vocaluxe/Lib/Sound/CPortAudioRecord.cs b/Vocaluxe/Lib/Sound/CPortAudioRecord.cs index dd4a631b..2df903f7 100644 --- a/Vocaluxe/Lib/Sound/CPortAudioRecord.cs +++ b/Vocaluxe/Lib/Sound/CPortAudioRecord.cs @@ -119,6 +119,16 @@ namespace Vocaluxe.Lib.Sound _Buffer[i].Reset(); } + for (int i = 0; i < _recHandle.Length; i++) + { + int waitcount = 0; + while (waitcount < 5 && PortAudio.Pa_IsStreamStopped(_recHandle[i]) == PortAudio.PaError.paStreamIsNotStopped) + { + System.Threading.Thread.Sleep(1); + waitcount++; + } + } + for (int i = 0; i < _recHandle.Length; i++) { _recHandle[i] = IntPtr.Zero;