GUI Apps should set kAudioHardwarePropertyRunLoop in the HAL
GUI Apps should set kAudioHardwarePropertyRunLoop in the HAL
- Subject: GUI Apps should set kAudioHardwarePropertyRunLoop in the HAL
- From: Jeff Moore <email@hidden>
- Date: Fri, 6 Dec 2002 16:13:01 -0800
The HAL needs a thread on which it can hang it's notification handlers
for the various messages it gets from the driver and from other
instances of itself in other processes. kAudioHardwarePropertyRunLoop
is used to point the HAL at the CFRunLoop to use for this purpose. By
default, the HAL creates it's own thread for it's notifications. This
is so that all processes, even those without a GUI, can receive
notifications.
Most GUI applciations have several threads on which they receive
notifications already, so the having the HAL's thread around is
wasteful. Here's what you should do: On the thread you want the HAL to
use for notifications (for most apps, this will be the main thread),
add the following two lines of code.
// tell the HAL to use the current thread as it's run loop
CFRunLoopRef theRunLoop = CFRunLoopGetCurrent();
AudioHardwareSetProperty(kAudioHardwarePropertyRunLoop,
sizeof(CFRunLoopRef), &theRunLoop);
The only notable exception is for Java apps as the Java VM does this
for you already. Otherwise, all apps should be setting this property.
For instance, in my own Cocoa apps, I put this code directly in the
main() just before I call NSApplicationMain().
--
Jeff Moore
Core Audio
Apple
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.