skip to Main Content

After recently installing iOS 16 beta 5, we are experiencing an issue with try AVAudioSession.sharedInstance().setCategory(<category>, options: .mixWithOthers), in which we get an error, and lose the connection.

Here is the error:

AVAudioSession_iOS.mm:2365 Failed to set category, error: 'what'

There is no additional information about this error. Any help would be greatly appreciated.

FYI: This only began to occur specifically in iOS Beta 5, and was previously working in iOS Beta 4.

2

Answers


  1. Your category is probably wrong. From the docs for .mixWithOthers:

    You can set this option explicitly only if the audio session category is playAndRecord, playback, or multiRoute. If you set the audio session category to ambient, the session automatically sets this option. Likewise, setting the duckOthers or interruptSpokenAudioAndMixWithOthers options also enables this option.

    I expect that your category is not playAndRecord, playback, or multiroute. Many AVAudioSession configurations have non-obvious requirements that may or may not be enforced in a particular version of the OS. I highly recommend reading the docs for every AVAudioSession method you call and every constant you use. The audio frameworks are filled with things that don’t do precisely what their names imply.

    'what' is a 4-character code (an old way of expressing a 32-bit integer as a "string-like thing"). It means AVAudioSessionErrorCodeUnspecified (see the AudioSessionTypes.h header.)

    Login or Signup to reply.
  2. We’ve just hit this on iOS 16.1 (20B82). We were initially setting the category to .playback, then changed it to .playAndRecord when we needed to do recording.
    It was when we tried to change it back to .playback that we got the error.

    I found that audioSession.setActive(false) before switching category, followed by audioSession.setActive(true) fixed the error.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search