title: Ringtone plays over and over again (looping infinitely)
body: <p>I have an Android app that plays a notification ringtone (<code>RingtoneManager.TYPE_NOTIFICATION</code>) when certain events are sent to a BroadcastReceiver.</p>
  
  <p>The code that plays the ringtone basically does:</p>
  
  <pre><code>    onReceive(Context context, Intent intent)
      {
          ...
          Uri ringtoneUri = someFunctionToLookupAValidNotificationRingtoneUri();
          ...
          Ringtone tone = RingtoneManager.getRingtone(context, uri);
          Log.v(TAG, "About to play ringtone");
          tone.play();
      }
  </code></pre>
  
  <p>Every so often when this code is run, the ringtone starts playing over and over again infinitely. Sometimes it happens when a large number of events are bunched close together, but it has also happened when only one event came in. The log message (and debugging) verifies that the <code>tone.play()</code> call is happening only once per event, and there isn't an infinite stream of events.</p>
  
  <p>The only way stop the infinite looping is to kill my app.</p>
  
  <p>It's almost as if every so often, Android forgets to flush the sound output buffer and so it keeps looping through playing whatever is inside.</p>
  
  <p>Any ideas how to debug and/or fix this issue?</p>