From f8d198636b5291f4328d5b3f572cc084b68bda87 Mon Sep 17 00:00:00 2001 From: Johns Date: Fri, 27 Jan 2012 21:08:37 +0100 Subject: Video bug fix. Made video_test working again. Disabled VA-API Intel vaAssociateSubpicture workaround. Fix bug: Must release lock for VideoPollEvent. Allow faster video and audio sync. Fix bug: Software decoder use vaPutImage with Intel backend. Fix bug: Artefacts are shown after mpeg2 channel switch. Fix bug: VideoReleaseSurface called after VideoExit. --- audio.c | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) (limited to 'audio.c') diff --git a/audio.c b/audio.c index 5ccb924..2142b5a 100644 --- a/audio.c +++ b/audio.c @@ -137,7 +137,8 @@ static unsigned AudioSampleRate; ///< audio sample rate in hz static unsigned AudioChannels; ///< number of audio channels static const int AudioBytesProSample = 2; ///< number of bytes per sample static int64_t AudioPTS; ///< audio pts clock -static const int AudioBufferTime = 350; ///< audio buffer time in ms +static const int AudioBufferTime = 300; ///< audio buffer time in ms +static int AudioMoreBufferTime = 1; ///< increase buffer time #ifdef USE_AUDIO_THREAD static pthread_t AudioThread; ///< audio play thread @@ -1086,11 +1087,13 @@ static int AlsaSetup(int *freq, int *channels, int use_ac3) AlsaStartThreshold = snd_pcm_frames_to_bytes(AlsaPCMHandle, period_size); // buffer time/delay in ms if (AlsaStartThreshold < - (*freq * *channels * AudioBytesProSample * AudioBufferTime) / 1000U) { + (*freq * *channels * AudioBytesProSample * AudioMoreBufferTime * + AudioBufferTime) / 1000U) { AlsaStartThreshold = - (*freq * *channels * AudioBytesProSample * AudioBufferTime) / - 1000U; + (*freq * *channels * AudioBytesProSample * AudioMoreBufferTime * + AudioBufferTime) / 1000U; } + AudioMoreBufferTime = 1; // no bigger, than the buffer if (AlsaStartThreshold > RingBufferFreeBytes(AlsaRingBuffer)) { AlsaStartThreshold = RingBufferFreeBytes(AlsaRingBuffer); @@ -1709,12 +1712,13 @@ static int OssSetup(int *freq, int *channels, int use_ac3) OssStartThreshold = bi.bytes + tmp; // buffer time/delay in ms if (OssStartThreshold < - (*freq * *channels * AudioBytesProSample * AudioBufferTime) / - 1000U) { + (*freq * *channels * AudioBytesProSample * AudioMoreBufferTime * + AudioBufferTime) / 1000U) { OssStartThreshold = - (*freq * *channels * AudioBytesProSample * AudioBufferTime) / - 1000U; + (*freq * *channels * AudioBytesProSample * + AudioMoreBufferTime * AudioBufferTime) / 1000U; } + AudioMoreBufferTime = 1; // no bigger, than the buffer if (OssStartThreshold > RingBufferFreeBytes(OssRingBuffer)) { OssStartThreshold = RingBufferFreeBytes(OssRingBuffer); @@ -2097,6 +2101,16 @@ int AudioSetup(int *freq, int *channels, int use_ac3) return AudioUsedModule->Setup(freq, channels, use_ac3); } +/** +** Increase audio buffer time. +** +** Some channels need a bigger audio buffer to buffer video. +*/ +void AudioIncreaseBufferTime(void) +{ + AudioMoreBufferTime = 4; +} + /** ** Set pcm audio device. ** -- cgit v1.2.3