Re: Callback [was PlayFile]
Re: Callback [was PlayFile]
- Subject: Re: Callback [was PlayFile]
- From: William Stewart <email@hidden>
- Date: Fri, 16 Dec 2005 11:46:14 -0800
You can't feed an audio unit MP3 data directly.
We've numerous examples of how to play a file, I think the simplest
one is PlayFile (in the Simple examples in the latest SDK). It shows
you how to use the AUFilePlayer.
If you want more control than this, you can use the ExtAudioFile API
(see the ConvertFile) - the difference being that you can't read
files from the I/O thread (and the ExtAF API also does the conversion
from say MP3 to linear PCM which is what you need to give an AU) - so
you have to do your file reads in an ancilliary thread (This is what
the AUFilePlayer does for you)
I really think the AUFilePlayer is the best course to take - you can
schedule small slices for it to play (rather than just one big
slice), so you can still exercise some fine degree of control over
its playback behaviour.
Bill
On 15/12/2005, at 10:10 PM, Michael Hanna wrote:
Thanks Bill, I put together this at the end of MakeSimpleGraph();
[...............]
OSStatus err;
// setup the render callback
AURenderCallbackStruct input;
input.inputProc = MyRendererCallback;
input.inputProcRefCon = NULL;
err = AudioUnitSetProperty (anAU,
kAudioUnitProperty_SetRenderCallback,
kAudioUnitScope_Input,
0,
&input,
sizeof(input));
XThrowIfError (err, "kAudioUnitProperty_SetRenderCallback");
}
currently MyRendererCallback() does nothing:
OSStatus MyRendererCallback(void *inRefCon,
AudioUnitRenderActionFlags *ioActionFlags,
const AudioTimeStamp *inTimeStamp,
UInt32 inBusNumber,
UInt32 inNumberFrames,
AudioBufferList *ioData)
{
return noErr;
}
but I get a CAException from this setup when MakeSimpleGraph gets
called:
playing file: /Users/tao/Music/iTunes/iTunes Music/Lamb/What Sound/
07 Small.mp3
format: AudioStreamBasicDescription: 2 ch, 44100 Hz,
'.mp3' (0x00000000) 0 bits/channel, 0 bytes/packet, 1152 frames/
packet, 0 bytes/frame
terminate called after throwing an instance of 'CAXException'
CocoaPlayFile has exited due to signal 6 (SIGABRT).
pretty certain it's my new code. Any suggestions on this?
Michael
On 15-Dec-05, at 10:48 AM, William Stewart wrote:
Have a look at the Default Output code in the SDK - it shows you
have to establish the callback and feed data to it once the output
unit has been started. There are also some explanations in:
/Developer/Examples/CoreAudio/Documentation/AudioUnits/
Bill
On 14/12/2005, at 10:01 PM, Michael Hanna wrote:
Hi all,
I'm assuming this call is done in a callback. How do I setup and
create this callback? Pardon my naive questions.
--
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