Skip to content

osxaudiosrc: Fixes for failing init/no output on recent iOS versions

Contains a couple fixes required to get osxaudiosrc to work correctly on iOS (>=17) again. Setting up the AVAudioSession also benefits osxaudiosink because it will no longer be silenced by the OS-wide silent mode (meant to silence notifications, not multimedia).

    osxaudio: Automatically set up AVAudioSession on iOS

    A correctly configured AVAudioSession is needed on iOS to:
    - allow the application to capture microphone audio (in some cases)
    - avoid playback being silenced in silent mode

    Without this, initializing AudioUnit for capture can fail on iOS >=17 (from my testing).

    Since AVAudioSession has a lot of settings, in most cases its setup should be handled by the user/app.
    However, just to have a basic default scenario covered, let's configure the bare minimum ourselves,
    and allow anyone to disable that behaviour by setting configure-session=false on src/sink.
    osxaudio: Fix AudioOutputUnitStart() deadlock on iOS >=17

    At some point in iOS 17, this call started waiting for the first render callback (io_proc) to finish.
    In our case, that callback also takes the ringbuf object lock by calling gst_audio_ring_buffer_set_timestamp(),
    which results in a deadlock.
    osxaudiosrc: Fix render callback removal when pausing/stopping

    At least on iOS, the 'input' callback kept being called after going to PAUSED.
    Specifying the right type (like in gst_core_audio_io_proc_start()) fixes that.
    osxaudiosrc: Work around timestamps on iOS not starting from 0

    On macOS, you always get your own 'timeline' for the AudioUnit session, so timestamps start from 0.
    On iOS however, AudioUnit seems to give you a 'shared' timeline so timestamps start at a later, non-0 point in time.
    Simply offsetting seems to do the trick.

    This was causing osxaudiosrc to not output any sound on iOS.

    Regressed in 2df9283d3f2ea06af5ebd6db03a6d545cac52f19
Edited by Piotr Brzeziński

Merge request reports

Loading