Re: API for switching audio output device or disabling output altogether
Re: API for switching audio output device or disabling output altogether
- Subject: Re: API for switching audio output device or disabling output altogether
- From: William Stewart <email@hidden>
- Date: Fri, 11 Dec 2009 16:21:01 -0800
On Dec 11, 2009, at 4:04 PM, Roger Thornhill wrote:
On Fri, Dec 11, 2009 at 3:53 PM, William Stewart <email@hidden>
wrote:
On Dec 10, 2009, at 10:49 PM, tahome izwah wrote:
Not sure if this helps but you can get the current default system
output device via
AudioDeviceID currentDevice;
UInt32 propsize = sizeof(AudioDeviceID);
OSStatus err = AudioHardwareGetProperty
(kAudioHardwarePropertyDefaultOutputDevice,
&propsize, ¤tDevice);
In order to find the built-in device you iterate through all audio
devices calling
Sorry if this is a basic question, but how do you get the list of
audio devices in order to iterate through them? I tried searching the
coreaudio documentation, but couldn't find the relevant information.
UInt32 transportType;
UInt32 propsize=sizeof(AudioDeviceID);
OSStatus err = AudioDeviceGetProperty(deviceID, 0, false,
kAudioDevicePropertyTransportType, &propsize, &transportType);
on each device. The built-in audio hardware has transportType ==
kIOAudioDeviceTransportTypeBuiltIn. You can set it system wide via
this call when required:
OSStatus err = AudioHardwareSetProperty
(kAudioHardwarePropertyDefaultOutputDevice,
sizeof(AudioDeviceID), &outputDevice);
Does the built in audio hardware remain constant? For example, when
you insert an optical cable into the audio output port on the Mac, a
hardware switch is triggered and the output device now becomes
"Digital Out". Will the default output device now be changed to
"Digital Out", or will it still refer to the internal speakers?
So you should be able to switch your device as required. Whether or
not this is good practice from a user experience POV I do not know -
It is not. Applications should not be setting the default device as
this is something the user controls.
It is also completely irrelevant to the question that was asked.
This is the problem I want to rectify. You mention that the default
device is something the user controls, however, once you insert a
cable into the audio output port, the option for "Internal Speakers"
is removed and replaced by "Digital Out". I'd like to give back this
option to the user, and allow them to select "Internal Speakers",
That's the point though. The behaviour that we support is to support
the user's gesture (plugging the cable) and NOT having to:
(1) Plug the cable
AND
(2) Go to a software panel and configure the output.
This is a UI Policy decision (amongst other things) and I don't see
this being changed at this point. Inserting headphones works the same
way (as does inserting a mic cable)
Bill
_______________________________________________
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