• 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: useful return values for Audio Unit callbacks?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: useful return values for Audio Unit callbacks?


  • Subject: Re: useful return values for Audio Unit callbacks?
  • From: William Stewart <email@hidden>
  • Date: Fri, 17 Mar 2006 11:20:38 -0800


On 16/03/2006, at 6:06 PM, Rick Sustek wrote:

Hi gang,

The API docs have scant mention of return values, for the Audio Unit callback functions.

I am particularly interested in the _SetRenderCallback. This is usually shown as needing to return an OSStatus. We would normally return a 'noErr' to indicate everything is puppies and bunnies. However, I have seen in some Apple example code, a '-1' being returned, to indicate foul creatures instead. The comments in this sample code says this will cause "silence". (see ComplexPlayThru example)

I would not say that this is a good illustration of this - we should probably go through this code and take a look at this.


All that a non-zero result code means is that some error occurred in your callback function, so the data should NOT be processed - ie. the input data is invalid.

Indeed, in my testing, a return value of '-1' produces silence, when used with the Apple Default Output Audio Unit.

However, other narrative in the docs suggest that to produce silence, one should zero-fill the provided buffer, and set the _OutputIsSilence flag in the ActionFlags, and (presumably) return with a 'noErr'.

Yes definitely.


Observe that simply returning a '-1' is much more efficient than taking the time to zero-fill a buffer, especially when long periods of silence are to be emitted, like when the application has nothing to do, but hasn't stopped the Audio Unit chain.

The difference is simple. If you return an error, the buffer will not be processed. If you return silence, the buffer can be processed. Therefore, returning an error can lead to distortions and discontinuities. I would strongly discourage you from doing this and we'll fix this example code.


Thanks

Bill


Comments or clarifications greatly appreciated!

Thanks,
Have fun,
-Rick



_______________________________________________
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

--
mailto:email@hidden
tel: +1 408 974 4056
________________________________________________________________________ __
"Much human ingenuity has gone into finding the ultimate Before.
The current state of knowledge can be summarized thus:
In the beginning, there was nothing, which exploded" - Terry Pratchett
________________________________________________________________________ __


_______________________________________________
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: 
 >useful return values for Audio Unit callbacks? (From: Rick Sustek <email@hidden>)

  • Prev by Date: Re: The EXS and the VM ; question from a beta tester user
  • Next by Date: Re: When has playback finished?
  • Previous by thread: useful return values for Audio Unit callbacks?
  • Next by thread: AUParameterListener notifying for events before listener is created?
  • Index(es):
    • Date
    • Thread