1
votes

I am basically trying to obtain the samples produced by an AUGraph using a GenericOutput Node and a call to AudioUnitRender. As a starting point for my program I used the MixerHost example by Apple and changed the outputNode as follows.

AudioComponentDescription iOUnitDescription;
iOUnitDescription.componentType          = kAudioUnitType_Output;
iOUnitDescription.componentSubType       = kAudioUnitSubType_GenericOutput;
iOUnitDescription.componentManufacturer  = kAudioUnitManufacturer_Apple;
iOUnitDescription.componentFlags         = 0;
iOUnitDescription.componentFlagsMask     = 0;

Later when I want to obtain my samples, I call

AudioUnitRenderActionFlags  ioActionFlags = kAudioOfflineUnitRenderAction_Render;
AudioTimeStamp        inTimeStamp = {0};

inTimeStamp.mHostTime = mach_absolute_time();
inTimeStamp.mFlags =   kAudioTimeStampSampleHostTimeValid;

result = AudioUnitRender (
                 ioUnit,
                 &ioActionFlags,
                 &inTimeStamp,
                 1,
                 1024,
                 ioData
                 );

which yields an

"-10877 / Invalid Element"

error. My assumption is, that the error comes from not setting the inTimeStamp.mSampleTime field correctly. To be honest, I have not found a way to find out the sample time other than AudioQueueDeviceGetCurrentTime, which I cannot use, since I do not use an AudioQueue. However changing the ioActionFlag to kAudioTimeStampHostTimeValid does not change the the error behaviour.

1

1 Answers

0
votes

The error pertaining to the element (AKA 'bus') refers to the 4th argument (1) to your AudioUnitRender call. The Generic Output unit only has one element/bus: 0 which has an input, output and global scope. If you pass 0 to the call instead of 1 for the element #, that error should disappear.