Skip to content

Draft: ios: Set up AVAudioSession to ensure playback won't get muted

Currently not fully tested, as on my iOS test device (on 17.4.1) osxaudiosrc does not produce any buffers and stays in PAUSED, so I can't exactly test the interaction.

It's a bit annoying how much code there is around such a simple thing, especially with the separate CoreAudio layer implementations, but if that ensures no races happen (even though it's not really a critical thing) then I guess it's fine.

Not entirely sure with where I put the set_context bits, might need to rethink a bit but I'd like to test if it works first anyway.

Technically, on some versions of iOS (undocumented, but judging from my research - quite recent), when the mic is used (with proper permissions) the category is automatically switched to AVAudioSessionCategoryPlayAndRecord. In that case, or in any other cases where the category is not the default one, this will stop doing anything to not mess with whatever is happening externally.

Context retrieval/creation parts were based on existing implementations (e.g. gstcudautils.cpp), as I assumed they would do things correctly.

Without this, the ring/silent switch on iOS devices will completely mute any playback from us.
Implemented in a GstContext to ensure it's not racy when we have both osxaudiosrc and osxaudiosink.
If it detects that the category is changed manually, it won't intervene anymore to not mess with whatever
the user is doing.

Merge request reports