diff --git a/audio.c b/audio.c index 7855887c..181129e0 100644 --- a/audio.c +++ b/audio.c @@ -105,13 +105,10 @@ static int AudioStereoDescent; ///< volume descent for stereo static int AudioVolume; ///< current volume (0 .. 1000) extern int VideoAudioDelay; ///< import audio/video delay -extern volatile char SoftIsPlayingVideo; ///< stream contains video data /// default ring buffer size ~2s 8ch 16bit (3 * 5 * 7 * 8) static const unsigned AudioRingBufferSize = 3 * 5 * 7 * 8 * 2 * 1000; -#define AUDIO_MIN_BUFFER_FREE (3072 * 8 * 8) - static int AudioChannelsInHw[9]; ///< table which channels are supported enum _audio_rates { ///< sample rates enumeration @@ -1333,7 +1330,6 @@ static int AudioNextRing(void) int sample_rate; int channels; size_t used; - size_t remain; // update audio format // not always needed, but check if needed is too complex @@ -1357,13 +1353,7 @@ static int AudioNextRing(void) / (AudioRing[AudioRingWrite].HwSampleRate * AudioRing[AudioRingWrite].HwChannels * AudioBytesProSample)); used = RingBufferUsedBytes(AudioRing[AudioRingRead].RingBuffer); - remain = RingBufferFreeBytes(AudioRing[AudioRingRead].RingBuffer); - // stop, if not enough in next buffer - if (remain <= AUDIO_MIN_BUFFER_FREE) { - Debug5("audio: force start"); - } - if (remain <= AUDIO_MIN_BUFFER_FREE || ((AudioVideoIsReady || !SoftIsPlayingVideo) - && AudioStartThreshold < used)) { + if (AudioStartThreshold * 4 < used || (AudioVideoIsReady && AudioStartThreshold < used)) { return 0; } return 1; @@ -1590,7 +1580,6 @@ void AudioEnqueue(const void *samples, int count) if (!AudioRunning) { // check, if we can start the thread int skip; - size_t remain; n = RingBufferUsedBytes(AudioRing[AudioRingWrite].RingBuffer); skip = AudioSkip; @@ -1610,12 +1599,8 @@ void AudioEnqueue(const void *samples, int count) n = RingBufferUsedBytes(AudioRing[AudioRingWrite].RingBuffer); } // forced start or enough video + audio buffered - remain = RingBufferFreeBytes(AudioRing[AudioRingRead].RingBuffer); - if (remain <= AUDIO_MIN_BUFFER_FREE) { - Debug5("audio: force start"); - } - if (remain <= AUDIO_MIN_BUFFER_FREE || ((AudioVideoIsReady || !SoftIsPlayingVideo) - && AudioStartThreshold < n)) { + // for some exotic channels * 4 too small + if (AudioStartThreshold * 4 < n || (AudioVideoIsReady && AudioStartThreshold < n)) { // restart play-back // no lock needed, can wakeup next time AudioRunning = 1; diff --git a/vaapidevice.cpp b/vaapidevice.cpp index d65a6bd5..9b8c29c6 100644 --- a/vaapidevice.cpp +++ b/vaapidevice.cpp @@ -124,7 +124,6 @@ static volatile int DoMakePrimary; ///< switch primary device to this #define SUSPEND_NORMAL 1 ///< normal suspend mode #define SUSPEND_DETACHED 2 ///< detached suspend mode static signed char SuspendMode; ///< suspend mode -volatile char SoftIsPlayingVideo; ///< stream contains video data static cString CommandLineParameters = ""; ///< plugin's command-line parameters //////////////////////////////////////////////////////////////////////////////