Commit 4247a757 authored by Max Kellermann's avatar Max Kellermann

output/alsa: call snd_pcm_prepare() if draining is requested early

This fixes a corner case which has probably never occurred and probably never will: if Cancel() is called, and then Play() followed by Drain(), the plugin should really play that data. However currently, this never happens, because snd_pcm_prepare() is never called.
parent 57e34823
......@@ -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<Mutex> 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()) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment