diff options
Diffstat (limited to 'indra/newview/llappviewermacosx.cpp')
-rw-r--r-- | indra/newview/llappviewermacosx.cpp | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/indra/newview/llappviewermacosx.cpp b/indra/newview/llappviewermacosx.cpp index d8c4a7d9d9..e195f6c856 100644 --- a/indra/newview/llappviewermacosx.cpp +++ b/indra/newview/llappviewermacosx.cpp @@ -49,6 +49,7 @@ #include <Carbon/Carbon.h> #include "lldir.h" #include <signal.h> +#include <CoreAudio/CoreAudio.h> // for systemwide mute class LLMediaCtrl; // for LLURLDispatcher namespace @@ -443,6 +444,59 @@ std::string LLAppViewerMacOSX::generateSerialNumber() return serial_md5; } +static AudioDeviceID get_default_audio_output_device(void) +{ + AudioDeviceID device = 0; + UInt32 size; + OSStatus err; + + size = sizeof(device); + err = AudioHardwareGetProperty(kAudioHardwarePropertyDefaultOutputDevice, &size, &device); + if(err != noErr) + { + LL_DEBUGS("SystemMute") << "Couldn't get default audio output device (0x" << std::hex << err << ")" << LL_ENDL; + } + + return device; +} + +//virtual +void LLAppViewerMacOSX::setMasterSystemAudioMute(bool new_mute) +{ + AudioDeviceID device = get_default_audio_output_device(); + + if(device != 0) + { + UInt32 mute = new_mute; + OSStatus err = AudioDeviceSetProperty(device, NULL, 0, false, kAudioDevicePropertyMute, sizeof(mute), &mute); + if(err != noErr) + { + LL_INFOS("SystemMute") << "Couldn't set audio mute property (0x" << std::hex << err << ")" << LL_ENDL; + } + } +} + +//virtual +bool LLAppViewerMacOSX::getMasterSystemAudioMute() +{ + // Assume the system isn't muted + UInt32 mute = 0; + + AudioDeviceID device = get_default_audio_output_device(); + + if(device != 0) + { + UInt32 size = sizeof(mute); + OSStatus err = AudioDeviceGetProperty(device, 0, false, kAudioDevicePropertyMute, &size, &mute); + if(err != noErr) + { + LL_DEBUGS("SystemMute") << "Couldn't get audio mute property (0x" << std::hex << err << ")" << LL_ENDL; + } + } + + return (mute != 0); +} + OSErr AEGURLHandler(const AppleEvent *messagein, AppleEvent *reply, long refIn) { OSErr result = noErr; |