From 1d30df9b1567c36a1713a9f91a0f05d40d84d763 Mon Sep 17 00:00:00 2001 From: Yue Wang Date: Fri, 13 Jul 2018 22:27:24 -0700 Subject: [PATCH] Update OSXOutputPlugin.cxx some device seems to have issue with setting kAudioDevicePropertyVolumeScalar with kAudioObjectPropertyElementMaster. Use AudioToolbox 's kAudioHardwareServiceDeviceProperty_VirtualMasterVolume instead. Ideally, we should get the steoro channels first, and set the kAudioDevicePropertyVolumeScalar for each channel, which is doable as presented in https://github.com/cmus/cmus/blob/master/op/coreaudio.c. I will do a follow up PR after refactor PR. --- src/output/plugins/OSXOutputPlugin.cxx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/output/plugins/OSXOutputPlugin.cxx b/src/output/plugins/OSXOutputPlugin.cxx index 0f3632871..67fd9ddfe 100644 --- a/src/output/plugins/OSXOutputPlugin.cxx +++ b/src/output/plugins/OSXOutputPlugin.cxx @@ -36,6 +36,7 @@ #include #include +#include #include #include @@ -192,7 +193,7 @@ OSXOutput::GetVolume() { Float32 vol; AudioObjectPropertyAddress aopa = { - .mSelector = kAudioDevicePropertyVolumeScalar, + .mSelector = kAudioHardwareServiceDeviceProperty_VirtualMasterVolume, .mScope = kAudioObjectPropertyScopeOutput, .mElement = kAudioObjectPropertyElementMaster, }; @@ -217,7 +218,7 @@ void OSXOutput::SetVolume(unsigned new_volume) { Float32 vol = new_volume / 100.0; AudioObjectPropertyAddress aopa = { - .mSelector = kAudioDevicePropertyVolumeScalar, + .mSelector = kAudioHardwareServiceDeviceProperty_VirtualMasterVolume, .mScope = kAudioObjectPropertyScopeOutput, .mElement = kAudioObjectPropertyElementMaster };