output/osx: catch kAudioDevicePropertyHogMode errors

Our AudioObjectGetPropertyDataT() wrapper throws exception on error,
and calling it from OSXOutput::Disable() can cause MPD crash due to
std::terminate().

Closes https://github.com/MusicPlayerDaemon/MPD/issues/932
This commit is contained in:
Max Kellermann 2020-08-14 14:36:30 +02:00
parent 2bdf1b2284
commit 4f6c54ecb3
2 changed files with 12 additions and 3 deletions

1
NEWS
View File

@ -1,5 +1,6 @@
ver 0.21.26 (not yet released)
* output
- osx: fix crash bug
- sles: support floating point samples
ver 0.21.25 (2020/07/06)

View File

@ -477,7 +477,7 @@ osx_output_set_buffer_size(AudioUnit au, AudioStreamBasicDescription desc)
}
static void
osx_output_hog_device(AudioDeviceID dev_id, bool hog)
osx_output_hog_device(AudioDeviceID dev_id, bool hog) noexcept
{
static constexpr AudioObjectPropertyAddress aopa = {
kAudioDevicePropertyHogMode,
@ -485,8 +485,16 @@ osx_output_hog_device(AudioDeviceID dev_id, bool hog)
kAudioObjectPropertyElementMaster
};
pid_t hog_pid = AudioObjectGetPropertyDataT<pid_t>(dev_id,
aopa);
pid_t hog_pid;
try {
hog_pid = AudioObjectGetPropertyDataT<pid_t>(dev_id, aopa);
} catch (...) {
Log(LogLevel::DEBUG, std::current_exception(),
"Failed to query HogMode");
return;
}
if (hog) {
if (hog_pid != -1) {
FormatDebug(osx_output_domain,