User guide

[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(handleRouteChange:)
name:AVAudioSessionRouteChangeNotification
object:session];
[session setActive:YES error:&audioSessionError];
if (audioSessionError) {
NSLog(@"Error %ld, %@, (long)audioSessionError.code,
audioSessionError.localizedDescription);
}
sampeRate = session.sampleRate;
bufferDuration = session.IOBuffferDuration;
NSLog(@"Sampe Rate:%0.0fHZ I/O Buffer Duration:%f", sampleRate, bufferDuration);
Querying Hardware Characteristics
Hardware characteristics of an iOS device can change while your app is running, and can differ from device to
device. When you use the built-in microphone for an original iPhone, for example, recording sample rate is
limited to 8 kHz; attaching a headset and using the headset microphone provides a higher sample rate. Newer
iOS devices support higher hardware sample rates for the built-in microphone.
Your apps audio session can tell you about many hardware characteristics of a device. These characteristics
can change at runtime. For instance, input sample rate may change when a user plugs in a headset. See
AVAudioSession Class Reference for a complete list of properties.
Before you specify preferred hardware characteristics, ensure that the audio session is inactive. After establishing
your preferences, activate the session and then query it to determine the actual characteristics. This final step
is important because in some cases, the system cannot provide what you ask for.
Optimizing Your App for Device Hardware
Querying Hardware Characteristics
2014-09-17 | Copyright © 2014 Apple Inc. All Rights Reserved.
34