output/pulse: fix crash during auto-detection

The PulseOutput needs to be "enabled" before WaitConnection() may be
called.

Closes #207
This commit is contained in:
Max Kellermann
2018-01-30 10:06:36 +01:00
parent ea66cdd6a5
commit ec408ca6a6
2 changed files with 6 additions and 0 deletions

View File

@@ -27,6 +27,7 @@
#include "../Wrapper.hxx"
#include "mixer/MixerList.hxx"
#include "mixer/plugins/PulseMixerPlugin.hxx"
#include "util/ScopeExit.hxx"
#include "Log.hxx"
#include <pulse/thread-mainloop.h>
@@ -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;