User guide

Using audio session properties, you can optimize your apps audio behavior for device hardware at runtime.
This lets your code adapt to the characteristics of the device it’s running on, as well as to changes made by
the user (such as plugging in a headset or docking the device) as your app runs.
The audio session property mechanism lets you:
Specify preferred hardware settings for sample rate and I/O buffer duration
Query many hardware characteristics, among them input and output latency, input and output channel
count, hardware sample rate, hardware volume setting, and whether audio input is available
Respond to device specific notifications
The most commonly used property value change event is route changes, covered in Responding to Route
Changes (page 37). You can also write callbacks to listen for changes in hardware output volume and changes
in the availability of audio input.
Choosing Preferred Audio Hardware Values
Use the audio session APIs to specify preferred hardware sample rate and preferred hardware I/O buffer
duration. Table 4-1 describes benefits and costs of these preferences.
Table 4-1 Choosing preferred hardware values
Preferred I/O buffer durationPreferred sample rateSetting
Example: 500 mS
+ Less-frequent disk access
Longer latency
Example: 44.1 kHz
+ High audio quality
Large file size
High value
Example: 5 mS
+ Low latency
Frequent disk access
Example: 8 kHz
+ Small file size
Low audio quality
Low value
2014-09-17 | Copyright © 2014 Apple Inc. All Rights Reserved.
32
Optimizing Your App for Device Hardware