SoundPool crashing with "could not create track"

All your problems with Audio, Video and Images.

SoundPool crashing with "could not create track"

Postby intermedi8 » Mon Aug 16, 2010 5:37 pm

Hey everyone,

im trying to play some audio samples at the same time with a little delay between them. For this im using soundpool. but when i start the playSound() function some times, after a while it crashes with this error:

08-16 18:33:06.208: ERROR/AudioTrack(7000): AudioFlinger could not create track, status: -12
08-16 18:33:06.208: ERROR/SoundPool(7000): Error creating AudioTrack

Sometimes i also get an additional out of memory error. Whats wrong?
Last edited by intermedi8 on Tue Aug 17, 2010 1:26 pm, edited 1 time in total.
intermedi8
Freshman
Freshman
 
Posts: 7
Joined: Fri Jul 16, 2010 8:19 am

Top

Re: SoundPool crashing with "could not create track"

Postby blundell » Tue Aug 17, 2010 8:43 am

http://developer.android.com/reference/ ... dPool.html

SoundPool can also manage the number of audio streams being rendered at once. When the SoundPool object is constructed, the maxStreams parameter sets the maximum number of streams that can be played at a time from this single SoundPool. SoundPool tracks the number of active streams. If the maximum number of streams is exceeded, SoundPool will automatically stop a previously playing stream based first on priority and then by age within that priority. Limiting the maximum number of streams helps to cap CPU loading and reducing the likelihood that audio mixing will impact visuals or UI performance.


Probably have a play with the maxStreams,

also you may want to release and create a new SoundPool at a certain stage in your prog
In our example, when the player has completed the level, the game logic should call SoundPool.release() to release all the native resources in use and then set the SoundPool reference to null. If the player starts another level, a new SoundPool is created, sounds are loaded, and play resumes.


I had this issue with SoundPool I can't remember why, but out of memory means you've used to many resources without releasing some, I resolved my issue by using a MediaPlayer instead of SoundPool don't know if this is an option for you.
User avatar
blundell
Master Developer
Master Developer
 
Posts: 1610
Joined: Tue Nov 18, 2008 12:58 pm
Location: UK

Re: SoundPool crashing with "could not create track"

Postby intermedi8 » Tue Aug 17, 2010 11:44 am

Ive already tried this and increased max streams with the same result. It seems to be a bug with the sample rate parameter. When i set it to 0 theres no problem and i can play the samples as fast behind each other as i like. But when i set it to any other value (even the "regular" 1f) it gives me the "could not create audiotrack" error after a while.

The MediaPlayer is no option for me, as i need to change the sample rate dynamically. :(
intermedi8
Freshman
Freshman
 
Posts: 7
Joined: Fri Jul 16, 2010 8:19 am

Re: SoundPool crashing with "could not create track"

Postby intermedi8 » Tue Aug 17, 2010 1:26 pm

I SOLVED THE PROBLEM!

For everyone having similar troubles:

Make sure you use .ogg media files with constant bitrate! My audio programs preset was to export ogg files with variable bitrate. Those will cause SoundPool to crash, especially when you want to modify the samplerate! Also make sure you export with a low bitrate, as SoundPool runs very fast out of memory. For simple sounds you can easily go down to 32 kb without hearing a difference on a mobile device compared to 128 kb!
intermedi8
Freshman
Freshman
 
Posts: 7
Joined: Fri Jul 16, 2010 8:19 am

Re: SoundPool crashing with "could not create track"

Postby blundell » Tue Aug 17, 2010 2:21 pm

Good Job *Thumbs Up*
User avatar
blundell
Master Developer
Master Developer
 
Posts: 1610
Joined: Tue Nov 18, 2008 12:58 pm
Location: UK

Top

Return to Multimedia Problems

Who is online

Users browsing this forum: No registered users and 18 guests