mirror of
https://projects.vdr-developer.org/git/vdr-plugin-softhddevice.git
synced 2023-10-10 19:16:51 +02:00
Reduces audio latency, increases audio buffer time.
This commit is contained in:
parent
f8d198636b
commit
c3b924a239
@ -1,6 +1,7 @@
|
|||||||
User johns
|
User johns
|
||||||
Date:
|
Date:
|
||||||
|
|
||||||
|
Reduces audio latency, increases audio buffer time.
|
||||||
Made video_test working again.
|
Made video_test working again.
|
||||||
Disabled VA-API Intel vaAssociateSubpicture workaround.
|
Disabled VA-API Intel vaAssociateSubpicture workaround.
|
||||||
Fix bug: Must release lock for VideoPollEvent.
|
Fix bug: Must release lock for VideoPollEvent.
|
||||||
|
2
Makefile
2
Makefile
@ -18,7 +18,7 @@ GIT_REV = $(shell git describe --always 2>/dev/null)
|
|||||||
|
|
||||||
### Configuration (edit this for your needs)
|
### Configuration (edit this for your needs)
|
||||||
|
|
||||||
CONFIG := -DDEBUG
|
CONFIG := #-DDEBUG
|
||||||
#CONFIG += -DHAVE_PTHREAD_NAME
|
#CONFIG += -DHAVE_PTHREAD_NAME
|
||||||
CONFIG += $(shell pkg-config --exists vdpau && echo "-DUSE_VDPAU")
|
CONFIG += $(shell pkg-config --exists vdpau && echo "-DUSE_VDPAU")
|
||||||
CONFIG += $(shell pkg-config --exists libva && echo "-DUSE_VAAPI")
|
CONFIG += $(shell pkg-config --exists libva && echo "-DUSE_VAAPI")
|
||||||
|
30
audio.c
30
audio.c
@ -137,8 +137,7 @@ static unsigned AudioSampleRate; ///< audio sample rate in hz
|
|||||||
static unsigned AudioChannels; ///< number of audio channels
|
static unsigned AudioChannels; ///< number of audio channels
|
||||||
static const int AudioBytesProSample = 2; ///< number of bytes per sample
|
static const int AudioBytesProSample = 2; ///< number of bytes per sample
|
||||||
static int64_t AudioPTS; ///< audio pts clock
|
static int64_t AudioPTS; ///< audio pts clock
|
||||||
static const int AudioBufferTime = 300; ///< audio buffer time in ms
|
static const int AudioBufferTime = 450; ///< audio buffer time in ms
|
||||||
static int AudioMoreBufferTime = 1; ///< increase buffer time
|
|
||||||
|
|
||||||
#ifdef USE_AUDIO_THREAD
|
#ifdef USE_AUDIO_THREAD
|
||||||
static pthread_t AudioThread; ///< audio play 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);
|
AlsaStartThreshold = snd_pcm_frames_to_bytes(AlsaPCMHandle, period_size);
|
||||||
// buffer time/delay in ms
|
// buffer time/delay in ms
|
||||||
if (AlsaStartThreshold <
|
if (AlsaStartThreshold <
|
||||||
(*freq * *channels * AudioBytesProSample * AudioMoreBufferTime *
|
(*freq * *channels * AudioBytesProSample * AudioBufferTime) / 1000U) {
|
||||||
AudioBufferTime) / 1000U) {
|
|
||||||
AlsaStartThreshold =
|
AlsaStartThreshold =
|
||||||
(*freq * *channels * AudioBytesProSample * AudioMoreBufferTime *
|
(*freq * *channels * AudioBytesProSample * AudioBufferTime) /
|
||||||
AudioBufferTime) / 1000U;
|
1000U;
|
||||||
}
|
}
|
||||||
AudioMoreBufferTime = 1;
|
|
||||||
// no bigger, than the buffer
|
// no bigger, than the buffer
|
||||||
if (AlsaStartThreshold > RingBufferFreeBytes(AlsaRingBuffer)) {
|
if (AlsaStartThreshold > RingBufferFreeBytes(AlsaRingBuffer)) {
|
||||||
AlsaStartThreshold = RingBufferFreeBytes(AlsaRingBuffer);
|
AlsaStartThreshold = RingBufferFreeBytes(AlsaRingBuffer);
|
||||||
@ -1712,13 +1709,12 @@ static int OssSetup(int *freq, int *channels, int use_ac3)
|
|||||||
OssStartThreshold = bi.bytes + tmp;
|
OssStartThreshold = bi.bytes + tmp;
|
||||||
// buffer time/delay in ms
|
// buffer time/delay in ms
|
||||||
if (OssStartThreshold <
|
if (OssStartThreshold <
|
||||||
(*freq * *channels * AudioBytesProSample * AudioMoreBufferTime *
|
(*freq * *channels * AudioBytesProSample * AudioBufferTime) /
|
||||||
AudioBufferTime) / 1000U) {
|
1000U) {
|
||||||
OssStartThreshold =
|
OssStartThreshold =
|
||||||
(*freq * *channels * AudioBytesProSample *
|
(*freq * *channels * AudioBytesProSample * AudioBufferTime) /
|
||||||
AudioMoreBufferTime * AudioBufferTime) / 1000U;
|
1000U;
|
||||||
}
|
}
|
||||||
AudioMoreBufferTime = 1;
|
|
||||||
// no bigger, than the buffer
|
// no bigger, than the buffer
|
||||||
if (OssStartThreshold > RingBufferFreeBytes(OssRingBuffer)) {
|
if (OssStartThreshold > RingBufferFreeBytes(OssRingBuffer)) {
|
||||||
OssStartThreshold = RingBufferFreeBytes(OssRingBuffer);
|
OssStartThreshold = RingBufferFreeBytes(OssRingBuffer);
|
||||||
@ -2101,16 +2097,6 @@ int AudioSetup(int *freq, int *channels, int use_ac3)
|
|||||||
return AudioUsedModule->Setup(freq, channels, 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.
|
** Set pcm audio device.
|
||||||
**
|
**
|
||||||
|
2
audio.h
2
audio.h
@ -42,8 +42,6 @@ extern int AudioSetup(int *, int *, int); ///< setup audio output
|
|||||||
//extern void AudioPlay(void); ///< play audio
|
//extern void AudioPlay(void); ///< play audio
|
||||||
//extern void AudioPause(void); ///< pause 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 AudioSetDevice(const char *); ///< set PCM audio device
|
||||||
extern void AudioSetDeviceAC3(const char *); ///< set Passthrough device
|
extern void AudioSetDeviceAC3(const char *); ///< set Passthrough device
|
||||||
extern void AudioInit(void); ///< setup audio module
|
extern void AudioInit(void); ///< setup audio module
|
||||||
|
@ -292,7 +292,6 @@ int PlayAudio(const uint8_t * data, int size,
|
|||||||
}
|
}
|
||||||
|
|
||||||
avpkt->pts = AV_NOPTS_VALUE;
|
avpkt->pts = AV_NOPTS_VALUE;
|
||||||
AudioIncreaseBufferTime();
|
|
||||||
CodecAudioOpen(MyAudioDecoder, NULL, CODEC_ID_MP2);
|
CodecAudioOpen(MyAudioDecoder, NULL, CODEC_ID_MP2);
|
||||||
AudioCodecID = CODEC_ID_MP2;
|
AudioCodecID = CODEC_ID_MP2;
|
||||||
data += n;
|
data += n;
|
||||||
@ -794,11 +793,15 @@ int PlayVideo(const uint8_t * data, int size)
|
|||||||
Debug(3, "video: not detected\n");
|
Debug(3, "video: not detected\n");
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
// FIXME: incomplete packets produce artefacts after channel switch
|
// incomplete packets produce artefacts after channel switch
|
||||||
if (0 && VideoCodecID == CODEC_ID_MPEG2VIDEO) {
|
// 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
|
// mpeg codec supports incomplete packets
|
||||||
// waiting for a full complete packages, increases needed delays
|
// waiting for a full complete packages, increases needed delays
|
||||||
|
VideoEnqueue(pts, check, size - 9 - n);
|
||||||
VideoNextPacket(CODEC_ID_MPEG2VIDEO);
|
VideoNextPacket(CODEC_ID_MPEG2VIDEO);
|
||||||
|
return size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
4
video.c
4
video.c
@ -3471,7 +3471,8 @@ static void VaapiAdvanceFrame(void)
|
|||||||
}
|
}
|
||||||
// debug duplicate frames
|
// debug duplicate frames
|
||||||
} else if (filled == 1) {
|
} else if (filled == 1) {
|
||||||
decoder->FramesDuped++;
|
++decoder->FramesDuped;
|
||||||
|
decoder->DropNextFrame = 0;
|
||||||
Warning(_
|
Warning(_
|
||||||
("video: display buffer empty, duping frame (%d/%d) %d\n"),
|
("video: display buffer empty, duping frame (%d/%d) %d\n"),
|
||||||
decoder->FramesDuped, decoder->FrameCounter,
|
decoder->FramesDuped, decoder->FrameCounter,
|
||||||
@ -6423,6 +6424,7 @@ static void VdpauAdvanceFrame(void)
|
|||||||
if (filled <= 1 + 2 * decoder->Interlaced) {
|
if (filled <= 1 + 2 * decoder->Interlaced) {
|
||||||
// keep use of last surface
|
// keep use of last surface
|
||||||
++decoder->FramesDuped;
|
++decoder->FramesDuped;
|
||||||
|
decoder->DropNextFrame = 0;
|
||||||
Warning(_
|
Warning(_
|
||||||
("video: display buffer empty, duping frame (%d/%d) %d\n"),
|
("video: display buffer empty, duping frame (%d/%d) %d\n"),
|
||||||
decoder->FramesDuped, decoder->FrameCounter,
|
decoder->FramesDuped, decoder->FrameCounter,
|
||||||
|
Loading…
Reference in New Issue
Block a user