From 9d40020756424ba966d6bd0d8e933aede264b4ee Mon Sep 17 00:00:00 2001 From: Flamefire Date: Fri, 2 May 2014 17:18:47 +0200 Subject: [PATCH] Fix wrong latency value with PA --- Vocaluxe/Lib/Sound/Playback/PortAudio/CPortAudioStream.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Vocaluxe/Lib/Sound/Playback/PortAudio/CPortAudioStream.cs b/Vocaluxe/Lib/Sound/Playback/PortAudio/CPortAudioStream.cs index 1042e0f8..62123b1f 100644 --- a/Vocaluxe/Lib/Sound/Playback/PortAudio/CPortAudioStream.cs +++ b/Vocaluxe/Lib/Sound/Playback/PortAudio/CPortAudioStream.cs @@ -49,6 +49,7 @@ namespace Vocaluxe.Lib.Sound.Playback.PortAudio private PortAudioSharp.PortAudio.PaStreamCallbackDelegate _PaStreamCallback; private IAudioDecoder _Decoder; private float _BytesPerSecond; + private float _Latency; private bool _NoMoreData; private bool _FileOpened; @@ -293,6 +294,8 @@ namespace Vocaluxe.Lib.Sound.Playback.PortAudio return false; } + _Latency = CConfig.AudioLatency / 1000f + (float)PortAudioSharp.PortAudio.Pa_GetStreamInfo(_Stream).outputLatency; + //From now on closing the driver and the decoder is handled by the thread ONLY! _Paused = true; @@ -462,7 +465,7 @@ namespace Vocaluxe.Lib.Sound.Playback.PortAudio if (_Data.BytesNotRead < _Beginrefill && !_NoMoreData) _EventDecode.Set(); - float latency = buf.Length / _BytesPerSecond + CConfig.AudioLatency / 1000f; + float latency = buf.Length / _BytesPerSecond + _Latency; float time = _TimeCode - _Data.BytesNotRead / _BytesPerSecond - latency; if (!_NoMoreData)