diff --git a/src/output/plugins/AlsaOutputPlugin.cxx b/src/output/plugins/AlsaOutputPlugin.cxx index 8d875ed26..00de0af18 100644 --- a/src/output/plugins/AlsaOutputPlugin.cxx +++ b/src/output/plugins/AlsaOutputPlugin.cxx @@ -891,6 +891,15 @@ AlsaOutput::DispatchSockets() noexcept try { non_block.DispatchSockets(*this, pcm); + if (must_prepare) { + must_prepare = false; + + int err = snd_pcm_prepare(pcm); + if (err < 0) + throw FormatRuntimeError("snd_pcm_prepare() failed: %s", + snd_strerror(-err)); + } + { const std::lock_guard lock(mutex); @@ -911,15 +920,6 @@ try { } } - if (must_prepare) { - must_prepare = false; - - int err = snd_pcm_prepare(pcm); - if (err < 0) - throw FormatRuntimeError("snd_pcm_prepare() failed: %s", - snd_strerror(-err)); - } - CopyRingToPeriodBuffer(); if (period_buffer.IsEmpty()) {