From 9c3cf39fdd6904d7a80efc7f1f8ecb45991defdc Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 8 Jul 2022 17:21:37 +0200 Subject: [PATCH] output/PipeWire: catch exceptions in ParamChanged() Fixes a potential crash bug. --- src/output/plugins/PipeWireOutputPlugin.cxx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/output/plugins/PipeWireOutputPlugin.cxx b/src/output/plugins/PipeWireOutputPlugin.cxx index 78ac228ba..66133a2b2 100644 --- a/src/output/plugins/PipeWireOutputPlugin.cxx +++ b/src/output/plugins/PipeWireOutputPlugin.cxx @@ -24,6 +24,7 @@ #include "../Error.hxx" #include "mixer/plugins/PipeWireMixerPlugin.hxx" #include "pcm/Silence.hxx" +#include "lib/fmt/ExceptionFormatter.hxx" #include "system/Error.hxx" #include "util/BitReverse.hxx" #include "util/Domain.hxx" @@ -656,7 +657,14 @@ PipeWireOutput::ParamChanged([[maybe_unused]] uint32_t id, { if (restore_volume) { restore_volume = false; - ::SetVolume(*stream, channels, volume); + + try { + ::SetVolume(*stream, channels, volume); + } catch (...) { + FmtError(pipewire_output_domain, + FMT_STRING("Failed to restore volume: {}"), + std::current_exception()); + } } #if defined(ENABLE_DSD) && defined(SPA_AUDIO_DSD_FLAG_NONE)