CoreAudio Overload Warnings

Q: CoreAudio is sending me occasional overload warnings when processing audio. What do these warnings mean, and what should I do to help eliminate these problems?

A: The HAL IOProc is a time-limited, high-priority thread. CoreAudio will generate an overload warning in order to indicate that a recent I/O cycle took too long to complete. This happens when the time allocated, by the HAL, expires before the IOProc returns. These types of warnings can be commonplace under high cpu load and/or low memory conditions. Some kernel-level tasks may also be causing your IOProc to be preempted, VM paging being a big one, especially when memory is sparse.

Optimize! Optimize! Optimize!

If you have Apple's CHUD tools installed you can use Shark and/or Saturn to profile your IOProc. These tools will allow you to determine any bottlenecks or IOProc preemptions caused by your code. Tools and documentation are available online under Performance & Debugging.

Apple also provides the HALLab utility (/Developer/Examples/CoreAudio/HAL/HALLab). You can use this application to monitor the statistics of your I/O cycle to get a better idea of where in the cycle the overload is occurring. This information can found in the IO Telemetry window (File->New:).

Process audio outside the HAL thread

If applicable to your situation, it is recommended that you create a separate thread for preparing audio data for the IOProc. For example, file or network I/O, codec decompression, or other tasks that may induce a high-level of latency can be done from a lower priority thread. The resultant data can then be fed to the IOProc.

Note: If you are developing an Audio Unit Effect, data processing must be done in real-time and a secondary processing thread is not an applicable practice.

Some simple tips:

  • Don't take locks if the action of acquiring the lock could be unbounded.

  • Do examine the size of buffer you're supplying to CoreAudio. It's possible it is larger than the device can handle in a single cycle.

  • Don't allocate memory from your IOProc. This can lead to VM paging.

  • Don't call the BSD layer from your IOProc. Many of these API's take kernel-locks which can cause your IOProc to be preempted. This includes printf and its family members.

  • Do take a look at the PublicUtility framework (/Developer/Examples/CoreAudio/PublicUtility/). It provides many handy wrappers for I/O cycle and latency timing.

References

  • CoreAudio Documentation

  • CoreAudio Mailing List

  • HALLab - /Developer/Examples/CoreAudio/HAL/HALLab

  • PublicUtility - /Developer/Examples/CoreAudio/PublicUtility

  • PlaySequence - /Developer/Examples/CoreAudio/Services/PlaySequence

  • Example AudioUnits - /Developer/Examples/CoreAudio/AudioUnits

Back to Top 

Document Revision History

DateNotes
2006-03-29First Version

Posted: 2006-03-29


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.