开发者

Got error from AudioUnitRender() function

I want to implement the I/O with a Render Callback Function Pattern in the "Audio Unit Hosting Guide for iOS" document. I'm not sure how to implement the render callback function.

My parts of codes are listed below:

- (void) configureAndInitializeAudioProcessingGraph {
...
NSLog (@"- Attach the input render callback and context to the input bus");

AURenderCallbackStruct inputCallbackStruct;
inputCallbackStruct.inputProc        = &inputRenderCallback;
inputCallbackStruct.inputProcRefCon  = NULL;    //&soundData;                   

result = AUGraphSetNodeInputCallback (
                                     开发者_Go百科  processingGraph, 
                                       ioNode, 
                                       0,          //output element of I/O unit     
                                       &inputCallbackStruct
                                       );
...
}


static OSStatus inputRenderCallback (
void                        *inRefCon,      
AudioUnitRenderActionFlags  *ioActionFlags,
const AudioTimeStamp        *inTimeStamp,
UInt32                      inBusNumber,   
UInt32                      inNumberFrames,
AudioBufferList             *ioData 
) 
{

DCIDBAudio *audio = (DCIDBAudio *)inRefCon;

OSStatus err = AudioUnitRender (
            audio.ioUnit, 
            ioActionFlags, 
            inTimeStamp, 
            1,            input element od I/O unit
            inNumberFrames, 
            ioData
            );

if (err)
{
    NSLog(@"AudioUnitRender() failed.");
    return err;
}

return noErr;

}

I always get the error "AudioUnitRender() failed." I just want to use AudioUnitRender() to get data from the output of the 1 element of the io unit and then put the data into the ioData buffer so that they cab be used by the 0 element of the io unit.

Could anybody point out what's wrong in my above codes? should I initialize the parameters: inNumberFrames and ioData first?

Any comments and instructions will be highly appreciated.

Thanks, Finspoo


I don't have the answer because i'm issuing kind of same problems but you could digg what's done in the mixerhost apple demo app


It'd help to know the OSStatus err code to try to determine what step you missed. Also, you should post all code relevant to initializing audio.ioUnit.

Make sure you've enabled IO on the input bus of your unit, such as:

UInt32 enableInput = 1;
AudioUnitSetProperty( ioUnit, kAudioOutputUnitProperty_EnableIO, kAudioUnitScope_Input, AudioUnitBus::Input, &enableInput, sizeof(enableInput) );
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜