Re: RemoteIO callback functions
Re: RemoteIO callback functions
- Subject: Re: RemoteIO callback functions
- From: Gregory Wieber <email@hidden>
- Date: Fri, 9 Jul 2010 09:15:27 -0700
Michael Tyson and Aaron Mulhulhand have both written great introductions to setting up remote io, I would start there.
Sent from my iPad
On Jul 9, 2010, at 3:28 AM, Brian Gerstle <email@hidden> wrote:
> 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
_______________________________________________
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