• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Error setting callback function
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Error setting callback function


  • Subject: Re: Error setting callback function
  • From: William Stewart <email@hidden>
  • Date: Tue, 11 Mar 2008 16:05:46 -0700

I think your format is wrong - you need to set the deinterleaved flag for the mFormatFlags (have a look at CAStreamBasicDescription.SetCanonical (numChannels, false)

On Mar 11, 2008, at 1:00 PM, alejandro wrote:

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

_______________________________________________ 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
References: 
 >Error setting callback function (From: alejandro <email@hidden>)

  • Prev by Date: Re: Processing overhead for unconnected nodes in AUGraph?
  • Next by Date: Re: Sample-accurate parameter automation? Possibe at all with AUs?
  • Previous by thread: Error setting callback function
  • Next by thread: Re: Error setting callback function
  • Index(es):
    • Date
    • Thread