Re: Device unplugged, how application should handle the situation?
Re: Device unplugged, how application should handle the situation?
- Subject: Re: Device unplugged, how application should handle the situation?
- From: Jeff Moore <email@hidden>
- Date: Thu, 10 Nov 2005 11:34:14 -0800
I'll preface these comments with a general note that most
applications should be using AUHAL to do their audio IO. AUHAL
handles all the heavy lifting with regards to being a proper HAL
client. In other words, if you were using AUHAL, you wouldn't have to
worry about any of this stuff.
On Nov 10, 2005, at 1:34 AM, Rustam Muginov wrote:
Hello all.
Suppose my application have IOProc attached and running to the
AudioDevice, as well as a some listeners to the properies, like
kAudioDevicePropertyDeviceIsAlive.
Then application discovered that device is no more alive, either
being notified by global property kAudioHardwarePropertyDevices or
by device-bound property kAudioDevicePropertyDeviceIsAlive.
The AudioHardware.h header says about
kAudioDevicePropertyDeviceIsAlive: "After receiving notification on
this property, any AudioDeviceID's referring to the destroyed
device are invalid. ".
Does this mean application could not remove property listeners and
stop then remove IOProc from the device which gone?
No, but you should be prepared to get errors. By the time the HAL
gets notified that a given device has gone away, all the IOKit stuff
has been torn down and many properties of the device that existed
previously will no longer be around.
When the HAL sends the kAudioDevicePropertyDeviceIsAlive
notification, the actual AudioDevice object is still around and you
should feel free to remove any IOProcs or property listeners you have
installed. It's always good practice to do so.
Does this mean such "clean-up" is not necessary, and after device
is gone it is guaranteed then IOProc attached to that device never
would be called?
As part of tearing down it's internal representation, the HAL stops
all the IOProcs, and discards all it's internal buffers and stops
tracking any registered IOProcs or property listeners. So strictly
speaking, you don't have to worry to much about unregistering IOProcs
or property listeners; it happens as a matter of course.
However, it is still good practice for your app to always unregister
stuff, provided you are prepared for errors (which you can safely
ignore).
Are where any leaks in such situation, or CoreAudio correctly
handle it?
As far as I know, the HAL doesn't leak any of it's own data
structures. If it did, that would be a bug that should be filed in
Radar.
--
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