Is the AudioFilePlayer sandbox compatible?

I'm having a problem using the AudioFilePlayer audio device with application sandbox support on OS X 10.8. I have an AUGraph with two nodes consisting of an AudioFilePlayer block connected to the DefaultOutput module. The goal (right now) is to simply play one audio file. If the sandbox is not turned on, everything works fine. If I enable the sandbox, AUGraphOpen() returns the error -3000 (invalidComponentID). If I delete the node file player with AUGraph, the error will disappear, which at least means that the problem with the file player is causing the problem.

Here is the code that I use to set the node file player up:

 OSStatus AddFileToGraph(AUGraph graph, NSURL *fileURL, AudioFileInfo *outFileInfo, AUNode *outFilePlayerNode) { OSStatus error = noErr; if ((error = AudioFileOpenURL((__bridge CFURLRef)fileURL, kAudioFileReadPermission, 0, &outFileInfo->inputFile))) { NSLog(@"Could not open audio file at %@ (%ld)", fileURL, (long)error); return error; } // Get the audio data format from the file UInt32 propSize = sizeof(outFileInfo->inputFormat); if ((error = AudioFileGetProperty(outFileInfo->inputFile, kAudioFilePropertyDataFormat, &propSize, &outFileInfo->inputFormat))) { NSLog(@"Couldn't get format of input file %@", fileURL); return error; } // Add AUAudioFilePlayer node AudioComponentDescription fileplayercd = {0}; fileplayercd.componentType = kAudioUnitType_Generator; fileplayercd.componentSubType = kAudioUnitSubType_AudioFilePlayer; fileplayercd.componentManufacturer = kAudioUnitManufacturer_Apple; fileplayercd.componentFlags = kAudioComponentFlag_SandboxSafe; if ((error = AUGraphAddNode(graph, &fileplayercd, outFilePlayerNode))) { NSLog(@"AUAudioFilePlayer node not found (%ld)", (long)error); return error; } return error; } 

Note that fileURL in the call to AudioFileOpenURL () is the URL obtained from the protected bookmark data and is the URL of the file that the user transferred to the application.

If I set the compatibility rights com.apple.security.temporary-exception.audio-unit-host when AUGraphOpen () is called, the user is prompted to lower the security settings and, assuming that they accept, playback works fine again (sandbox disabled).

So, this indicates that the AudioFilePlayer module is not safe or sandbox compatible. It's true? It's hard to believe that Apple would not commit such an important part of the CoreAudio API to be sandbox compatible. Also note that I specify the kAudioComponentFlag_SandboxSafe flag in the description passed to AUGraphAddNode, and this call is not interrupted. In addition, I can only find one link to the AudioFilePlayer, which is not safe for the sandbox online, in the form of this message on the CoreAudio mailing list, and it did not receive any answers. Perhaps I am making another small mistake that causes a problem with the sandbox turned on, but not when it is turned off (I'm new to Core Audio)?

+6
source share

All Articles