It looks to me that you are loading a new instance of playBeat every time this code gets run without ever releasing the AVAudioPlayer object (playBeat). Not knowing the rest of your code, I can't know for sue, but it seems to me likely that you are leaking these objects. My experience with AVAudioPlayer is that if you create enough instances of AVAudioPlayer objects, without releasing, some of the objects stop working - i.e. they won't play and they'll act odd.
Also,
[playBeat prepareToPlay]; [playBeat play];
-play will call -prepareToPlay, so you don't have to call them in succession like that. Usually, you will allocate your AVAudioPlayer object and call -prepareToPlay on it at an earlier stage, so that later calls to -play will complete with less latency.
-mz
On Jul 25, 2010, at 9:38 AM, Sanoj Nambi wrote: Hey all, I have a set of buttons which on pressed plays the sound file.I have used AVAudioPlayer to play these sound files.All the buttons plays fine for sometime after which AVAudioPlayer objects are somehow released.
I guess AVAudioPlayer internally maintains a pool and flushes it if a certain number of objects are created. I there a way to handle this issue.
here is the code snippet if(!AppDelegate.recordFlag) //if it is not in recording mode
{ playBeat = [[[AVAudioPlayer alloc] initWithContentsOfURL:filePath error:&error]retain]; [playBeat prepareToPlay]; [playBeat play]; // if(playBeat.playing==FALSE)
// { // NSLog(@"play release"); // [playBeat release]; // } }
I have not released the playBeat object anywhere.
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
|