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.