Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 09-23-2010, 12:51 AM   #1 (permalink)
Registered Member
 
Join Date: Sep 2009
Location: india
Posts: 65
sharhelia is on a distinguished road
Default Leak Leak Leak ! in AudioToolbox

HI
i am making an app in which there are 30 images in a scroll view and as i scroll from one image to another a sound is being played on every image by calling a method playSound. the code is below . but when i run the code through performance tool it gives leak in audioToolbox, please help me with this AVAudio player.

Code:
-(void)playSound
{
	self.view.userInteractionEnabled=FALSE;
	NSLog(@"play sound called start");

	
	NSString *myExamplePath = [[NSBundle mainBundle] pathForResource:@"ting" ofType:@"mp3"];
	NSURL *fileURL = [[NSURL alloc] initFileURLWithPath:myExamplePath];
	self.soundFileURL = fileURL;
	[fileURL release];
	[[AVAudioSession sharedInstance] setDelegate: self];
	[[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryAmbient error: nil];
	// Registers the audio route change listener callback function
  //  AudioSessionAddPropertyListener (kAudioSessionProperty_AudioRouteChange,audioRouteChangeListenerCallback, self);
                                   
	
    // Activates the audio session.
	
    NSError *activationError = nil;
    [[AVAudioSession sharedInstance] setActive: YES error: &activationError];
	
    AVAudioPlayer *newPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL: soundFileURL error: nil];
	
	
	self.myExampleSound = newPlayer;
	[newPlayer release];
	[myExampleSound setDelegate:self];
	[myExampleSound play];
	
	repeatCount = [[noOfCharsArray objectAtIndex:curr_page]intValue] ;
	counter = 0;
	
	NSRunLoop *runloop = [NSRunLoop currentRunLoop];

	colorTimer = [[[NSTimer alloc] init]autorelease];
	colorTimer = [NSTimer timerWithTimeInterval:0.1 target:self selector:@selector(changeColor) userInfo:nil repeats:YES];
	[runloop addTimer:colorTimer forMode:NSRunLoopCommonModes];
	[runloop addTimer:colorTimer forMode:UITrackingRunLoopMode];
	
	NSLog(@"play sound called end");

		
}

-(void)changeColor
{
	NSLog(@"changeColor start");
 	if(counter <repeatCount)
	{
		   
		
		NSString *myString =  _name;
		NSMutableArray *characters = [[NSMutableArray alloc] initWithCapacity:[myString length]];
		for (int i=0; i < [myString length]; i++) {
			NSString *ichar  = [NSString stringWithFormat:@"%c_orange.png", [myString characterAtIndex:i]];
			[characters addObject:ichar];
		}
		
		UIImageView *Ab = [self.view viewWithTag:counter+1];
	    Ab.image = [UIImage imageNamed:[characters objectAtIndex:counter]];
		[characters release];
		counter ++;
	   }
	   else
	   {
		   [colorTimer invalidate];
		   NSLog(@"invalidate");
		   btn.enabled=TRUE;
		   self.view.userInteractionEnabled=TRUE;
		   [myExampleSound stop];
	
	   }
			
	NSLog(@"changeColor end");


}
myExampleSound is declared in .h

Thanks in advance & happy coding
sharhelia is offline   Reply With Quote
Reply

Bookmarks

Tags
audio, audio toolbox, avaudioplayer, leak, scroll view

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 347
11 members and 336 guests
2ndSegment, djohnson, Hamad, headkaze, markuschow, mistergreen2011, Objective Zero, pungs, revg, v1n2e7t
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,655
Threads: 94,116
Posts: 402,889
Top Poster: BrianSlick (7,990)
Welcome to our newest member, pungs
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 11:05 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0