• 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
GUI Apps should set kAudioHardwarePropertyRunLoop in the HAL
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Prev by Date: Re: Is entering MIDIEvents into MusicSequence while playing safe?
  • Next by Date: Algebra Graph replacement (slightly ot)
  • Previous by thread: Re: Is entering MIDIEvents into MusicSequence while playing safe?
  • Next by thread: Algebra Graph replacement (slightly ot)
  • Index(es):
    • Date
    • Thread