2017-02-24 14:56:44.280 PropertyManager[10172:5336578] 14:56:44.280 ERROR: [0x1a0a24000] AVAudioSession.mm:692: -[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.
2017-02-24 14:56:44.281 PropertyManager[10172:5336578] error === Error Domain=NSOSStatusErrorDomain Code=560030580 "(null)"
PropertyManager was compiled with optimization - stepping may behave oddly; variables may not be available.
Your error log is very succinctly self-expressive:
Deactivating an audio session that has running I/O. All I/O should be stopped or paused prior to deactivating the audio session
It tells you the problem and also the solution.
Right now you're doing something like this:
[[AVAudioSession sharedInstance] setActive:NO
withOptions:AVAudioSessionSetActiveOptionNotifyOthersOnDeactivation
error:nil];
You should however, first stop the audio player instance and then set the activation status to Yes or No.
[yourAudioPlayer stop];
[[AVAudioSession sharedInstance] setActive:NO
withOptions:AVAudioSessionSetActiveOptionNotifyOthersOnDeactivation
error:nil];
Refer to Apple Documentation to see values of enum AudioSessionSetActiveOption.
Also see: Apple Documentation on setActive:withOptions method
As for your second error
PropertyManager was compiled with optimization - stepping may behave oddly; variables may not be available.
see this excellent answer.
@NSNoob is 100% correct. The player (or something else) is still active.
More from dani-mp. He said:
I'd say that pausing the player is not a synchronous operation, so we shouldn't be deactivating the session before knowing that the player has been paused (see the response in this thread).
A solution for this problem could be that we listen to changes to timeControlStatus and deactivate the audio session once the player has really been paused.
The answer in the thread says
This error indicates that something in your app is still using audio I/O at the time when the AVAudioSession setActive:NO is being called. It’s impossible to say which object without more information, but sometimes it’s the result of calling an asynchronous stop method on a player of some sort and not waiting for the notification that the player has stopped before deactivating the audio session.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With