• 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: Why does this code crash in AUGraphInitialize?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Why does this code crash in AUGraphInitialize?


  • Subject: Re: Why does this code crash in AUGraphInitialize?
  • From: tahome izwah <email@hidden>
  • Date: Thu, 24 May 2012 07:24:21 +0200


Look closely at your code: you're setting kAudioUnitProperty_StreamFormat on the converterUnit twice, but never on the decoderUnit (copy & paste error)

--th

2012/5/15 Dave Camp <email@hidden>
Below is a bit of code (error checking removed for email) that attempts to setup an AUGraph like decoder -> converter -> output. When I call AUGraphInitialize at the end, I consistently crash in ACAppleIMA4Decoder::SetCurrentInputFormat. I can change the decoder to '.mp3' or other types and I crash in their implementations of ::SetCurrentInputFormat() or ::Initialize().

This seems like a relatively basic bit of code, but can't figure out why it crashes. I'm assuming the problem is in my code since it crashes with a variety of decoders.

What am I missing here?

Thanks,
Dave


OSStatus result = noErr;
AudioUnit outputUnit = 0;
AudioUnit converterUnit = 0;
AudioUnit decoderUnit = 0;

// Create a graph
result = NewAUGraph(&audioGraph);

// Add an output node
AudioComponentDescription outputNodeDesc = {kAudioUnitType_Output, kAudioUnitSubType_DefaultOutput, kAudioUnitManufacturer_Apple, 0, 0};
result = AUGraphAddNode(audioGraph, &outputNodeDesc, &outputNode);

AudioComponentDescription decoderNodeDesc = {kAudioDecoderComponentType, 'ima4', 'appl', 0, 0};
result = AUGraphAddNode(audioGraph, &decoderNodeDesc, &decoderNode);

// Add a converter to get things in the correct LPCM format
AudioComponentDescription converterNodeDesc = {kAudioUnitType_FormatConverter, kAudioUnitSubType_AUConverter, kAudioUnitManufacturer_Apple, 0, 0};
result = AUGraphAddNode(audioGraph, &converterNodeDesc, &converterNode);

// Open the graph
result = AUGraphOpen(audioGraph);

// Get the converter unit
result = AUGraphNodeInfo(audioGraph, converterNode, &converterNodeDesc, &converterUnit);

// Get the decoder unit
result = AUGraphNodeInfo(audioGraph, decoderNode, &decoderNodeDesc, &decoderUnit);

// Get the output unit
result = AUGraphNodeInfo(audioGraph, outputNode, &outputNodeDesc, &outputUnit);

AudioStreamBasicDescription outputFormat;
bzero(&outputFormat, sizeof(outputFormat));

outputFormat.mSampleRate = 44100.0;
outputFormat.mFormatID = kAudioFormatLinearPCM;
outputFormat.mFormatFlags = kAudioFormatFlagsNativeEndian | kLinearPCMFormatFlagIsSignedInteger | kLinearPCMFormatFlagIsPacked;

outputFormat.mChannelsPerFrame = 2;
outputFormat.mBitsPerChannel = 16;

outputFormat.mBytesPerPacket = outputFormat.mChannelsPerFrame * (outputFormat.mBitsPerChannel / 8);
outputFormat.mFramesPerPacket = 1;
outputFormat.mBytesPerFrame = outputFormat.mBytesPerPacket;

// Configure the decoder unit output
result = AudioUnitSetProperty(converterUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Output, 0, &outputFormat, sizeof(outputFormat));

// Configure the converter unit output
result = AudioUnitSetProperty(converterUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Output, 0, &outputFormat, sizeof(outputFormat));

// Configure the output unit's input format
result = AudioUnitSetProperty(outputUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, 0, &outputFormat, sizeof(outputFormat));

// Connect the decoder node as the input of the converter node
result = AUGraphConnectNodeInput (audioGraph, decoderNode, 0, converterNode, 0);

// Connect the converter node as the input of the output node
result = AUGraphConnectNodeInput (audioGraph, converterNode, 0, outputNode, 0);

// Initialize the graph
result = AUGraphInitialize(audioGraph);

… rest of code omitted since we don't get that far


 _______________________________________________
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: 
 >Why does this code crash in AUGraphInitialize? (From: Dave Camp <email@hidden>)

  • Prev by Date: Re: Using SoundTouch in IOS project
  • Next by Date: Re: Using SoundTouch in IOS project
  • Previous by thread: Why does this code crash in AUGraphInitialize?
  • Next by thread: HighLevel Overview Offline Rendering
  • Index(es):
    • Date
    • Thread