Skip to content
This repository has been archived by the owner on Mar 23, 2024. It is now read-only.

Crash EXC_BAD_ACCESS when switching output/Input wile doing VOIP call with Active Audio Unit. #73

Open
jr9098 opened this issue Apr 6, 2023 · 0 comments

Comments

@jr9098
Copy link

jr9098 commented Apr 6, 2023

Hi there, I've been trying to use your library to have list of input and output devices which is working fine. I am able to get a list of all inputs and outputs available. However, when I try to switch output/input from my AirPods to the BuiltIn speakers and Microphone I get a crash like the following.

* thread #56, queue = 'HALC_ShellObject_Listener Queue', stop reason = EXC_BAD_ACCESS (code=1, address=0x48)
  * frame #0: 0x000000028bdccc34 AudioDSP`___lldb_unnamed_symbol14106 + 196
    frame #1: 0x00000001906ace44 CoreAudio`HALObject::PropertiesChanged(unsigned int, AudioObjectPropertyAddress const*) + 1728
    frame #2: 0x0000000190539478 CoreAudio`HALSystem::AudioObjectPropertiesChanged(AudioHardwarePlugInInterface**, unsigned int, unsigned int, AudioObjectPropertyAddress const*) + 232
    frame #3: 0x000000019072335c CoreAudio`_SendPropertiesChanged(void*) + 44
    frame #4: 0x000000010848fda4 libclang_rt.asan_osx_dynamic.dylib`asan_dispatch_call_block_and_release + 224
    frame #5: 0x000000010936a9d4 libdispatch.dylib`_dispatch_client_callout + 20
    frame #6: 0x0000000109373d74 libdispatch.dylib`_dispatch_lane_serial_drain + 984
    frame #7: 0x0000000109374e00 libdispatch.dylib`_dispatch_lane_invoke + 484
    frame #8: 0x00000001093768c8 libdispatch.dylib`_dispatch_workloop_invoke + 2876
    frame #9: 0x0000000109384990 libdispatch.dylib`_dispatch_workloop_worker_thread + 1064
    frame #10: 0x0000000108127d28 libsystem_pthread.dylib`_pthread_wqthread + 288

Here is a little snippet of what I'm doing.

            audioQueue.async { // concurrent queue for the audio
                output.isDefaultOutputDevice = true
                input.isDefaultInputDevice = true
                recreateAudio() // AudioUnitStop, AudioUnitUninitialize, AudioUnitDispose, AudioUnitInitialize, AudioUnitStart
            }

/*!
@function AudioUnitUninitialize
@abstract uninitialize an audio unit
@discussion Once an audio unit has been initialized, to change its state in response to
some kind of environmental change, the audio unit should be uninitialized.
This will have the effect of the audio unit de-allocating its resources.
The caller can then reconfigure the audio unit to match the new environment
(for instance, the sample rate to process audio is different than it was) and
then re-initialize the audio unit when those changes have been applied.

I am still new to all these CoreAudio concepts so I am not sure if this is the right way but when I don't recreate the audio chain, there is no sound anymore after the switch of input/output.

SimplyCoreAudio is instantiate at the launch of the App and I keep a strong reference to it inside a class like this:

private let coreAudio: SimplyCoreAudio = SimplyCoreAudio()

My Project is running on Mac OS Catalyst on Mac OS Ventura. If you need more information please tell me, I would be very glad to get some help on this issue I'm facing, thank you!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant