Re: How to programmatically change the default sound output device?
Re: How to programmatically change the default sound output device?
- Subject: Re: How to programmatically change the default sound output device?
- From: Thorrin <email@hidden>
- Date: Thu, 17 Jan 2008 11:07:34 -0800 (PST)
Take a look at these functions:
AudioHardwareGetPropertyInfo
AudioHardwareGetProperty
AudioHardwareSetProperty
AudioDeviceSetPropertyInfo
AudioDeviceGetProperty
AudioDeviceSetProperty
To get a list of devices on the system, do something
like this (this is Carbon, BTW):
UInt32 size;
UInt32 number_of_devices_on_system;
AudioDeviceID *dev_array;
AudioHardwareGetPropertyInfo(kAudioHardwarePropertyDevices,&size,
NULL);
AudioHardwareGetProperty(kAudioHardwarePropertyDevices,
&size, dev_array);
number_of_devices_on_system = (size / sizeof
(AudioDeviceID));
You can use a for loop to get the device IDs from
dev_array.
To set the default output to one of those devices, do
this:
UInt32 dev_to_set_to;
dev_to_set_to = (whatever device number you want from
array above)
AudioHardwareSetProperty(kAudioHardwarePropertyDefaultOutputDevice,
sizeof (UInt32), &dev_to_set_to);
I think that will do it. There are other things you
can get with the functions above like device names,
types (usb, builtin, etc) and stuff like that.
Lol, hope I explained it ok ;)
-T
--- Mikael Hakman <email@hidden> wrote:
> Hello,
>
> How do I programmatically change the default sound
> output device? I'm
> building an application that on user request will
> change audio, display and
> some other settings. Then the user will run whatever
> media applications
> he/she likes. By another user request all these
> settings will be restored to
> values before change. For display I use the Quartz
> calls but I can not
> figure out what API to use for changing the default
> sound output. Any help
> would be appreciated.
>
> Thanks/Mikael
>
> _______________________________________________
> 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
>
"Everyone is allergic to giant rocks hitting them in the head!"
-Thorrin's elf chick after casting a 'meteor swarm' spell ;)
____________________________________________________________________________________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
_______________________________________________
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