Symbol missing for makeRealAudioWorkgroup

I can see that the below method compiles as an mm file, but if I include the header where this one is declared from a file that is compiled as a .cpp file, then I get a linker error saying that there is no symbol for makeRealAudioWorkgroup. If I remove the os_workgroup_t from the signature of this function then the linker error goes away.

I am guessing that os_workgroup_t is different if compiled as objective-c compared to when compiled as c++.

AudioWorkgroup makeRealAudioWorkgroup (os_workgroup_t handle)
    if (handle == nullptr)
        return AudioWorkgroup{};

    return AudioWorkgroup { [provider = AudioWorkgroup::WorkgroupProvider { handle }] { return &provider; } };



juce_AudioWorkgroup_mac.h is not intended to be included directly by users. Instead, you can retrieve a workgroup by calling AudioIODevice::getWorkgroup(), AudioDeviceManager::getDeviceAudioWorkgroup(), or override AudioProcessor::audioWorkgroupContextChanged().

ok, our plugin requires a separate process that talks to hardware. So I would like to resuse as much as possible when joining the thread in the other process to the same audio work group as the one in the DAW. So somehow I need to signal which audio work group that the plugin has and then join any thread in the other process to the same group. Or maybe this is not the best way?

Any guidance is appreciated.

I don’t think that’s directly possible. I would expect that a os_workgroup_type* is local to a specific process in the absense of documentation suggesting otherwise. Trying to read the same pointer address across process boundaries will probably result in undefined behaviour.

As an alternative, perhaps you could open the audio device in the separate process, and then get the workgroup from the audio device there. That said, once you have the audio device open, you’d only need the workgroup if you needed additional threads besides the audio thread, all sharing the same deadline.

From Understanding Audio Workgroups | Apple Developer Documentation

An audio workgroup is a collection of real-time threads that work together to produce audio by a common deadline while spanning multiple processes …

For audio apps and AU plugins, there are dedicated APIs to fetch the correct os_workgroup. My point was that the docs don’t say that it’s valid to share a given os_workgroup_t across process boundaries, so I don’t think that approach will work.

Looking at the docs, there is os_workgroup_create_with_port and os_workgroup_copy_port. The docs for those functions explicitly mention other processes, so that’s probably a good starting point.

1 Like

Ok, thanks!

Using os_workgroups_copy_port and then creating a new workgroup in the same process with os_workgroup_create_with_port works, but if I just use the value of the port (mach_port_t is an unsigned int) in an another process then os_workgroup_create_with_port returns a nullptr. I wonder If I need to do something else before I can use that port in some other process?

os_workgroup_create_with_port says A process may export its workgroup’s Mach port to coordinate any work it’s doing with similar work happening in other processes.

What does “export” mean in this case?

I don’t think we’ve tried this use-case, so I’m not sure how this is supposed to work. I’d assume that just using the same port value would be sufficient, but it sounds like that’s not the case.

If you have an Apple developer account, you will have an allowance of code-level support requests (more details here) - perhaps you could use one of your TSIs to answer this question.

1 Like