AudioComponentInstanceNew takes several seconds to complete

I'm using a VoiceProcessingIO audio unit in my VoIP application on Mac. The problem is, at least since Mojave, AudioComponentInstanceNew blocks for at least 2 seconds. Profiling shows that internally it's waiting on some mutex and then on some message queue. My code to initialize the audio unit is as follows:


  OSStatus status;
  AudioComponentDescription desc;
  AudioComponent inputComponent;
  desc.componentType = kAudioUnitType_Output;
  desc.componentSubType = kAudioUnitSubType_VoiceProcessingIO;
  desc.componentFlags = 0;
  desc.componentFlagsMask = 0;
  desc.componentManufacturer = kAudioUnitManufacturer_Apple;
  inputComponent = AudioComponentFindNext(NULL, &desc);
  status = AudioComponentInstanceNew(inputComponent, &unit);


Here's a profiler screenshot showing the two system calls in question.


So, is this a bug or an intended behavior?

Replies

Hi

I'm facing the same issue

Did you find a way to solve it?

Hi I'm facing the same issue too. In my case, when airpod is connected, it takes several seconds to complete Did you find a way to solve it?

Add a Comment

I didn't solve this because I no longer work on that project. They've also since replaced my library with WebRTC.

This issue may or may not be present in modern versions of macOS — I haven't built anything related to CoreAudio since 2019.