• 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 setting mData in render callback doesn't work, but memcpy does?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Why setting mData in render callback doesn't work, but memcpy does?


  • Subject: Re: Why setting mData in render callback doesn't work, but memcpy does?
  • From: Brian Willoughby <email@hidden>
  • Date: Wed, 14 Dec 2016 21:54:06 -0800

Yes, the caller expects that you put the audio data in the buffer that it has allocated. I assume that the buffer may be in use by several upstream functions in the graph, which means that changing the pointer would potentially cause lots of trouble in multiple places.

The code would be slower if the caller had to detect changed pointers and copy the data whenever the callee changed the pointer. Besides, I don't think that the API marks the whole structure as in/out, only the contents of the array are the output, not the pointers or other fields of the structure. For example, you can't change the number of buffers in the callback, either. That sort of change has to be handled while the AudioUnits are not initialized.

Keep in mind that CoreAudio has to be real time, and this means pre-allocated buffers and lots of other restrictions. Certain changes can't only happen when the AudioUnits are not active, which is why there is an "initialize" step and Start/Stop for AUGraph, etc.

Brian Willoughby
Sound Consulting


On Dec 14, 2016, at 10:39 AM, Baoshan Sheng <email@hidden> wrote:
In my audio output prototype, replace below line in the IOProc

memcpy(outOutputData->mBuffers[0].mData, pcm, outOutputData->mBuffers[0].mDataByteSize);

with

outOutputData->mBuffers[0].mData = pcm;

Will lead to digital silence. I have no idea why. The pcm buffer is globally alloced and never freed.

Does that means the caller of the IOProc expects the buffer be filled, rather than the pointer be replaced?

Any help would be appreciated.

 _______________________________________________
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 setting mData in render callback doesn't work, but memcpy does? (From: Baoshan Sheng <email@hidden>)

  • Prev by Date: Re: ExtAudioFileWrite: insz - invalid number of frames? (iOS)
  • Next by Date: Re: ExtAudioFileWrite: insz - invalid number of frames? (iOS)
  • Previous by thread: Why setting mData in render callback doesn't work, but memcpy does?
  • Next by thread: What should my iOS app do in applicationWillResignActive()?
  • Index(es):
    • Date
    • Thread