My application plays music and records from mic at the same time. Recording can be started after playback is started or before playback is started
And now I want to stop recording but keep playback running at the same time.
How can I do this?
I can stop recording and playback by using
[[AVAudioSession sharedInstance] setActive:NO error:nil];
But the issue is: I want to stop recording only.
I tried to change category to AVAudioSessionCategoryPlayback
using the following code
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:&error]
but that doesn't stop recording.
I solved the issue by explicitly stopping all recording activity without touching AVAudioSession at all.
The following warning
AVAudioSession.mm:623: -[AVAudioSession setActive:withOptions:error:]: Deactivating an audio session that has running I/O. All I/O should be stopped or paused prior to deactivating the audio session.
helped me to identify the issue.
Initially I forgot to call the AudioOutputUnitStop
method of AudioUnit framework. Because of this recording process was still running and audio session were indicating that.