OS X Programmatically set default output device

I am trying to change what audio devices my computer is sending to. My ultimate goal is to create a program that can output my laptop's output to the built-in speakers, even if headphones are plugged into the headphone jack.

I stumbled upon this project, but the methods it uses (in particular AudioHardwareSetProperty

) are outdated. It also just doesn't work (it will say that it changed the output device, but the audio still goes to my headphones).

CoreAudio seems to be very poorly documented and I couldn't find ANY code on the internet that didn't use this feature. I would go with a deprecated feature if I did what I wanted, but it doesn't. I'm not sure if the weather is broken or just doesn't do what I think it does, but it really doesn't matter in the end.

I tried to look at the comments on AudioHardwareSetProperty

, but all I found was in the discussion section:

Note that the property value should not be considered changed until the HAL has called the listeners, as many property values ​​have changed asynchronously. Also note that the same functionality is provided by the AudioObjectGetPropertyData () function.

This is obviously not correct as I know what AudioObjectGetPropertyData

is being used to get information about one particular audio device.

Am I trying to do this with CoreAudio?

+3


source to share





All Articles