• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How do I release multiple instance of AVAudioPlayer
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How do I release multiple instance of AVAudioPlayer


  • Subject: Re: How do I release multiple instance of AVAudioPlayer
  • From: uɐıʇəqɐz pnoqɥɒɯ <email@hidden>
  • Date: Fri, 30 Jul 2010 09:49:02 -0700

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
References: 
 >How do I release multiple instance of AVAudioPlayer (From: Sanoj Nambi <email@hidden>)

  • Prev by Date: Re: multichannel mixer render callback problems
  • Next by Date: Re: multichannel mixer render callback problems
  • Previous by thread: Re: How do I release multiple instance of AVAudioPlayer
  • Next by thread: Getting distorted sound from AU
  • Index(es):
    • Date
    • Thread