core audio user-space driver sandboxing preventing data interaction from another process

Hello everyone,


I'm working on a coreaudio user-space hal plugin based on the example

https://developer.apple.com/library/mac/samplecode/AudioDriverExamples/Introduction/Intro.html


I plan to obtain audio data from another process i.e. CFMessagePort


However, I got the following error in console trying to create port CFMessagePortCreateLocal...

sandboxd[251]: ([2597]) coreaudiod(2597) deny mach-register com.mycompnay.audio


I did some googlging and came to this article


Technical Q&A QA1811

https://developer.apple.com/library/mac/qa/qa1811/_index.html

about adding AudioServerPlugIn_MachServices in plist but still no success.


Is there anything else I need to do to make this work (like adding entitlements, code-sign) or this is not the correct approach.?

I am not sure if MesssagePort mechanism works anymore under sandbox. would XPC Services be viable?


update 1.


I should be creating a remote port instead of a local in the audio plug-in. Having that said, with the AudioServerPlugIn_MachServices attribute in the plist. now there is no sandboxd[559]: ([552]) coreaudiod(552) deny mach-lookup / register message in console.

However, in my audio hal plug-in (client side) I have


CFStringRef port_name = CFSTR("com.mycompany.audio.XPCService");
CFMessagePortRef port = CFMessagePortCreateRemote(kCFAllocatorDefault, port_name);
SInt32 status = CFMessagePortSendRequest(port, 22, NULL, 1000, 0, NULL, NULL);

port has return the value of 0 and therefore gets an access violation in SendRequest. I tried this in a different app and it works just fine.


This is my server side:

CFDataRef callback(CFMessagePortRef local, SInt32 msgid, CFDataRef data, void *info)
{
    int x = 0;
    printf("helo world\n");
    return NULL;
}
...
CFStringRef port_name = CFSTR("com.mycompany.audio.XPCService");
CFMessagePortRef port = CFMessagePortCreateLocal(kCFAllocatorDefault, port_name, &callback, NULL, NULL); 
CFRunLoopSourceRef runLoopSource = CFMessagePortCreateRunLoopSource(nil, port, 0); 
CFRunLoopAddSource(CFRunLoopGetCurrent(), runLoopSource, kCFRunLoopCommonModes); 
CFRunLoopRun();


I did get a console message regarding this.

com.apple.audio.DriverHelper[1314]: The plug-in named SimpleAudioPlugIn.driver requires extending the sandbox for the mach service named com.mycompnay.audio.XPCService

anyone know why..??


update 2.

I noticed that when I use the debug mode with coreaudiod it does successful get the object reference of the mach service. (same thing happened when I was trying the xpc_service approach)

project scheme setting


Thank you very much for your time. Any help is greatly appreciated

Allen.

core audio user-space driver sandboxing preventing data interaction from another process
 
 
Q