0

When my app is sent into the background, a red status bar flashes briefly. I can live with that. The problem is, if the user then changes the route (eg., plugs or unplugs headphones), the red status bar comes on and stays on (until the app is killed or foregrounded).

My app uses audio session category AVAudioSessionCategoryPlayAndRecord, but not when backgrounded. I change the category to playback and then deactivate the audio session when the app goes into the background, but have not been able to suppress the red flash nor the bigger problem with route changes.

Phil Mitchell
  • 699
  • 8
  • 25

1 Answers1

0

Looks like changing the category isn't sufficient -- if the session was created with inputEnabled true, then you're stuck with the status warnings. You'll have to release the session completely. See this question for discussion with final answer "...the only way is to actually release audioController."

Community
  • 1
  • 1
Alex Curylo
  • 4,744
  • 1
  • 27
  • 37
  • I saw that answer, but it's based on the Amazing Audio Engine and I didn't see how to apply it here. AVAudioSession is a singleton, afaik it doesn't make sense to release it. – Phil Mitchell Jul 16 '16 at 18:11
  • 1
    Take a look at [AEAudioController.m](https://github.com/TheAmazingAudioEngine/TheAmazingAudioEngine/blob/master/TheAmazingAudioEngine/AEAudioController.m) and see what of it does in `dealloc` is applicable to your own code. – Alex Curylo Jul 16 '16 at 20:45
  • Nice idea, but I don't find anything useful there. It's all a teardown of its own data structures. – Phil Mitchell Jul 16 '16 at 21:59
  • 1
    You've shut down all background processing? You're not holding on to an AUGraph, or any other system data structures? – Alex Curylo Jul 16 '16 at 23:53
  • I'm not doing anything low level, just using AVFoundation for playback and mic input. However, you did give me a good lead ... I need to look at the OpenEars speech recognizer I'm using and see if that's causing the issue ... I was focused on the audio session and not thinking of that. – Phil Mitchell Jul 17 '16 at 00:16
  • Awarding you the bounty ... the answer wasn't quite right, but you got me onto the right track! Turns out it was a mic left open for my speech recognizer. – Phil Mitchell Jul 20 '16 at 21:04