Render callback on remote audio device does not receive audio tapes

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)

 // Add file player node
 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)

 // Add output node
 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)


 // The callback is configures as
 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

    // Just obtain samples from buffer
     var bus1: UInt32 = 1
    CheckError(AudioUnitRender(player.filePlayerAU, ioActionFlags, inTimeStamp, bus1, inNumberFrames, ioData),
        operation: "Couldn't render from filePlayer Audio Unit")

    return noErr
 }
+4
source share

Source: https://habr.com/ru/post/1622924/


All Articles