Re: PlayFile
Re: PlayFile
- Subject: Re: PlayFile
- From: Andrew Pouliot <email@hidden>
- Date: Mon, 12 Dec 2005 23:36:39 -0800
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