• 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
remoteIO unit not entering input callback in AUGraph
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

remoteIO unit not entering input callback in AUGraph


  • Subject: remoteIO unit not entering input callback in AUGraph
  • From: Alex Wiltschko <email@hidden>
  • Date: Thu, 28 Jan 2010 22:48:39 -0500

Hello all,
I've finished an app using Audio Units to acquire audio directly from the mic. I'm in the process of converting my code to use AUGraphs, so that I can stick in a mixer eventually.

My problem is, using an AUGraph, the render callback is never being entered.

I've stuck with Apple's example code closely, and I can't quite get it to work. The code posted below was modified only slightly to use a graph instead of a single unit, so I'm baffled as to what is not working.

Here's what I'm doing:



// Setting up the Audio Session...
	// Initialize and configure the audio session, and add an interuption listener
	AudioSessionInitialize(NULL, NULL, sessionInterruptionListener, self);

	UInt32 audioCategory = kAudioSessionCategory_PlayAndRecord;
	AudioSessionSetProperty(kAudioSessionProperty_AudioCategory, sizeof(audioCategory), &audioCategory);

	// Allow iPod audio to continue to play while the app is active.
	UInt32 flag = 1;
	AudioSessionSetProperty(kAudioSessionProperty_OverrideCategoryMixWithOthers, sizeof(flag), &flag);

	// Add a property listener to listen to changes to the session
	AudioSessionAddPropertyListener(kAudioSessionProperty_AudioRouteChange, sessionPropertyListener, self);

	Float32 preferredBufferSize = 0.00125;
	AudioSessionSetProperty(kAudioSessionProperty_PreferredHardwareIOBufferDuration, sizeof(preferredBufferSize), &preferredBufferSize);

	//set the audio session active
	AudioSessionSetActive(YES);

	OSStatus err;

// Now start setting up the graph & nodes
	//create the graph & its only node, which will be of type remoteIO
	NewAUGraph(&graph);
	AUNode ioNode;

	// First describe the node, graphs are made up of nodes connected together, in this graph there is only one node.
	// the descriptions for the components
	AudioComponentDescription outputDescription;
	outputDescription.componentFlags = 0;
	outputDescription.componentFlagsMask = 0;
	outputDescription.componentType = kAudioUnitType_Output;
	outputDescription.componentSubType = kAudioUnitSubType_RemoteIO;
	outputDescription.componentManufacturer = kAudioUnitManufacturer_Apple;

	// Create the remoteIO node, and open the graph
	err = AUGraphAddNode(graph, &outputDescription, &ioNode);
	NSAssert(err == noErr, @"Failed to add the remoteIO node");

	err = AUGraphOpen (graph);
	NSAssert(err == noErr, @"Opening the audio graph failed");

	// Grab an instance of the remoteIO unit from the graph
	AudioUnit ioUnit;
	err = AUGraphNodeInfo(graph, ioNode, NULL, &ioUnit);
	NSAssert(err == noErr, @"NOOO! (couldn't get the node info)");

	// Set the audio format on the audio unit instance
	AudioStreamBasicDescription audioFormat;
	memset(&audioFormat, 0, sizeof(audioFormat));

	// Let's talk formats for just a sec
	audioFormat.mSampleRate		= 44100.0f;
	audioFormat.mFormatID			= kAudioFormatLinearPCM;
	audioFormat.mFormatFlags		= kAudioFormatFlagsCanonical;
	audioFormat.mFramesPerPacket	= 1;
	audioFormat.mChannelsPerFrame	= 1;
	audioFormat.mBitsPerChannel	= 16;
	audioFormat.mBytesPerPacket	= 2;
	audioFormat.mBytesPerFrame		= 2;

	// set the format on the bus coming into the app ...
	err = AudioUnitSetProperty(ioUnit,
							   kAudioUnitProperty_StreamFormat,
							   kAudioUnitScope_Output,
							   kInputBus,
							   &audioFormat,
							   sizeof(audioFormat));
	NSAssert(err == noErr, @"Error setting Output Scope for Bus 1 (from microphone to app)");

	// ... and on the bus leaving the app for the mic
	err = AudioUnitSetProperty(ioUnit,
							   kAudioUnitProperty_StreamFormat,
							   kAudioUnitScope_Input,
							   kOutputBus,
							   &audioFormat,
							   sizeof(audioFormat));
	NSAssert(err == noErr, @"Error setting Input Scope for Bus 0 (from app to mic)");





	// Enable IO from the mic to the app...
	UInt32 one = 1;
	err = AudioUnitSetProperty(ioUnit,
							   kAudioOutputUnitProperty_EnableIO,
							   kAudioUnitScope_Input,
							   kInputBus, // BUS 1
							   &one,
							   sizeof(one));
	NSAssert(err == noErr, @"Could not enable the Input Scope of Bus 1");

	// ... and from the app back out to the mic
	err = AudioUnitSetProperty(ioUnit,
							   kAudioOutputUnitProperty_EnableIO,
							   kAudioUnitScope_Output,
							   kOutputBus, // BUS 0
							   &one,
							   sizeof(one));
	NSAssert(err == noErr, @"Could not enable the Output Scope of Bus 0");


	// This is what doesn't seem to be working
	// ***********************************


	AURenderCallbackStruct playbackCallbackStruct;
	playbackCallbackStruct.inputProc = continuousDisplayOutputCallback;
	continuousCallbackData *cd = (continuousCallbackData *)malloc(sizeof(continuousCallbackData));
	cd->ssb = secondStageBuffer;
	cd->au = &outputAudioUnit;
	playbackCallbackStruct.inputProcRefCon = cd;




	// Register a callback with the AUNode
	err = AUGraphSetNodeInputCallback (graph,
									   ioNode,
									   kInputBus,
									   &playbackCallbackStruct);

	// continuousDisplayOutputCallback() is never entered! I have an NSLog; return; right at the beginning,
	// and the app sits silent after initialization, and no audio is acquired.
	// ***********************************


	// Now we get to start it all up!
	err = AUGraphInitialize(graph);
	NSAssert(err == noErr, @"Could not initialize audio graph");

	err = AUGraphStart(graph);
	NSAssert(err == noErr, @"Could not start audio graph");


 _______________________________________________
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

  • Follow-Ups:
    • Re: remoteIO unit not entering input callback in AUGraph
      • From: Doug Wyatt <email@hidden>
  • Prev by Date: Re: 64-bit auval crash - Custom Unit
  • Next by Date: Re: remoteIO unit not entering input callback in AUGraph
  • Previous by thread: Re: iPad UI possibility...
  • Next by thread: Re: remoteIO unit not entering input callback in AUGraph
  • Index(es):
    • Date
    • Thread