Re: mac os x : Unplugging headphones or changing the sampling rate cause the audio to stop
Re: mac os x : Unplugging headphones or changing the sampling rate cause the audio to stop
- Subject: Re: mac os x : Unplugging headphones or changing the sampling rate cause the audio to stop
- From: Jeff Moore <email@hidden>
- Date: Thu, 12 Aug 2010 09:23:27 -0700
From the sound of it, the thing your app isn't doing is allowing the main thread's run loop any time. Either you are blocking it or just aren't tasking it's run loop. There are two ways you can fix this. You can either make sure that the process's main thread's run loop is getting time to run or you can have the HAL run it's own thread to handle notifications by setting kAudioHardwarePropertyRunLoop with a NULL value sometime early in your process's initialization. Most apps do it as part of their main. The code would look something like this:
CFRunLoopRef theRunLoop = NULL;
AudioObjectPropertyAddress theAddress = { kAudioHardwarePropertyRunLoop, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster };
AudioObjectSetPropertyData(kAudioObjectSystemObject, &theAddress, 0, NULL, sizeof(CFRunLoopRef), &theRunLoop);
--
Jeff Moore
Core Audio
Apple
On Aug 12, 2010, at 7:53 AM, Stéphane Beauchemin wrote:
> We use to have working implementation of core audio. Today, I have noticed that unplugging headphone jack cause the audio to stop in our application. The same happens when you change the sampling rate of the default output device when the application is running. The only way of having audio back is to re-lauch the application. I have tested the same with iTunes, and it doesn’t happen.
>
> I have carefully set-up my audio graph so there is a converter node at the end of the processing chain to handle the sample rate changes or default audio output change. I suspect that Snow Leopard update might be the cause, since not much changed happened on our side in this area of the code.
>
> Also, my inputProc function for the converter node (which feed PCM data from the app) is still hitting breakpoint after the headphone jack has been unplug or sample rate has been changed. I have looked at the buffers in the memory browser and the buffer are not zeros… but I hear nothing.
>
> I have tried to set property listener on kAudioDevicePropertyNominalSampleRate or kAudioDevicePropertyJackIsConnected and hopping that calling AuGraphStop and AuGraphStart would solve the problem; however my listener function is never called.
>
> Anyone has a suggestion? What’s wrong?
>
_______________________________________________
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