diff options
author | Max Kellermann <max@musicpd.org> | 2018-11-14 10:00:50 +0100 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2018-11-14 10:00:50 +0100 |
commit | 7db24504478ac5eb40f8114e7f57302be5e59849 (patch) | |
tree | 4f8ea971d13a30441cde004f7b63c20a54802ec6 /src/output | |
parent | 6c2a6a65e0adb1961c8d79dbdf30739cafcbd811 (diff) |
output/alsa: refactor the drain EAGAIN workaround
Diffstat (limited to 'src/output')
-rw-r--r-- | src/output/plugins/AlsaOutputPlugin.cxx | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/output/plugins/AlsaOutputPlugin.cxx b/src/output/plugins/AlsaOutputPlugin.cxx index 841b12b8c..29510f870 100644 --- a/src/output/plugins/AlsaOutputPlugin.cxx +++ b/src/output/plugins/AlsaOutputPlugin.cxx @@ -33,6 +33,7 @@ #include "util/RuntimeError.hxx" #include "util/Domain.hxx" #include "util/ConstBuffer.hxx" +#include "util/ScopeExit.hxx" #include "util/StringView.hxx" #include "event/MultiSocketMonitor.hxx" #include "event/DeferEvent.hxx" @@ -738,14 +739,15 @@ AlsaOutput::DrainInternal() noexcept /* .. and finally drain the ALSA hardware buffer */ + int result; if (work_around_drain_bug) { snd_pcm_nonblock(pcm, 0); - bool result = snd_pcm_drain(pcm) != -EAGAIN; + result = snd_pcm_drain(pcm); snd_pcm_nonblock(pcm, 1); - return result; - } + } else + result = snd_pcm_drain(pcm); - return snd_pcm_drain(pcm) != -EAGAIN; + return result != -EAGAIN; } void |