From d3f361752e5988800228cff11fcc50289b2f88c7 Mon Sep 17 00:00:00 2001 From: Rick Pasetto Date: Wed, 27 Jan 2010 14:00:02 -0800 Subject: Plumb getting and setting the system audio mute through appviewer Next step is to actually implement the OS-specific calls to do so. Until then, behavior is the same; the status bar will mute/unmute the "master" audio for the viewer *only* --- indra/newview/llappviewermacosx.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'indra/newview/llappviewermacosx.cpp') diff --git a/indra/newview/llappviewermacosx.cpp b/indra/newview/llappviewermacosx.cpp index 1282e437f2..cc38a0940c 100644 --- a/indra/newview/llappviewermacosx.cpp +++ b/indra/newview/llappviewermacosx.cpp @@ -444,6 +444,20 @@ std::string LLAppViewerMacOSX::generateSerialNumber() return serial_md5; } +//virtual +void LLAppViewerMacOSX::setMasterSystemAudioMute(bool mute) +{ + // XXX TODO: make this actually set the OS's audio mute state + gSavedSettings.setBOOL("MuteAudio", mute); +} + +//virtual +bool LLAppViewerMacOSX::getMasterSystemAudioMute() +{ + // XXX TODO: make this actually get the OS's audio mute state + return gSavedSettings.getBOOL("MuteAudio"); +} + OSErr AEGURLHandler(const AppleEvent *messagein, AppleEvent *reply, long refIn) { OSErr result = noErr; -- cgit v1.2.3 From 6c92a724a1893eceac644a65ff5660e73ba6d42e Mon Sep 17 00:00:00 2001 From: Monroe Linden Date: Wed, 27 Jan 2010 16:48:09 -0800 Subject: Implemented LLAppViewerMacOSX::setMasterSystemAudioMute() and LLAppViewerMacOSX::getMasterSystemAudioMute() using CoreAudio APIs. This required adding a reference to the CoreAudio framework in indra/newview/CMakeLists.txt --- indra/newview/llappviewermacosx.cpp | 50 +++++++++++++++++++++++++++++++++---- 1 file changed, 45 insertions(+), 5 deletions(-) (limited to 'indra/newview/llappviewermacosx.cpp') diff --git a/indra/newview/llappviewermacosx.cpp b/indra/newview/llappviewermacosx.cpp index cc38a0940c..f8f8f50cd6 100644 --- a/indra/newview/llappviewermacosx.cpp +++ b/indra/newview/llappviewermacosx.cpp @@ -50,6 +50,7 @@ #include #include "lldir.h" #include +#include // for systemwide mute class LLMediaCtrl; // for LLURLDispatcher namespace @@ -444,18 +445,57 @@ 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 mute) +void LLAppViewerMacOSX::setMasterSystemAudioMute(bool new_mute) { - // XXX TODO: make this actually set the OS's audio mute state - gSavedSettings.setBOOL("MuteAudio", 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() { - // XXX TODO: make this actually get the OS's audio mute state - return gSavedSettings.getBOOL("MuteAudio"); + // 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) -- cgit v1.2.3