Audio Unit session management is one of the most common topics developers ask us about while working on iOS apps. This reference attempts to serve as an entry point for diagnosing and customizing audio routing for your application.
How It Works
All of the code that controls audio playback and recording in the OpenTok iOS SDK is open sourced as a sample application [link]. If no audio device is set prior to the first instantiation of OTSession, the default driver internal to the SDK will be used. Using the sample audio device is the best way to debug runtime audio issues encountered during app development.
Interruption & Route Handling
Apart from debugging, another reason to adopt an external audio driver is to override default behaviors for handling audio events on the end user's device. Incoming phone calls, Siri activations, app switches, and device plugins are some of the events that will interrupt an active audio session working with OpenTok. The default implementation in the SDK attempts to handle all of these situations gracefully, however in some cases it may be prudent to provide alternative event handling behavior.
In some situations, audio may become corrupted by misconfigured sessions or interfering other audio classes, for example MPMoviePlayerController or AVAudioPlayer. The best approach for diagnosing and solving audio integrity issues is to make sure that compatible sample rates and formats are used, and to ensure that the audio session for the app is being properly managed between contending resources.
Sample Formats & Rates
The notes in the README for the external audio device sample application have the most up to date information on known working (and breaking) configurations.