Skip to content
Snippets Groups Projects
Commit 6c92a724 authored by Monroe Linden's avatar Monroe Linden
Browse files

Implemented LLAppViewerMacOSX::setMasterSystemAudioMute() and...

Implemented LLAppViewerMacOSX::setMasterSystemAudioMute() and LLAppViewerMacOSX::getMasterSystemAudioMute() using CoreAudio APIs.

This required adding a reference to the CoreAudio framework in indra/newview/CMakeLists.txt
parent bfd21c08
No related branches found
No related tags found
No related merge requests found
...@@ -1064,11 +1064,13 @@ if (DARWIN) ...@@ -1064,11 +1064,13 @@ if (DARWIN)
find_library(APPKIT_LIBRARY AppKit) find_library(APPKIT_LIBRARY AppKit)
find_library(COCOA_LIBRARY Cocoa) find_library(COCOA_LIBRARY Cocoa)
find_library(IOKIT_LIBRARY IOKit) find_library(IOKIT_LIBRARY IOKit)
find_library(COREAUDIO_LIBRARY CoreAudio)
set(viewer_LIBRARIES set(viewer_LIBRARIES
${COCOA_LIBRARY} ${COCOA_LIBRARY}
${AGL_LIBRARY} ${AGL_LIBRARY}
${IOKIT_LIBRARY} ${IOKIT_LIBRARY}
${COREAUDIO_LIBRARY}
) )
# Add resource files to the project. # Add resource files to the project.
......
...@@ -50,6 +50,7 @@ ...@@ -50,6 +50,7 @@
#include <Carbon/Carbon.h> #include <Carbon/Carbon.h>
#include "lldir.h" #include "lldir.h"
#include <signal.h> #include <signal.h>
#include <CoreAudio/CoreAudio.h> // for systemwide mute
class LLMediaCtrl; // for LLURLDispatcher class LLMediaCtrl; // for LLURLDispatcher
namespace namespace
...@@ -444,18 +445,57 @@ std::string LLAppViewerMacOSX::generateSerialNumber() ...@@ -444,18 +445,57 @@ std::string LLAppViewerMacOSX::generateSerialNumber()
return serial_md5; 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 //virtual
void LLAppViewerMacOSX::setMasterSystemAudioMute(bool mute) void LLAppViewerMacOSX::setMasterSystemAudioMute(bool new_mute)
{ {
// XXX TODO: make this actually set the OS's audio mute state AudioDeviceID device = get_default_audio_output_device();
gSavedSettings.setBOOL("MuteAudio", mute);
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 //virtual
bool LLAppViewerMacOSX::getMasterSystemAudioMute() bool LLAppViewerMacOSX::getMasterSystemAudioMute()
{ {
// XXX TODO: make this actually get the OS's audio mute state // Assume the system isn't muted
return gSavedSettings.getBOOL("MuteAudio"); 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 AEGURLHandler(const AppleEvent *messagein, AppleEvent *reply, long refIn)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment