Re: My mute program kills volume, but menubar doesn't show it
Re: My mute program kills volume, but menubar doesn't show it
- Subject: Re: My mute program kills volume, but menubar doesn't show it
- From: Jeff Moore <email@hidden>
- Date: Wed, 27 May 2009 11:32:08 -0700
The basic strategy works by prioritizing the master control over the
per-channel controls. Algorithmically, you might express it as follows:
if(ControlExists(Master))
{
UseControl(Master);
}
else if(ControlExists(Left) && ControlExists(Right))
{
UseControls(Left, Right);
}
else
{
NoControlsExist();
}
This algorithm generalizes nicely over pretty much any device you
might run into.
On May 27, 2009, at 4:45 AM, Gabriel Berriz wrote:
Jeff, thank you very much! Your suggestion worked beautifully. And
the code is considerably simpler to boot:
void setSystemMute(UInt32 mute) {
OSStatus status;
AudioDeviceID device;
status = GetDefaultAudioDevice(&device);
require_noerr(status, ReturnStatus);
UInt32 size = sizeof(mute);
status = AudioDeviceSetProperty(device, NULL, 0, false,
kAudioDevicePropertyMute, size, &mute);
require_noerr(status, ReturnStatus);
ReturnStatus:
return;
}
On Tue, May 26, 2009 at 4:10 PM, Jeff Moore <email@hidden> wrote:
Most likely, this means that you have one of our more recent bits of
hardware. The newer hardware has a master mute control in addition
to the
per-channel mute controls. It appears from empirical testing that
the menu
bar widget and the Sound Prefs panel both use the global mute
control to
inform the UI state.
Since your code is not manipulating the master mute control (aka
channel 0),
just the individual channel mutes, the UI is not updating. The fix
for this
is quite simple, just add a call to set the
kAudioDevicePropertyMute on
channel 0.
I'm curious, how general is this strategy? Would this work on other
machines running OS X?
Also, I'd be curious to know the most efficient reading I could have
done to figure out that muting channel 0 was the way to go. What you
wrote about channel 0 looks like very basic, fundamental stuff, and
yet I didn't come across it when I was looking for ways to solve the
problem... I managed to miss it somehow. I find that the Apple docs
on audio is a huge amount of stuff and it's difficult to know where to
begin.
Again, thanks a ton for your help!
--
Jeff Moore
Core Audio
Apple
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden