Chapter 6. Making Some Noise
If there was ever any doubt whether the iPhone was intended to be a
music device, the presence of three different frameworks on the iPhone
just for sound should be all the answer you need. The Core Audio,
Celestial, and Audio Toolbox frameworks all provide different levels of
sound functionality. In addition to this, the iPhone runs an audio daemon
mediaserverd that aggregates the
sound output of all applications and governs events such as volume and
ringer switch changes. There are a lot of moving pieces involved in the
iPhone’s sound framework, but Apple has provided some great interfaces
that make the task painless.
Core Audio: It’s Great, but You Can’t Use It
Of the three frameworks available, Core Audio is the most low-level, and least accessible. Core Audio provides a direct interface to the iPhone’s sound device. There is only one sound device, so only one process can be talking to it at any time. Unlike the Mac OS X desktop, which allows developers to share Core Audio resources, the iPhone has an audio daemon that binds to the device as the iPhone is booted, setting what is called hog mode in many versions of the firmware. Hog mode is a flag hardcoded into the Core Audio framework that prevents any other application from being able to say, “Hey, I’d like to make some sound, can you give up control of the sound card for a minute?” In other words, the audio daemon hogs the sound card all to itself, requiring all sounds to be played through ...