From ec408ca6a6d378d9038e720cbed65fdd8f233066 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 30 Jan 2018 10:06:36 +0100 Subject: [PATCH] output/pulse: fix crash during auto-detection The PulseOutput needs to be "enabled" before WaitConnection() may be called. Closes #207 --- NEWS | 2 ++ src/output/plugins/PulseOutputPlugin.cxx | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/NEWS b/NEWS index 2836e984e..ad631c9e1 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,6 @@ ver 0.20.16 (not yet released) +* output + - pulse: fix crash during auto-detection * database - simple: fix search within mount points * fix crash in debug build on Haiku and other operating systems diff --git a/src/output/plugins/PulseOutputPlugin.cxx b/src/output/plugins/PulseOutputPlugin.cxx index 01302e53d..77c411d22 100644 --- a/src/output/plugins/PulseOutputPlugin.cxx +++ b/src/output/plugins/PulseOutputPlugin.cxx @@ -27,6 +27,7 @@ #include "../Wrapper.hxx" #include "mixer/MixerList.hxx" #include "mixer/plugins/PulseMixerPlugin.hxx" +#include "util/ScopeExit.hxx" #include "Log.hxx" #include @@ -854,7 +855,10 @@ PulseOutput::TestDefaultDevice() try { const ConfigBlock empty; PulseOutput po(empty); + po.Enable(); + AtScopeExit(&po) { po.Disable(); }; po.WaitConnection(); + return true; } catch (const std::runtime_error &e) { return false;