From c79a9d3184cefb2fe8898d7f562f32334eb32324 Mon Sep 17 00:00:00 2001 From: Jens Ziller Date: Mon, 23 Aug 2021 19:07:56 +0200 Subject: [PATCH] if audio running must stop audio player thread before reconfigure Alsa --- audio.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/audio.c b/audio.c index 069a572..32e7d4c 100644 --- a/audio.c +++ b/audio.c @@ -944,10 +944,11 @@ static int AlsaSetup(int channels, int sample_rate, __attribute__ ((unused)) int AudioDownMix = 0; - if (!AlsaPCMHandle) { // alsa not running yet - // FIXME: if open fails for fe. pass-through, we never recover - fprintf(stderr, "AlsaSetup: No AlsaPCMHandle found!!!\n"); - return -1; + if (AudioRunning) { +#ifdef SOUND_DEBUG + fprintf(stderr, "AlsaSetup: Audio is Running => AudioFlushBuffers\n"); +#endif + AudioFlushBuffers(); } snd_pcm_hw_params_alloca(&hwparams); if ((err = snd_pcm_hw_params_any(AlsaPCMHandle, hwparams)) < 0) { @@ -1327,7 +1328,9 @@ void AudioFilter(AVFrame *inframe, AVCodecContext *AudioCtx) } else { Filterchanged = 1; err_count++; +#ifdef DEBUG fprintf(stderr, "AudioFilter: Filterchanged %d err_count %d\n", Filterchanged, err_count); +#endif goto in; } }