mirror of
https://projects.vdr-developer.org/git/vdr-plugin-softhddevice.git
synced 2023-10-10 19:16:51 +02:00
Increase audio buffer, if bigger audio delay used.
This commit is contained in:
parent
e258c35537
commit
3585f1df19
25
audio.c
25
audio.c
@ -137,7 +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 = 450; ///< audio buffer time in ms
|
static const int AudioBufferTime = 350; ///< audio buffer time in ms
|
||||||
|
|
||||||
#ifdef USE_AUDIO_THREAD
|
#ifdef USE_AUDIO_THREAD
|
||||||
static pthread_t AudioThread; ///< audio play thread
|
static pthread_t AudioThread; ///< audio play thread
|
||||||
@ -147,6 +147,8 @@ static pthread_cond_t AudioStartCond; ///< condition variable
|
|||||||
static const int AudioThread; ///< dummy audio thread
|
static const int AudioThread; ///< dummy audio thread
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
extern int VideoAudioDelay; /// import audio/video delay
|
||||||
|
|
||||||
#ifdef USE_AUDIORING
|
#ifdef USE_AUDIORING
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
@ -900,6 +902,7 @@ static int AlsaSetup(int *freq, int *channels, int use_ac3)
|
|||||||
snd_pcm_uframes_t period_size;
|
snd_pcm_uframes_t period_size;
|
||||||
int err;
|
int err;
|
||||||
int ret;
|
int ret;
|
||||||
|
int delay;
|
||||||
snd_pcm_t *handle;
|
snd_pcm_t *handle;
|
||||||
|
|
||||||
if (!AlsaPCMHandle) { // alsa not running yet
|
if (!AlsaPCMHandle) { // alsa not running yet
|
||||||
@ -1085,11 +1088,14 @@ 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
|
||||||
|
delay = AudioBufferTime;
|
||||||
|
if (VideoAudioDelay > -100) {
|
||||||
|
delay += 100 + VideoAudioDelay / 90;
|
||||||
|
}
|
||||||
if (AlsaStartThreshold <
|
if (AlsaStartThreshold <
|
||||||
(*freq * *channels * AudioBytesProSample * AudioBufferTime) / 1000U) {
|
(*freq * *channels * AudioBytesProSample * delay) / 1000U) {
|
||||||
AlsaStartThreshold =
|
AlsaStartThreshold =
|
||||||
(*freq * *channels * AudioBytesProSample * AudioBufferTime) /
|
(*freq * *channels * AudioBytesProSample * delay) / 1000U;
|
||||||
1000U;
|
|
||||||
}
|
}
|
||||||
// no bigger, than the buffer
|
// no bigger, than the buffer
|
||||||
if (AlsaStartThreshold > RingBufferFreeBytes(AlsaRingBuffer)) {
|
if (AlsaStartThreshold > RingBufferFreeBytes(AlsaRingBuffer)) {
|
||||||
@ -1622,6 +1628,7 @@ static int OssSetup(int *freq, int *channels, int use_ac3)
|
|||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
int tmp;
|
int tmp;
|
||||||
|
int delay;
|
||||||
|
|
||||||
if (OssPcmFildes == -1) { // OSS not ready
|
if (OssPcmFildes == -1) { // OSS not ready
|
||||||
return -1;
|
return -1;
|
||||||
@ -1708,12 +1715,14 @@ static int OssSetup(int *freq, int *channels, int use_ac3)
|
|||||||
// start when enough bytes for initial write
|
// start when enough bytes for initial write
|
||||||
OssStartThreshold = bi.bytes + tmp;
|
OssStartThreshold = bi.bytes + tmp;
|
||||||
// buffer time/delay in ms
|
// buffer time/delay in ms
|
||||||
|
delay = AudioBufferTime;
|
||||||
|
if (VideoAudioDelay > -100) {
|
||||||
|
delay += 100 + VideoAudioDelay / 90;
|
||||||
|
}
|
||||||
if (OssStartThreshold <
|
if (OssStartThreshold <
|
||||||
(*freq * *channels * AudioBytesProSample * AudioBufferTime) /
|
(*freq * *channels * AudioBytesProSample * delay) / 1000U) {
|
||||||
1000U) {
|
|
||||||
OssStartThreshold =
|
OssStartThreshold =
|
||||||
(*freq * *channels * AudioBytesProSample * AudioBufferTime) /
|
(*freq * *channels * AudioBytesProSample * delay) / 1000U;
|
||||||
1000U;
|
|
||||||
}
|
}
|
||||||
// no bigger, than the buffer
|
// no bigger, than the buffer
|
||||||
if (OssStartThreshold > RingBufferFreeBytes(OssRingBuffer)) {
|
if (OssStartThreshold > RingBufferFreeBytes(OssRingBuffer)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user