summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTofu Linden <tofu.linden@lindenlab.com>2010-01-27 17:11:07 -0800
committerTofu Linden <tofu.linden@lindenlab.com>2010-01-27 17:11:07 -0800
commit28075aa3242a3a6e1049983eed111a0ffa48321c (patch)
treefa02faf424089ea615538401a2033d40cfda12cb
parent0d2ce43c545b40a3ce5a90bc894b79ae8b11b726 (diff)
parent6c92a724a1893eceac644a65ff5660e73ba6d42e (diff)
merge.
-rw-r--r--indra/newview/CMakeLists.txt2
-rw-r--r--indra/newview/llappviewermacosx.cpp50
2 files changed, 47 insertions, 5 deletions
diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt
index 7ddeb90d29..4c0c895a7d 100644
--- a/indra/newview/CMakeLists.txt
+++ b/indra/newview/CMakeLists.txt
@@ -1064,11 +1064,13 @@ if (DARWIN)
find_library(APPKIT_LIBRARY AppKit)
find_library(COCOA_LIBRARY Cocoa)
find_library(IOKIT_LIBRARY IOKit)
+ find_library(COREAUDIO_LIBRARY CoreAudio)
set(viewer_LIBRARIES
${COCOA_LIBRARY}
${AGL_LIBRARY}
${IOKIT_LIBRARY}
+ ${COREAUDIO_LIBRARY}
)
# Add resource files to the project.
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 <Carbon/Carbon.h>
#include "lldir.h"
#include <signal.h>
+#include <CoreAudio/CoreAudio.h> // 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)