• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Device gone away notification?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Device gone away notification?


  • Subject: Re: Device gone away notification?
  • From: Ethan Funk <email@hidden>
  • Date: Tue, 8 Sep 2009 12:06:56 -0700

It sounds like kAudioDevicePropertyDeviceIsAlive is what I am after.

Then to go full circle with this, can I get notification from the system, probably at the HAL level some place, when a device becomes available from the system, or the device list changes? If so, I can code things so that the output nicely goes away when the device is removed using kAudioDevicePropertyDeviceIsAlive, and if a device come online while my program is running, it can check to see if it is a device it wants to use and set it back up again.

Thanks,
Ethan...

On Sep 8, 2009, at 11:50 AM, Jeff Moore wrote:


On Sep 8, 2009, at 10:27 AM, Ethan Funk wrote:

I am using kAudioUnitSubType_HALOutput. I was expecting my I/O Proc would just stop getting called, which would be fine, but instead, the device seems to get re-directed to the system default device.

I'm pretty sure that this has been the default behavior of AUHAL. I don't believe that there is a way to get AUHAL to just stop when the device it is using goes away. It would probably be worth filing a feature request about it.



I will have a look at some of the notifications mention and see which fits best.

AUHAL will send a notification for kAudioOutputUnitProperty_CurrentDevice on the global scope when it changes the device it is using. You can use this as an opportunity to stop IO or tell the instance of AUHAL to use a different device.


If you want to know when the AudioDevice you are using has been removed from the system, you would listen for notifications on the property, kAudioDevicePropertyDeviceIsAlive. The HAL fires this off just prior to tearing things down.

If you want to know when the AudioDevice you are using stops IO, you would listen to kAudioDevicePropertyDeviceIsRunning. The HAL fires this off just prior to entering and just after leaving the IO thread's work loop.

Remember that AUHAL proxies notifications from the HAL to make listening to HAL property changes much simpler.


I assume the notifications will come in on a realtime thread, so I will need to make sure the handler does not block, correct?

Only kAudioDevicePropertyDeviceIsRunning comes from the IO thread, but it happens at a relatively safe time - either before the HAL starts tracking time or after it is finished. The others will come on less critical thread contexts - usually the HAL's notification thread. Consequently, you can feel safe to block in the listener for any of these properties.




On Sep 8, 2009, at 10:13 AM, Stephen Davis wrote:

If you are using kAudioUnitSubType_DefaultOutput, CoreAudio will track the default device for you which sounds like the behavior you're seeing. If you want to be tied to a particular device, you use kAudioUnitSubType_HALOutput and tell it which device to use.

Off-hand, I'm not sure what happens when the device goes away but, in the absence of any special handling by you, I suspect your I/O proc will just stop getting called which is also what happens when somebody else takes hog mode on the device you're using. I do not know if it will come back but it should be pretty easy for you to find out. As Brian said, you'll need to listen to notifications on that device to find out when it goes away.


--

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

_______________________________________________ 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
  • Follow-Ups:
    • Re: Device gone away notification?
      • From: Jeff Moore <email@hidden>
References: 
 >Device gone away notification? (From: Ethan Funk <email@hidden>)
 >Re: Device gone away notification? (From: Brian Willoughby <email@hidden>)
 >Re: Device gone away notification? (From: Stephen Davis <email@hidden>)
 >Re: Device gone away notification? (From: Ethan Funk <email@hidden>)
 >Re: Device gone away notification? (From: Jeff Moore <email@hidden>)

  • Prev by Date: Re: QTMediaTypeMusic
  • Next by Date: Deprated coreaudio functions in 10.6
  • Previous by thread: Re: Device gone away notification?
  • Next by thread: Re: Device gone away notification?
  • Index(es):
    • Date
    • Thread