0

the audio unit subType is kAudioUnitSubType_VoiceProcessingIO, and use kAudioOutputUnitProperty_CurrentDevice to set Device ID for the audio unit

OSStatus result = AudioOutputUnitStop(audio_unit);
result = AudioUnitUninitialize(audio_unit);
result = AudioComponentInstanceDispose(audio_unit);

Thread trace:

3   ExceptionHandling                   0x00007fff3c64ef31 -[NSExceptionHandler _handleException:mask:] + 364
4   ExceptionHandling                   0x00007fff3c64ecac NSExceptionHandlerUncaughtSignalHandler + 35
5   libsystem_platform.dylib            0x00007fff204d3d7d _sigtramp + 29
6   CoreFoundation                      0x00007fff2050f381 CFStringGetLength + 11
7   CoreFoundation                      0x00007fff205225c7 CFStringCompare + 24
8   CoreAudio                           0x00007fff221e83f5 _ZN9HALDevice4DuckEfPK14AudioTimeStampf + 921
9   CoreAudio                           0x00007fff21d3ed48 AudioDeviceDuck + 843
10  AudioDSP                            0x00000001390d7d4a _Z14DuckOtherAudiojff + 51
11  AudioDSP                            0x0000000139213e06 _ZN16AUVoiceProcessor22DestroyAggregateDeviceEv + 974
12  AudioDSP                            0x0000000139215459 _ZN16AUVoiceProcessorD2Ev + 417
13  AudioDSP                            0x00000001392efdec _ZN13ComponentBase8AP_CloseEPv + 30
14  AudioToolboxCore                    0x00007fff219e4b6a AudioComponentInstanceDispose + 55
as.a.bell
  • 21
  • 2

1 Answers1

0

You are disposing of an Audio Instance before it is stopped.

Note that AudioOutputUnitStop may not stop an audio unit immediately, since the audio thread runs asynchronously. If you delay for a half second after stopping the audio unit, that other thread is likely stopped by then and then you can more safely dispose of its resources.

hotpaw2
  • 70,107
  • 14
  • 90
  • 153
  • before AudioUnitUninitialize, I get the property "kAudioOutputUnitProperty_IsRunning" for audio unit, the status is not running. – as.a.bell Apr 28 '21 at 07:40
  • That may or may not tell you if the audio unit is completely stopped and disconnected from all other kernel processes. Only that you told it to stop. – hotpaw2 Apr 28 '21 at 23:10