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 07-20-2011, 05:01 PM   #1 (permalink)
Registered Member
 
Join Date: Nov 2010
Posts: 70
juanchofern is on a distinguished road
Thumbs up NSMutable Array of sounds plays perfectly until plays 240 sounds

Hello i have this problem:

I Create a NSMutable array of 90 sounds.
It plays perfectly, in the device and in the simulator.
But when i play the sounds in the third session i cannot hear the sounds.

Does anybody know why?

Here is the code.


NSMutableArray *sounds;

sounds = [NSMutableArray new];

for (int i=0; i<90;i++
[sounds addObject:[NSString stringWithFormat:@"Juancho%u",i+1]];

NSString *myFile = [sounds objectAtIndexnumber)];
NSString *pathStringAudio = [[NSBundle mainBundle] pathForResource:myFile ofType:@"aif"];
NSURL *pathURLAudio = [NSURL fileURLWithPathathStringAudio];
NSError *error;
audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURLathURLAudio error:&error];

if (audioPlayer == nil)
NSLog([error description]);
else
[audioPlayer play];
juanchofern is offline   Reply With Quote
Old 07-20-2011, 05:36 PM   #2 (permalink)
Reading the Documentation
 
baja_yu's Avatar
 
Join Date: Sep 2010
Location: 45.255019,19.844908
Posts: 5,414
baja_yu has a spectacular aura about
Default

Maybe you're running out of memory. 240 AVAudioPlayers at the same time is a bit much. Did you run Instruments on your app to check memory allocation?

Also, where and how is audioPlayer declared? I don't see you releasing the players anywhere. Nor the sounds array for that matter.
baja_yu is offline   Reply With Quote
Old 07-20-2011, 05:41 PM   #3 (permalink)
Just helping out.
 
Domele's Avatar
 
Join Date: Feb 2011
Posts: 2,565
Domele is on a distinguished road
Default

You should allocate without keeping a pointer and then sign up for notifications for when the sound is done playing and release there. Or autorelease but I think that might release before the sound is done playing.
__________________
If you are looking for a quality developer, I'm your man. Give me a PM if you are interested.

New app - See screenshots and details at www.globaclock.com.

If you want to thank me, click the link. Every click counts. If you want to do more, buy my app. A link is available on my website. Thanks.
Domele is offline   Reply With Quote
Old 07-20-2011, 06:46 PM   #4 (permalink)
Registered Member
 
Join Date: Nov 2010
Posts: 70
juanchofern is on a distinguished road
Default

Quote:
Originally Posted by baja_yu View Post
Maybe you're running out of memory. 240 AVAudioPlayers at the same time is a bit much. Did you run Instruments on your app to check memory allocation?

Also, where and how is audioPlayer declared? I don't see you releasing the players anywhere. Nor the sounds array for that matter.
I Have declared

AVAudioPlayer *audioPlayer;

in .h

and in .m

in (void) dealloc
[audioPlayer release];
juanchofern is offline   Reply With Quote
Old 07-20-2011, 06:59 PM   #5 (permalink)
Registered Member
 
Join Date: Nov 2010
Posts: 70
juanchofern is on a distinguished road
Default

Quote:
Originally Posted by Domele View Post
You should allocate without keeping a pointer and then sign up for notifications for when the sound is done playing and release there. Or autorelease but I think that might release before the sound is done playing.
Please could you show me how to do it?
juanchofern is offline   Reply With Quote
Old 07-20-2011, 09:02 PM   #6 (permalink)
Reading the Documentation
 
baja_yu's Avatar
 
Join Date: Sep 2010
Location: 45.255019,19.844908
Posts: 5,414
baja_yu has a spectacular aura about
Default

Quote:
Originally Posted by juanchofern View Post
I Have declared

AVAudioPlayer *audioPlayer;

in .h

and in .m

in (void) dealloc
[audioPlayer release];
You are overwriting the pointer in each iteration without ever releasing them. You're leaking memory all over the place. Still, 240 players is too much, what exactly are you trying to do?
baja_yu is offline   Reply With Quote
Old 07-21-2011, 08:26 AM   #7 (permalink)
Registered Member
 
Join Date: Nov 2010
Posts: 70
juanchofern is on a distinguished road
Thumbs up

Quote:
Originally Posted by baja_yu View Post
You are overwriting the pointer in each iteration without ever releasing them. You're leaking memory all over the place. Still, 240 players is too much, what exactly are you trying to do?
Hello, i supposed that i was leaking memory, but i donīt know how to release.

How must i do?

i am trying to do a iteration that plays sounds from nsmutable array, and after
when the iteration finalizes, i want to call the function again to play the sounds,
but the problem is that i release the player in the the dealloc.

Do you know how i must do?

Thank you very much for your help.
juanchofern is offline   Reply With Quote
Reply

Bookmarks

Tags
array, nsmutable array, nsmutble, play, sounds

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: 405
15 members and 390 guests
7twenty7, blasterbr, buggen, Clouds, dre, EvilElf, HemiMG, jeroenkeij, jimmyon122, jonathandeknudt, LEARN2MAKE, n00b, nyoe, pungs, UMAD
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,668
Threads: 94,121
Posts: 402,901
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jonathandeknudt
Powered by vBadvanced CMPS v3.1.0

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