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.

We are having the same issue with current MacOS versions on a host of different Macs (x86 and x64 alike). It takes two to three seconds until AudioComponentInstanceNew returns. We also see the following errors in the log multiple times:

AUVPAggregate.cpp:2560 AggInpStreamsChanged wait failed

and those right after (which I don't know if they matter to this issue):

KeystrokeSuppressorCore.cpp:44 ERROR: KeystrokeSuppressor initialization was unsuccessful. Invalid or no plist was provided. AU will be bypassed. vpStrategyManager.mm:486 Error code 2003332927 reported at GetPropertyInfo