Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy does AudioFlinger fail without programmatic indication?
    primarykey
    data
    text
    <p>I'm having a problem where SoundPool crashes, but gives no programmatic indication that is has crashed. After it crashes, it will not play any more sounds until the application is reloaded (exiting via back button then restarting is not sufficient). LogCat gives me these error messages:</p> <pre><code>AudioFlinger: no more track names availlable [sic] AudioTrack: AudioFlinger could not create track, status: -12 SoundPool: Error creating AudioTrack </code></pre> <p>Yet, despite these errors, SoundPool.play() still returns a positive integer that increments for each new play request which, according to the documentation, indicates that there was not an error. Someone else started an Issue for this problem: <a href="http://code.google.com/p/android/issues/detail?id=13453" rel="nofollow">http://code.google.com/p/android/issues/detail?id=13453</a></p> <p>...however, there have been no responses. The code below is a minimalist Activity to consistently recreate this issue. Just create a new Android project, set the ID of the LinearLayout to main_bg, set the ID of the TextView to main_tv, and add a sound file named ding to res/raw. The sound file needs to be long enough to click on the screen four times before the first sound completes; mine is a 1.7-second 22050 Hz mono MP3 @ 96kbps. After a brief pause, the fifth click will generate the error messages above via LogCat. Or, you can just click a bunch of times until sounds stop playing.</p> <p>I have tested the error messages to occur on a T-Mobile G1 running Android 1.6, but they do not occur on a 1.6 emulator, a 2.1 emulator, or a 2.2 emulator.</p> <p>Does anyone know how to fix this problem, or is SoundPool just worthless for coincident sound effects on a G1?</p> <p>Code:</p> <pre><code>public class SoundTestActivity extends Activity implements OnClickListener { private SoundPool mSoundPool; private HashMap&lt;Integer, Integer&gt; mSoundPoolMap; private int index = 0; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); findViewById(R.id.main_bg).setOnClickListener((OnClickListener)this); initSounds(); mSoundPoolMap.put(index, mSoundPool.load(getApplicationContext(), R.raw.ding, 1)); } public void initSounds() { mSoundPool = new SoundPool(10, AudioManager.STREAM_MUSIC, 0); mSoundPoolMap = new HashMap&lt;Integer, Integer&gt;(); } @Override public void onClick(View v) { int result = mSoundPool.play(mSoundPoolMap.get(index), 0.99f, 0.99f, 1, 0, 1f); ((TextView)findViewById(R.id.main_tv)).setText(Integer.toString(result)); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload