Re: using non-default output units
Re: using non-default output units
- Subject: Re: using non-default output units
- From: Bill Stewart <email@hidden>
- Date: Mon, 21 Oct 2002 15:58:53 -0700
Kurt
We will maintain the current V1 units, but no further development is being
done on them...
Funny - I've just finished rewriting this file to use V2:)
We'll deprecate the usage of the OpenDefaultAudioOutput because:
(1)It returns a V1 unit,
(2) We can't have it return a V2 unit and know we don't break anyone
(3) We're deprecating V1
(4) Its only a few lines of code anyway...
Bill
on 20/10/02 12:22 AM, Kurt Bigler wrote:
>
With the help of some off-list support from Kurt Revis, and some trial and
>
error (and yes, the documentation helped), I found answers to my questions.
>
>
I was able to modify an app based on the output unit sample code, namely
>
>
Developer/Examples/CoreAudio/Services/DefaultOutputUnit/UsingDefaultNoAC.cpp
>
>
to allow the app to select the output device instead of using the default
>
output. It turned out to be _almost_ as easy as adding this code after the
>
call to AudioUnitInitialize...
>
>
AudioDeviceID deviceId = 0x1B/*the device ID that I wanted*/;
>
verify_noerr(err = AudioUnitSetProperty(
>
theOutputUnit,
>
kAudioOutputUnitProperty_CurrentDevice,
>
kAudioUnitScope_Global,
>
0,
>
&deviceId,
>
sizeof(deviceId)));
>
>
...which permitted the output device for the AU to be set to something other
>
than the current default device. Unfortunately this did not prevent the
>
default AU from switching away from the app's preferred device whenever the
>
user switches the default output (e.g. using the system sound preferences
>
panel).
>
>
So it was necessary to use FindNextComponent and OpenAComponent to open the
>
V1 HALOutput AU instead of the default output unit by replacing the
>
OpenDefaultAudioOutput(&theOutputUnit) call with:
>
>
ComponentDescription searchDesc;
>
searchDesc.componentType = kAudioUnitComponentType;
>
searchDesc.componentSubType = kAudioUnitSubType_Output;
>
searchDesc.componentManufacturer = kAudioUnitID_HALOutput;
>
searchDesc.componentFlags = 0;
>
searchDesc.componentFlagsMask = 0;
>
Component theAUComponent = FindNextComponent (NULL, &searchDesc);
>
if (theAUComponent != NULL)
>
err = OpenAComponent (theAUComponent, &theOutputUnit);
>
>
Result: the modified sample app can now take charge of switching devices by
>
using the AudioUnitSetProperty above. The HALOutput AU appears to default
>
_initially_ to the default output device if you don't set the
>
kAudioOutputUnitProperty_CurrentDevice property, but does not track
>
subsequent user changes to the default output.
>
>
This glosses over the issue of how to usefully determine the desired
>
deviceId at run-time. I used the displayhaldeviceinfo sample code to
>
discover how to get the list of device id's and the name for each id, from
>
which a menu could be built, for example.
>
>
>
Now there is the question of the choice of V1 rather than the V2 audio unit.
>
It is curious that OpenDefaultAudioOutput opens the V1 default output unit,
>
although this is certainly helpful for compatibility, because as it turns
>
out, the sample code AS IS would not work with the V2 unit, since that code
>
uses the kAudioUnitProperty_SetInputCallback mechanism to set the callback
>
routine (MyRenderer) that computes the audio _input_ to the output AU, and
>
that mechanism has been replaced by a different callback mechanism in V2
>
units.
>
>
The question remains: would it be a good idea to change over to the V2
>
scheme? Does the V1 approach perform just as well, and can we expect it to
>
stay around? I did not look into the coding changes that would have been
>
necessary to switch to V2 but it appeared to be a slightly more complex
>
callback interface. I believe (correct me if I am wrong) that the standard
>
format conversions would permit the V2-based renderer to continue to
>
generated audio in interleaved format (if that were more convenient), but
>
are there other implications, and does Apple plan to change this sample code
>
to use the V2 scheme?
>
>
>
Thanks,
>
Kurt Bigler
>
>
>
>
on 10/19/02 12:40 AM, Kurt Bigler <email@hidden> wrote:
>
>
> I can't seem to find any information in the documentation or the archives
>
> about how to use audio units to output to devices other than the default
>
> device. In other words I want the application to be able to choose the
>
> output device independent of the current default device.
>
>
>
> I expected to be able to find an apple audio unit component that I could
>
> instantiate and some how tell it to associate itself with a particular
>
> output device, after which I could hopefully use it just like I would use
>
> the default audio unit.
>
>
>
> Thanks in advance for any info.
>
>
>
> -Kurt Bigler
>
_______________________________________________
>
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.