Re: Streaming audio to built-in audio device
Re: Streaming audio to built-in audio device
- Subject: Re: Streaming audio to built-in audio device
- From: Kurt Revis <email@hidden>
- Date: Mon, 7 May 2007 11:08:02 -0700
(resending, my original message was apparently too large...)
On May 6, 2007, at 5:58 PM, B. Mitchell Loebel wrote:
Question .. how do I instantiate the DefaultOutputUnit without
having to become a Component Manager expert ;-).
The code is right there in TN2097: "Listing 1: Constructing a
DefaultOutputAudioUnit".
TN2097 described how I should bind a renderCallback method into the
AU ... good. I see where the Audio Unit is the 'consumer' of my
data ... my app is the 'producer'. Having told the Audio Unit the
size and shape of my frames (my app will load a buffer with a frame
for the Audio Unit to 'pull'), I'd like to pass a pointer to the AU
when it needs more data to drive its D/A and speakers. I saw
somewhere that the renderCallback is supposed to return a
ComponentResult, but I can't find out what that looks like ...
question. I do know what my renderCallback function needs
do to create the pointer to my buffer ... my app does that coding.
Did you take a look at the code here?
/Developer/Examples/CoreAudio/SimpleSDK/DefaultOutputUnit
(Yes, I know the extensions on the files are .cpp, but it really is
practically plain C code. In fact I'll send you a slightly modified
version that is plain old C.)
Your render callback would look just like the MyRenderer() function
in main.cpp:
OSStatus MyRenderer(void *inRefCon,
AudioUnitRenderActionFlags *ioActionFlags,
const AudioTimeStamp *inTimeStamp,
UInt32 inBusNumber,
UInt32 inNumberFrames,
AudioBufferList *ioData)
This returns an OSStatus, not a ComponentResult. Just do whatever
you need to do to fill in the data in the AudioBufferList, and return
noErr (0).
Finally, I need to know how to start and stop the Audio Unit engine.
Again, TN2097 says: "...the AudioUnit must be started by calling
AudioOutputUnitStart. " The sample code above shows exactly how to do
that.
I think most of the questions I've raised would be answered if I
could find a list of functions associated with the
DefaultOutputUnit ... in C. Are you able to point me there please?
The headers are at:
/System/Library/Frameworks/AudioUnit.framework/Headers
and there's lots of documentation here:
http://developer.apple.com/documentation/MusicAudio/Reference/
CoreAudio/audio_units/chapter_5_section_1.html
This may not be as complete as you like, though. For instance, I
can't find a simple description of what AudioOutputUnitStart() does,
anywhere. developer.apple.com should be the definitive reference,
but all it returns is sample code and a couple of technotes:
http://developer.apple.com/cgi-bin/search.pl?
q=AudioOutputUnitStart&num=10&site=default_collection
So, when in doubt, look in the headers and search the sample code and
archives of this mailing list.
--
Kurt Revis
email@hidden
_______________________________________________
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