NP.
I will say that you will need to test your app for USB
devices and/or firewire devices. Unplugging a set of
USB headphones and then re-inserting it will give you
a new device ID (IIRC).
-T
--- Mikael Hakman <email@hidden> wrote:
A lot of thanks T for very clear and to the point
information! This works
like a breeze. I couldn't find this information in
the reference because the
reference doesn't have the usual bar on the left
with "Functions by Task"
etc. headers. Anyhow, following your example, I made
a small shell tool that
takes name of an output device on command line and
sets it to default. I don't
know whether it is appropriate or customary to post
the source here.
BTW AudioDeviceGet/SetProperty calls remind me of
UNIX IOCTL calls very
much, which is good for someone coming from that
place.
Thanks again/Mikael
Thorrin wrote:
> 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:
>>
>
http://lists.apple.com/mailman/options/coreaudio-api/email@hidden
>>
>> 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
>
> __________ NOD32 2802 (20080117) Information
__________
>
> Detta meddelande är genomsökt av NOD32 Antivirus.
> http://www.nod32.com
>
>
"Everyone is allergic to giant rocks hitting them in the head!"
-Thorrin's elf chick after casting a 'meteor swarm' spell ;)
____________________________________________________________________________________
Looking for last minute shopping deals?
Find them fast with Yahoo! Search.
http://tools.search.yahoo.com/newsearch/category.php?category=shopping
__________ NOD32 2805 (20080118) Information __________
Detta meddelande är genomsökt av NOD32 Antivirus.
http://www.nod32.com