summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohns <johns98@gmx.net>2012-02-02 16:01:08 +0100
committerJohns <johns98@gmx.net>2012-02-02 16:01:08 +0100
commit3585f1df193c771083c01a124249472dfc4111bd (patch)
tree1b6abdc81511126e1be715968943a51b3d222298
parente258c355371ae45f3ee6cf00a1badfdbe1591551 (diff)
downloadvdr-plugin-softhddevice-3585f1df193c771083c01a124249472dfc4111bd.tar.gz
vdr-plugin-softhddevice-3585f1df193c771083c01a124249472dfc4111bd.tar.bz2
Increase audio buffer, if bigger audio delay used.
-rw-r--r--audio.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/audio.c b/audio.c
index 6c41503..14de4a4 100644
--- a/audio.c
+++ b/audio.c
@@ -137,7 +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 = 450; ///< audio buffer time in ms
+static const int AudioBufferTime = 350; ///< audio buffer time in ms
#ifdef USE_AUDIO_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
#endif
+extern int VideoAudioDelay; /// import audio/video delay
+
#ifdef USE_AUDIORING
//----------------------------------------------------------------------------
@@ -900,6 +902,7 @@ static int AlsaSetup(int *freq, int *channels, int use_ac3)
snd_pcm_uframes_t period_size;
int err;
int ret;
+ int delay;
snd_pcm_t *handle;
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);
// buffer time/delay in ms
+ delay = AudioBufferTime;
+ if (VideoAudioDelay > -100) {
+ delay += 100 + VideoAudioDelay / 90;
+ }
if (AlsaStartThreshold <
- (*freq * *channels * AudioBytesProSample * AudioBufferTime) / 1000U) {
+ (*freq * *channels * AudioBytesProSample * delay) / 1000U) {
AlsaStartThreshold =
- (*freq * *channels * AudioBytesProSample * AudioBufferTime) /
- 1000U;
+ (*freq * *channels * AudioBytesProSample * delay) / 1000U;
}
// no bigger, than the buffer
if (AlsaStartThreshold > RingBufferFreeBytes(AlsaRingBuffer)) {
@@ -1622,6 +1628,7 @@ static int OssSetup(int *freq, int *channels, int use_ac3)
{
int ret;
int tmp;
+ int delay;
if (OssPcmFildes == -1) { // OSS not ready
return -1;
@@ -1708,12 +1715,14 @@ static int OssSetup(int *freq, int *channels, int use_ac3)
// start when enough bytes for initial write
OssStartThreshold = bi.bytes + tmp;
// buffer time/delay in ms
+ delay = AudioBufferTime;
+ if (VideoAudioDelay > -100) {
+ delay += 100 + VideoAudioDelay / 90;
+ }
if (OssStartThreshold <
- (*freq * *channels * AudioBytesProSample * AudioBufferTime) /
- 1000U) {
+ (*freq * *channels * AudioBytesProSample * delay) / 1000U) {
OssStartThreshold =
- (*freq * *channels * AudioBytesProSample * AudioBufferTime) /
- 1000U;
+ (*freq * *channels * AudioBytesProSample * delay) / 1000U;
}
// no bigger, than the buffer
if (OssStartThreshold > RingBufferFreeBytes(OssRingBuffer)) {