I am trying to get samples that are reproduced by kAudioUnitSubType_RemoteIO and which are obtained from kAudioUnitSubType_AudioFilePlayer.
To get these samples, I configured kAudioUnitProperty_SetRenderCallback at the output of the RemoteIO Audio Unit (bus 0). While I manage to play the sound, this render callback does not seem to receive any samples. As far as I understand, the remoteIO callback pulls (displays) the available data (stored in the buffer) from the AudioPlayer FilePlayer (bus 1).
Does anyone know what went wrong?
NewAUGraph(player.graph)
var cd = AudioComponentDescription(componentType: OSType(kAudioUnitType_Generator),
componentSubType: OSType(kAudioUnitSubType_AudioFilePlayer),
componentManufacturer: OSType(kAudioUnitManufacturer_Apple),
componentFlags: 0, componentFlagsMask: 0)
AUGraphAddNode(player.graph, &cd, &player.filePlayerNode)
var rioNode = AUNode()
cd.componentType = OSType(kAudioUnitType_Output)
cd.componentSubType = OSType(kAudioUnitSubType_RemoteIO)
AUGraphAddNode(player.graph, &cd, &rioNode)
AUGraphOpen(player.graph)
AUGraphNodeInfo(player.graph, player.filePlayerNode, nil, &player.filePlayerAU)
AUGraphNodeInfo(player.graph, rioNode, nil, &player.rioAU)
AUGraphConnectNodeInput(player.graph, player.filePlayerNode, 0, outputNode, 0)
var callbackStruct = AURenderCallbackStruct(inputProc: InputRenderProc, inputProcRefCon: &player)
CheckError(AudioUnitSetProperty(player.rioAU,
kAudioUnitProperty_SetRenderCallback,
kAudioUnitScope_Output,
0,
&callbackStruct,
UInt32(sizeof(callbackStruct.dynamicType))),
operation: "Couldn't set RIO render callback")
AUGraphInitialize(player.graph)
And the render callback (doesn't get any data, doesn't give any errors):
let InputRenderProc: AURenderCallback = {(inRefCon, ioActionFlags, inTimeStamp, inBusNumber, inNumberFrames, ioData) -> OSStatus in
let player = UnsafeMutablePointer<StatePlayer>(inRefCon).memory
var bus1: UInt32 = 1
CheckError(AudioUnitRender(player.filePlayerAU, ioActionFlags, inTimeStamp, bus1, inNumberFrames, ioData),
operation: "Couldn't render from filePlayer Audio Unit")
return noErr
}