Skip to content

Commit

Permalink
if audio running must stop audio player thread before reconfigure Alsa
Browse files Browse the repository at this point in the history
  • Loading branch information
zillevdr committed Aug 23, 2021
1 parent 981a1bf commit c79a9d3
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions audio.c
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
}
}
Expand Down

0 comments on commit c79a9d3

Please sign in to comment.