I/O Kit Audio Support

The IOAudioFamily handles audio in the kernel and facilitates the creation of drivers for audio hardware. The responsibility of an audio driver is conceptually very simple; it merely transfers data to and from the hardware on behalf of clients (much like any hardware driver). It is also responsible for performing actions like muting, controlling the volume, or other configurable attributes. Core Audio uses 32-bit floating-point format as its native audio format and because not all devices will support this, a driver must handle conversion to and from a format the hardware is able to handle. Figure 12-3 shows the hierarchy of classes that make up the IOAudioFamily.

images

Figure 12-3. IOAudioFamily classes

Let's have a look at the role of each class in the family.

  • The IOAudioDevice class serves as a central coordination point for an audio driver. It is responsible for attaching to a hardware provider and configuring and initializing the hardware. The class itself is not usually directly involved in the I/O of audio, which instead is the role of IOAudioEngine. The IOAudioDevice class also centralizes timing and synchronization services.
  • The IOAudioEngine represents the DMA or I/O engine of an audio driver. Because an audio device can have many inputs and outputs that operate independently, it makes sense to encapsulate their behavior into their own class. If you look at the I/O Registry entries for the Apple built-in audio device on a Mac Pro, you will see the Apple audio driver has five instances of IOAudioEngine representing Line input, S/PDIF optical input, Headphone output, Line output, and S/PDIF optical output. An IOAudioEngine must allocate at least one IOAudioStream. The IOAudioEngine is an abstract class.
  • The IOAudioStream represents a sample buffer. A sample buffer has a direction associated with it, which can be either input or output. It also has metadata that describes the formats it is capable of supporting, such as the numeric format of the contained samples, the sample rate, and the number of channels supported. The class is not abstract and can be instantiated directly. The class does not allocate memory for the sample buffer itself. It has to be told the location of the buffer. It is responsible for exposing the sample buffer to user space consumers. The audio stream also maintains an internal mix buffer where audio from multiple sources is mixed together into a single stream.
  • The IOAudioControl class represents a tunable parameter of the device, such as the input volume, output volume, and mute. The IOAudioControl class is directly usable, but you can also subclass it yourself to create custom controls. Three subclasses of IOAudioControl exist, IOAudioLevelControl, IOAudioSelectorControl, and IOAudioToggleControl. A control may belong to the device itself, the engine, or an IOAudioPort.
  • IOAudioPort can be used to represent a logical or physical port, such as Line out or Headphone out. The use of this class is not required for an audio driver.
  • The Core Audio framework communicates with an IOAudioEngine through the IOAudioEngineUserClient, which allows it to interact with the engine's sample buffers for the purpose of playing back or capturing audio.
  • The IOAudioControlUserClient serves as a user client for IOAudioControl instances and allows manipulation. This is how an application, such as System Preferences, can control volume or mute.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.149.254.7