• 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 callback functions
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RemoteIO callback functions


  • Subject: RemoteIO callback functions
  • From: Brian Gerstle <email@hidden>
  • Date: Fri, 9 Jul 2010 12:28:06 +0200

Hello all,

This is a pretty specific question about how CoreAudio is implemented on the iPhone, and I would really appreciate any thoughts you all have on the subject, especially CoreAudio Team members ;-).

I'm programming audio apps for the iPhone, and I have a question about how input/output callback function(s) "should" be implemented.  Currently I'm have one RemoteIO audio unit with two "registered" callbacks: one which calls AudioUnitRender and gets HW input data, and another callback which writes to the output AudioBufferList.  Here are some code snippets:

OSStatus RenderInput(AudioUnitRenderActionFlags *apIOActionFlags,
									 const AudioTimeStamp *apInTimeStamp,
									 UInt32 aInBusNumber,
									 UInt32 aInNumberFrames)
{
	OSStatus result = noErr;
	// fill bufferlist w/ mic data
	result = AudioUnitRender(mRIOUnit,
							 apIOActionFlags,
							 apInTimeStamp,
							 aInBusNumber,
							 aInNumberFrames,
							 mpBufferList);  	// mpBufferList is an AudioBufferList that I've instantiated/initialized elsewhere
	return result;
}


OSStatus RenderOutput(AudioUnitRenderActionFlags *apIOActionFlags,
									   const AudioTimeStamp *apInTimeStamp,
									   UInt32 aInBusNumber,
									   UInt32 aInNumberFrames,
									   AudioBufferList *apIOData)
{
	OSStatus result = noErr;
	AudioSampleType *pOut;
	AudioSampleType *pIn;

	pOut = (AudioSampleType*) apIOData->mBuffers[0].mData;
	pIn = (AudioSampleType*) mpBufferList->mBuffers[0].mData;

	// copy samples from internal AudioBufferList to host's AudioBufferList
	for(UInt32 n = 0; n < aInNumberFrames; ++n)
	{
		pOut[n] = (AudioSampleType) pIn[n];
	}

	return result;
}

The input callback (RenderInput) is registered using kAudioOutputUnitProperty_SetInputCallback, and the output callback (RenderOutput) is registered using kAudioUnitProperty_SetRenderCallback.  I've also tried registering only one callback function on the output scope and calling AudioUnitRender manually.  Having said all that, here are a few questions:

-Is there a way to find out how/when these callbacks are invoked by the host (iPhone OS)?  In other words, how does the CoreAudio system schedule callback function invocations for a RemoteIO audio unit?  Does the AudioTimeStamp have anything to do with this?
-While we're at it, I've seen people talk about the callback functions being scheduled on a realtime thread, does anyone know where I can learn more about how multithreading is handled in the iPhone audio subsystem?

Thanks a lot in advance!!

Best regards,

Brian

 _______________________________________________
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 callback functions
      • From: Gregory Wieber <email@hidden>
  • Prev by Date: Re: What is the AudioStreamBasicDescription(asbd) for a wav file
  • Next by Date: Re: iPhone Library Access
  • Previous by thread: Calling glBindBufferOES fails within inputCallback(), but not elsewhere
  • Next by thread: Re: RemoteIO callback functions
  • Index(es):
    • Date
    • Thread