diff options
author | Johns <johns98@gmx.net> | 2012-01-27 23:33:10 +0100 |
---|---|---|
committer | Johns <johns98@gmx.net> | 2012-01-27 23:33:10 +0100 |
commit | c3b924a2393c46513e5b02d5b821084d668e0bb9 (patch) | |
tree | 38062238d87024bfd51efab33aafdffe46ebc14c | |
parent | f8d198636b5291f4328d5b3f572cc084b68bda87 (diff) | |
download | vdr-plugin-softhddevice-c3b924a2393c46513e5b02d5b821084d668e0bb9.tar.gz vdr-plugin-softhddevice-c3b924a2393c46513e5b02d5b821084d668e0bb9.tar.bz2 |
Reduces audio latency, increases audio buffer time.
-rw-r--r-- | ChangeLog | 1 | ||||
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | audio.c | 30 | ||||
-rw-r--r-- | audio.h | 2 | ||||
-rw-r--r-- | softhddev.c | 9 | ||||
-rw-r--r-- | video.c | 4 |
6 files changed, 19 insertions, 29 deletions
@@ -1,6 +1,7 @@ User johns Date: + Reduces audio latency, increases audio buffer time. Made video_test working again. Disabled VA-API Intel vaAssociateSubpicture workaround. Fix bug: Must release lock for VideoPollEvent. @@ -18,7 +18,7 @@ GIT_REV = $(shell git describe --always 2>/dev/null) ### Configuration (edit this for your needs) -CONFIG := -DDEBUG +CONFIG := #-DDEBUG #CONFIG += -DHAVE_PTHREAD_NAME CONFIG += $(shell pkg-config --exists vdpau && echo "-DUSE_VDPAU") CONFIG += $(shell pkg-config --exists libva && echo "-DUSE_VAAPI") @@ -137,8 +137,7 @@ 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 = 300; ///< audio buffer time in ms -static int AudioMoreBufferTime = 1; ///< increase buffer time +static const int AudioBufferTime = 450; ///< audio buffer time in ms #ifdef USE_AUDIO_THREAD static pthread_t AudioThread; ///< audio play thread @@ -1087,13 +1086,11 @@ 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 * AudioMoreBufferTime * - AudioBufferTime) / 1000U) { + (*freq * *channels * AudioBytesProSample * AudioBufferTime) / 1000U) { AlsaStartThreshold = - (*freq * *channels * AudioBytesProSample * AudioMoreBufferTime * - AudioBufferTime) / 1000U; + (*freq * *channels * AudioBytesProSample * AudioBufferTime) / + 1000U; } - AudioMoreBufferTime = 1; // no bigger, than the buffer if (AlsaStartThreshold > RingBufferFreeBytes(AlsaRingBuffer)) { AlsaStartThreshold = RingBufferFreeBytes(AlsaRingBuffer); @@ -1712,13 +1709,12 @@ static int OssSetup(int *freq, int *channels, int use_ac3) OssStartThreshold = bi.bytes + tmp; // buffer time/delay in ms if (OssStartThreshold < - (*freq * *channels * AudioBytesProSample * AudioMoreBufferTime * - AudioBufferTime) / 1000U) { + (*freq * *channels * AudioBytesProSample * AudioBufferTime) / + 1000U) { OssStartThreshold = - (*freq * *channels * AudioBytesProSample * - AudioMoreBufferTime * AudioBufferTime) / 1000U; + (*freq * *channels * AudioBytesProSample * AudioBufferTime) / + 1000U; } - AudioMoreBufferTime = 1; // no bigger, than the buffer if (OssStartThreshold > RingBufferFreeBytes(OssRingBuffer)) { OssStartThreshold = RingBufferFreeBytes(OssRingBuffer); @@ -2102,16 +2098,6 @@ int AudioSetup(int *freq, int *channels, int 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. ** ** @param device name of pcm device (fe. "hw:0,9" or "/dev/dsp") @@ -42,8 +42,6 @@ extern int AudioSetup(int *, int *, int); ///< setup audio output //extern void AudioPlay(void); ///< play audio //extern void AudioPause(void); ///< pause audio -extern void AudioIncreaseBufferTime(void); ///< use bigger buffer - extern void AudioSetDevice(const char *); ///< set PCM audio device extern void AudioSetDeviceAC3(const char *); ///< set Passthrough device extern void AudioInit(void); ///< setup audio module diff --git a/softhddev.c b/softhddev.c index 5abdd11..60d70c9 100644 --- a/softhddev.c +++ b/softhddev.c @@ -292,7 +292,6 @@ int PlayAudio(const uint8_t * data, int size, } avpkt->pts = AV_NOPTS_VALUE; - AudioIncreaseBufferTime(); CodecAudioOpen(MyAudioDecoder, NULL, CODEC_ID_MP2); AudioCodecID = CODEC_ID_MP2; data += n; @@ -794,11 +793,15 @@ int PlayVideo(const uint8_t * data, int size) Debug(3, "video: not detected\n"); return size; } - // FIXME: incomplete packets produce artefacts after channel switch - if (0 && VideoCodecID == CODEC_ID_MPEG2VIDEO) { + // incomplete packets produce artefacts after channel switch + // packet < 65526 is the last split packet, detect it here for + // better latency + if (size < 65526 && VideoCodecID == CODEC_ID_MPEG2VIDEO) { // mpeg codec supports incomplete packets // waiting for a full complete packages, increases needed delays + VideoEnqueue(pts, check, size - 9 - n); VideoNextPacket(CODEC_ID_MPEG2VIDEO); + return size; } } @@ -3471,7 +3471,8 @@ static void VaapiAdvanceFrame(void) } // debug duplicate frames } else if (filled == 1) { - decoder->FramesDuped++; + ++decoder->FramesDuped; + decoder->DropNextFrame = 0; Warning(_ ("video: display buffer empty, duping frame (%d/%d) %d\n"), decoder->FramesDuped, decoder->FrameCounter, @@ -6423,6 +6424,7 @@ static void VdpauAdvanceFrame(void) if (filled <= 1 + 2 * decoder->Interlaced) { // keep use of last surface ++decoder->FramesDuped; + decoder->DropNextFrame = 0; Warning(_ ("video: display buffer empty, duping frame (%d/%d) %d\n"), decoder->FramesDuped, decoder->FrameCounter, |