Re: AU Format Negotiation
Re: AU Format Negotiation
- Subject: Re: AU Format Negotiation
- From: William Stewart <email@hidden>
- Date: Wed, 10 Dec 2003 12:22:14 -0800
On 10/12/2003, at 8:40 AM, Patrick Gostovic wrote:
Hi.
I've made a bunch of AudioUnits that stream MIDIPacketList's to one
another. Everything works great as long as I don't try and mess with
stream formats -- that is, I am not explicitly setting the stream
format to "kAudioFormatMIDIStream", just leaving them as default. How
does one set the stream format for an AU? My presumably naive approach
was to plop this code into my AU's constructor...
AudioStreamBasicDescription format = GetOutput(0)->GetStreamFormat();
format.mFormatID = kAudioFormatMIDIStream;
GetOutput(0)->SetStreamFormat(format);
First of all - you should *never* and I mean *never* set the stream
format of either an input or an output from within an Audio Unit. And I
do mean *never*...
The format for a scope/element pair is set externally by the client,
and the format as such establishes a shared understanding between say
an output element from a source AU and an input element on a
destination AU.
When a connection is made by the client, the format from the source
unit is propagated to the input of the destination. Part of the
semantic of making this connection is the process of ensuring that the
formats are the same before the connection is considered successful.
You can look through the implementation in AUBase roughly the steps
are:
(a) Are the formats the same on each side of the connection?
Yes - you are done
No -
(b) Is the proposed new format from the source output element a format
you (the AU that is the destination) can accept?
No - return an error (connection is not made)
Yes
(c) Is the format writable at this stage?
No - return an error (connection is not made)
Yes
(d) Change the format on the input to match the format from the
source AU's output
Fails - return an error (connection is not made)
Succeeded - you are done and the connection is established.
Once the connection is established, when the destination AU is asked to
render it will Pull on its inputs.
If the connection returns an error, then one of the above steps is
failing in the destination AU and you'll need to debug why. It should
be fairly easy - just put breakpoints in the AU's SetProperty for the
connection propertyID and step through this
Bill
However, when try to make connections between AU's where I have set the
stream format as above, I get a kAudioUnitErr_FormatNotSupported error.
I would really appreciate advice or links to sample code, etc.
These midi AU's that I'm making are actually for use in a AU host app
that I'm making, so my next question is what is the correct way to
negotiate stream formats when making a connection? My app is using
AUGraph's. Is format negotiation somehow automatically handled? Is it
just a matter of getting the kAudioUnitProperty_StreamFormat property
from the source element and setting it on the destination element?
Currently, I am doing nothing, just making and breaking connections.
It seems to work fine, but I'm sure I should be handling this
explicitly.
Thanks a bunch.
Patrick
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.
--
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
________________________________________________________________________
__
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.