Re: PlayFile
Re: PlayFile
- Subject: Re: PlayFile
- From: Michael Hanna <email@hidden>
- Date: Tue, 13 Dec 2005 08:40:51 -0800
Well, thanks. I realize now that Bill was saying this to me all
along, but I simply didn't clue in. Sorry Bill.
Michael
On 12-Dec-05, at 11:36 PM, Andrew Pouliot wrote:
On Dec 12, 2005, at 11:11 PM, Michael Hanna wrote:
-(void)doPlayFile
{
…
// start playing
XThrowIfError (AUGraphStart (theGraph), "AUGraphStart");
This is where you should break off the method. The method must end
now so that audio processing can continue in the background without
blocking the run loop.
Remove the usleep code:
// sleep until the file is finished
usleep ((int)fileDuration * 1000 * 1000);
If you want to kill your AUGraph at the end of playback, then set
up a timer to fire with (I presume) fileDuration seconds in the
future that triggers a method that does the rest of the code
(cleanup operation). The creation of the timer would go at the end
of doPlayFile
You could also do the cleanup when the controller is deallocated.
Or, you could make a stop button that called it.
// lets clean up
XThrowIfError (AUGraphStop (theGraph), "AUGraphStop");
XThrowIfError (AUGraphUninitialize (theGraph),
"AUGraphUninitialize");
XThrowIfError (AudioFileClose (audioFile), "AudioFileClose");
XThrowIfError (AUGraphClose (theGraph), "AUGraphClose");
// return 0;
}
I haven't scrutinized the audio code itself, but this should make
it work if the code was valid before.
I hope that helps!
—Andrew Pouliot
_______________________________________________
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