Re: Audio devices not updating
Re: Audio devices not updating
- Subject: Re: Audio devices not updating
- From: Ethan Funk <email@hidden>
- Date: Mon, 15 Mar 2010 15:42:23 -0700
I started a run loop on my main thread, moved the work the main thread had been doing into another thread which stops the main run-loop just before it is finished, and now all is well. Not only did that solve the AudioObjectAddPropertyListener problem, but it also fix the problem I had been having with audio going away when headphones are plugged into a MacBookPro and not coming back when unplugged.
Thanks so much everyone, and make sure to have a CF run loop running, even if you think you don't need one. Ethan... On Mar 15, 2010, at 2:31 PM, Jeff Moore wrote: On Mar 15, 2010, at 1:25 PM, Ethan Funk wrote: How about AudioObjectAddPropertyListener?
Yes and no. The thread context a listener is invoked in has more to do with the specific property being listened to than anything else. I am still having problems getting called back in my code. Does this also try to attach to the main thread run loop?
Yes. What if I am not running a runloop - a command line application or daemon for example?
A command line tool or daemon that doesn't task it's main thread's run loop has two options. It can either be modified such that the tool/daemon does task the main thread's run loop. Or the tool/daemon can set kAudioHardwareRunLoop to tell the HAL what thread it should use. Note that you have to do one or the other to have a functional HAL in your process. Ethan...
On Mar 15, 2010, at 11:30 AM, Jeff Moore wrote:
A couple of things come to mind.
The default device is a setting that is tracked on a per-user basis. It doesn't sound like this is something is tripping you up currently, but it is something to keep in mind when writing a program that monitors the settings used by other programs.
The most likely cause of your problem is that your process's main run loop is not getting time to run. Note that by default, the HAL will attach all it's notifications and what not to the main thread's run loop. If this run loop never gets a chance to run, the HAL will never know about things going on in the rest of the system.
There are two solutions. You can either modify your program such that the main thread's run loop gets time to run. Or you can tell the HAL to use another thread for notifications using the system object property, kAudioHardwareRunLoop. Note that if you set the value of kAudioHardwareRunLoop to NULL, the HAL will create and manage it's own thread for notifications.
--
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