coreaudio crash on new M1 mac

  apple-m1, c++, core-audio, kernel-extension, macos

I’m trying to write audio kernel extension similar to PhantomAudioDriver or (SoundFlower which is based on it) on new M1 mac.

I built it, it loads and I also able to set it as default device.
During initialization I check each part and everything initializes and creates without any error, but when I play something while set my virtual device as default, it just freezes. While using QuickTime player, it just does nothing, but while I try to play videos using vlc, it freezes some seconds but it does play video, without audio.

in kernel logs I saw that it definitely starts audio engine:

kernel: (IOAudioFamily)   engine started  

Because IOAudioFamily's code is open source, I was able to check and analyze my code, based on kernel logs and it works how it should and it doesn’t return any error.

But after some seconds, in kernel logs I see that engine stopping commands is called.
I was able to identify that it starts closing after this log:

coreaudiod: (CoreAudio)  HALS_IOContext::IOWorkLoop: could not establish a timeline after waiting 10000000 microseconds for context 214 <private>

Have you ever seen it? HALS_IOContext's code unfortunately is not open source and I don’t get it why it’s happening.

in code:

wl = getWorkLoop();
if (!wl) {
    goto Done;
}
    
timerEventSource = IOTimerEventSource::timerEventSource(this, timerFired);
    
if (!timerEventSource) {
    goto Done;
}

So it definitely does not fail to get workloop.

After that logs IOAudioFamily's stop commands are called and it stops engine and close client.
And I see that CoreAudio error:

coreaudiod: (CoreAudio)  HALS_IOContext::StartIOThread: the IO thread failed to start, Error: 1852797029 (<private>)

And QuickTime player get this one:

QuickTime Player: (CoreAudio)  HALC_ProxyIOContext::IOWorkLoop: the server failed to start, Error: 0x6E6F7065

I also checked logs between starting and closing client logs (and what I see it’s nothing useful and understandable there) and maybe I should some specific process logs?

Also, maybe there are other ways to see HALS source code.
I’d definitely appreciate your expertise and help.

Source: Windows Questions C++

LEAVE A COMMENT