Error setting callback function
Error setting callback function
- Subject: Error setting callback function
- From: alejandro <email@hidden>
- Date: Tue, 11 Mar 2008 21:00:58 +0100
Art,
Here you have the code. Return value is -10879 in both calls
AudioUnitSetProperty and AudioUnitSetPropertyInfo with
kAudioUnitProperty_SetRenderCallback.
#include <AudioUnit/AudioUnit.h>
#include <AudioUnit/AudioUnitProperties.h>
#include <CoreFoundation/CoreFoundation.h>
OSStatus callbackFunction( void *inRefCon, AudioUnitRenderActionFlags
*ioActionFlags, const AudioTimeStamp *inTimeStamp,
UInt32 chnum, UInt32 inNumberFrames,
AudioBufferList *ioData)
{
return noErr;
}
int main()
{
ComponentDescription desc;
desc.componentFlags = 0;
desc.componentFlagsMask = 0;
desc.componentManufacturer = 0;
desc.componentType = kAudioUnitComponentType;
desc.componentSubType = kAudioUnitSubType_Effect;
Component *component = FindNextComponent( NULL, &desc);
OSStatus err = noErr;
AudioUnit audioUnit;
err = OpenAComponent( *component, &audioUnit);
assert( err == noErr);
assert( audioUnit);
// set stream I/O description *********
AudioStreamBasicDescription streamDescription;
streamDescription.mSampleRate = 48000.0;
streamDescription.mFormatID = kAudioFormatLinearPCM; // a four-char
code indicating stream type
streamDescription.mFormatFlags = kLinearPCMFormatFlagIsFloat |
kAudioFormatFlagIsPacked; // flags specific to the stream type
streamDescription.mBytesPerPacket = 8; // bytes per packet of audio
data
streamDescription.mFramesPerPacket = 1; // frames per packet of
audio data
streamDescription.mBytesPerFrame = 8; // bytes per frame of audio data
streamDescription.mChannelsPerFrame = 2; // number of channels per
frame
streamDescription.mBitsPerChannel = 32; // bit depth
streamDescription.mReserved = 0; // padding
// must be done before AudioUnitInitialize(), otherwise it crashes!
err = AudioUnitSetProperty( audioUnit,
kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, 0,
&streamDescription, sizeof( AudioStreamBasicDescription));
assert( err == noErr);
err = AudioUnitSetProperty( audioUnit,
kAudioUnitProperty_StreamFormat, kAudioUnitScope_Output, 0,
&streamDescription, sizeof( AudioStreamBasicDescription));
assert( err == noErr);
// ******************************************
Boolean isWritable = 0;
UInt32 dataSize = 0;
// Find out if the unit has any channel restrictions
err = AudioUnitGetPropertyInfo( audioUnit,
kAudioUnitProperty_SetRenderCallback,
kAudioUnitScope_Input, 0,
&dataSize, &isWritable);
assert( err == noErr); // assertion FAILS!! err == -10879
AURenderCallbackStruct callbackStruct;
bzero( &callbackStruct, sizeof( AURenderCallbackStruct));
callbackStruct.inputProc = callbackFunction;
callbackStruct.inputProcRefCon = NULL; // arguments
err = AudioUnitSetProperty( audioUnit,
kAudioUnitProperty_SetRenderCallback, kAudioUnitScope_Input, 0,
&callbackStruct, sizeof(
AURenderCallbackStruct));
if( err) cout << "ERROR in AudioUnitSetProperty()
kAudioUnitProperty_SetRenderCallback: " << (char *) err << endl;
assert( err == noErr); // assertion FAILS!! err == -10879
err = AudioUnitInitialize( audioUnit); // must initialize to obtain
extra parameters (ID 1000 and up)!
assert( err == noErr);
AudioUnitUninitialize( audioUnit); // must initialize to obtain
extra parameters!
CloseComponent( audioUnit);
}
--
Alejandro Palencia
Open Studio Networks
+34 667 440 770
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden