I tried to reproduce the problem using the play_sound Xcode example that comes with the FMOD engine download. While the example doesn’t crash when I remove my headphone from the headphone jack while its running, I do get a somewhat interesting log output:
2022-08-10 14:07:14.122169+0200 play_sound[4316:32249] SecTaskLoadEntitlements failed error=22 cs_flags=20, pid=4316
2022-08-10 14:07:14.122335+0200 play_sound[4316:32249] SecTaskCopyDebugDescription: play_sound[4316]/0#-1 LF=0
[LOG] SystemI::init : Initialize version=20207 (125130), maxchannels=32, flags=0x00000000
[LOG] SystemI::setOutputInternal : Setting output to ‘FMOD Core Audio Output’
2022-08-10 14:07:14.360654+0200 play_sound[4316:32678] [plugin] AddInstanceForFactory: No factory registered for id <CFUUID 0x600001644520> F8BB1C28-BAE8-11D6-9C31-00039315CD46
[LOG] OutputCoreAudio::init : Output running 2 channels at 44100Hz sample rate.
[LOG] OutputCoreAudio::init : Maximum hardware read size: 512 samples, Software buffer size: 512 samples, Number of software buffers: 4.
[LOG] SystemI::init : Output requires a sample rate of 44100Hz, resampling will occur.
[LOG] Thread::initThread : Init FMOD stream thread. Affinity: 0x4000000000000003, Priority: 0xFFFF7FFB, Stack Size: 98304, Semaphore: No, Sleep Time: 10, Looping: Yes.
[LOG] Thread::initThread : Init FMOD mixer thread. Affinity: 0x4000000000000001, Priority: 0xFFFF7FFA, Stack Size: 81920, Semaphore: Yes, Sleep Time: 0, Looping: Yes.
[LOG] SystemI::createSoundInternal : Create name=‘/Users/thstehle/Library/Developer/Xcode/DerivedData/play_sound-embpzygqjppqtybrdtewamsyzzwf/Build/Products/Debug/play_sound.app/Contents/Resources/media/drumloop.wav’, mode=0x00000000
[LOG] SystemI::createSoundInternal : Sample 0/0: name=‘(null)’, format=2, channels=1, frequency=44100, lengthbytes=84316, lengthpcm=42158, pcmblocksize=0, loopstart=20512, loopend=42157, mode=0x00000002, channelmask=0x00000000, channelorder=0, peakvolume=0.000000.
[LOG] SystemI::createSoundInternal : Create name=‘/Users/thstehle/Library/Developer/Xcode/DerivedData/play_sound-embpzygqjppqtybrdtewamsyzzwf/Build/Products/Debug/play_sound.app/Contents/Resources/media/jaguar.wav’, mode=0x00000000
[LOG] SystemI::createSoundInternal : Sample 0/0: name=‘(null)’, format=2, channels=1, frequency=22050, lengthbytes=77824, lengthpcm=38912, pcmblocksize=0, loopstart=0, loopend=0, mode=0x00000000, channelmask=0x00000000, channelorder=0, peakvolume=0.000000.
[LOG] SystemI::createSoundInternal : Create name=‘/Users/thstehle/Library/Developer/Xcode/DerivedData/play_sound-embpzygqjppqtybrdtewamsyzzwf/Build/Products/Debug/play_sound.app/Contents/Resources/media/swish.wav’, mode=0x00000000
[LOG] SystemI::createSoundInternal : Sample 0/0: name=‘(null)’, format=2, channels=2, frequency=22050, lengthbytes=32768, lengthpcm=32544, pcmblocksize=1017, loopstart=0, loopend=0, mode=0x00000000, channelmask=0x00000000, channelorder=0, peakvolume=0.000000.
=================================================================
Main Thread Checker: UI API called on a background thread: -[NSApplication delegate]
PID: 4316, TID: 32678, Thread name: (none), Queue name: com.apple.root.default-qos.overcommit, QoS: 0
Backtrace:
4 play_sound 0x000000010264151c _Z13Common_Updatev + 44
5 play_sound 0x00000001026402c1 _Z9FMOD_Mainv + 353
6 play_sound 0x0000000102641f61 -[ExampleApplicationDelegate threadMain:] + 65
7 Foundation 0x00007ff809746964 NSThread__start + 1009
8 libsystem_pthread.dylib 0x000000010ad85c0d _pthread_start + 125
9 libsystem_pthread.dylib 0x000000010ad8dccf thread_start + 15
2022-08-10 14:07:14.550038+0200 play_sound[4316:32678] [reports] Main Thread Checker: UI API called on a background thread: -[NSApplication delegate]
PID: 4316, TID: 32678, Thread name: (none), Queue name: com.apple.root.default-qos.overcommit, QoS: 0
Backtrace:
4 play_sound 0x000000010264151c _Z13Common_Updatev + 44
5 play_sound 0x00000001026402c1 _Z9FMOD_Mainv + 353
6 play_sound 0x0000000102641f61 -[ExampleApplicationDelegate threadMain:] + 65
7 Foundation 0x00007ff809746964 NSThread__start + 1009
8 libsystem_pthread.dylib 0x000000010ad85c0d _pthread_start + 125
9 libsystem_pthread.dylib 0x000000010ad8dccf thread_start + 15
2022-08-10 14:07:19.733698+0200 play_sound[4316:32694] HALC_ProxyIOContext::IOWorkLoop: failed to send the final message to the server, Error: 0x10000003
2022-08-10 14:07:19.997210+0200 play_sound[4316:32732] HAL_HardwarePlugIn_DeviceStart: no device
2022-08-10 14:07:19.997720+0200 play_sound[4316:32732] HALPlugIn::StopIOProc: got an error from the plug-in routine, Error: 560947818 (!obj)
2022-08-10 14:07:20.026177+0200 play_sound[4316:32732] HAL_HardwarePlugIn_DeviceDestroyIOProcID: no device
2022-08-10 14:07:20.026338+0200 play_sound[4316:32732] HALPlugIn::DeviceCreateIOProcID: got an error from the plug-in routine, Error: 560947818 (!obj)
2022-08-10 14:07:20.466014+0200 play_sound[4316:32732] HAL_HardwarePlugIn_ObjectHasProperty: no object
2022-08-10 14:07:20.466259+0200 play_sound[4316:32732] HAL_HardwarePlugIn_ObjectHasProperty: no object
2022-08-10 14:07:20.466357+0200 play_sound[4316:32732] HAL_HardwarePlugIn_ObjectHasProperty: no object
2022-08-10 14:07:20.466470+0200 play_sound[4316:32732] HAL_HardwarePlugIn_ObjectHasProperty: no object
2022-08-10 14:07:20.466567+0200 play_sound[4316:32732] HAL_HardwarePlugIn_ObjectHasProperty: no object
2022-08-10 14:07:20.466644+0200 play_sound[4316:32732] HAL_HardwarePlugIn_ObjectHasProperty: no object
2022-08-10 14:07:20.466828+0200 play_sound[4316:32732] HAL_HardwarePlugIn_ObjectHasProperty: no object
[LOG] Thread::callback : FMOD mixer thread finished.
[LOG] OutputCoreAudio::init : Output running 8 channels at 48000Hz sample rate.
[LOG] OutputCoreAudio::init : Maximum hardware read size: 512 samples, Software buffer size: 512 samples, Number of software buffers: 4.
[LOG] DownMix::init : dspbuffersize: 512 rate: 48000. output speaker mode: 7, input speaker mode 3
[LOG] DownMix::init : done.
[LOG] Thread::initThread : Init FMOD mixer thread. Affinity: 0x4000000000000001, Priority: 0xFFFF7FFA, Stack Size: 81920, Semaphore: Yes, Sleep Time: 0, Looping: Yes.
Here, all the HAL_ output comes the moment I unplug my headphone.
I am on an M1 Mac so another thing worth mentioning is maybe that I could build but not launch the example app using the scheme “My Mac”. Instead, I had to use the scheme “My Mac (Rosetta)” which implies that I had to launch an emulated instead of a native app. When trying to launch the native app Xcode tells me: “The LaunchServices launcher has returned an error. Please check the system logs for the underlying cause of the error.” This log, however, looks somewhat uninteresting so I am not posting it now.
Thanks!
Thomas