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.
This commit is contained in:
Yue Wang 2018-07-13 22:27:24 -07:00 committed by GitHub
parent ef84e5c8fa
commit 1d30df9b15
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -36,6 +36,7 @@
#include <CoreAudio/CoreAudio.h>
#include <AudioUnit/AudioUnit.h>
#include <AudioToolbox/AudioToolbox.h>
#include <CoreServices/CoreServices.h>
#include <boost/lockfree/spsc_queue.hpp>
@ -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
};