• 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: How to set buffer size for Audio Output Unit?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: How to set buffer size for Audio Output Unit?


  • Subject: RE: How to set buffer size for Audio Output Unit?
  • From: Roger Butler <email@hidden>
  • Date: Thu, 30 Aug 2001 10:52:45 +1000

Hi Christof,

I think I'm doing a very similar thing and revised my buffering situation
just yesterday.

I don't think you can change the size of the buffer the output AU expects.
If anyone knows otherwise then please correct me. What you can do is
implement a buffering scheme in your callback. Mine goes something like
this:

Declare a buffer of N frames

AudioUnitCallback(output AU wants a slice of M frames)
{
Look at your buffer and copy whatever's there to make M

While we still haven't delivered enough samples (to make M)
Generate a new block of N samples and copy to buffer
Deliver as many frames as desired (unless we run out of
processed frames)
End while
}

Another way is to maintain a buffer of 2*N and changes the loops above a
bit. But the buffer has to be circular. You'd do this on a DSP but not on a
general purpose processor I reckon.

Hope this helps,
Roger.

> -----Original Message-----
> From: Christof Faller [mailto:email@hidden]
> Sent: Wednesday, 29 August 2001 5:54 AM
> To: email@hidden
> Subject: How to set buffer size for Audio Output Unit?
>
>
> I am using the default audio output unit for implementing
> a real-time audio decoder. My decoder is frame based,
> that means, it decodes always N samples at once
> (e.g. 2048).
>
> I use an input callback function for the default output
> unit (kAudioUnitProperty_SetInputCallback).
> AudioUnitRenderActionFlags is zero. Am I allowed in this
> case to just override the buffer (ioData), by filling this struct
> with my desired buffer size and setting the data pointer to
> my data?
>
> I did not get it to work yet.
>
> This is my question again:
>
> OSStatus AudioUnitCallback(void *inRefCon, AudioUnitRenderActionFlags
> inActionFlags, const AudioTimeStamp *inTimeStamp, UInt32 inBusNumber,
> AudioBuffer *ioData)
> {
> BCC_vars* bcc_vars = inRefCon; // get access to data
> BCC_params* bcc_params = bcc_vars->bcc_params;
>
> int framesize = bcc_params->framesize;
> int i;
> float *fbuf;
>
> bcc_vars->getsamples(bcc_vars);
>
> ioData->mDataByteSize = framesize * 2 * sizeof(float);
> ioData->mNumberChannels = 2;
> ioData->mData = (float*) bcc_vars->rbuf;
>
> etc.
> }
>
> ======>
> I am allowed to override the buffer like this?
>
> Thanks for any comments!
> Chris
> _______________________________________________
> coreaudio-api mailing list
> email@hidden
> http://www.lists.apple.com/mailman/listinfo/coreaudio-api


  • Follow-Ups:
    • AudioOutputUnit and its AudioDevice
      • From: Christof Faller <email@hidden>
    • Re: How to set buffer size for Audio Output Unit?
      • From: Christof Faller <email@hidden>
  • Prev by Date: AudioUnit frame sizes
  • Next by Date: Re: How to set buffer size for Audio Output Unit?
  • Previous by thread: How to set buffer size for Audio Output Unit?
  • Next by thread: Re: How to set buffer size for Audio Output Unit?
  • Index(es):
    • Date
    • Thread