title: Permanent audio stutter on LGE Nexus 4 with the Deezer Android SDK
body: <p>Audio playback has been tested successfully on Samsung Galaxy S3 and HTC One, but is severely broken on an LGE Nexus 4 running Android 4.4. What happens is that perfectly fine audio can be heard for a fraction of a second, then there's a few seconds of silence followed by another short piece of audio, then silence, and so it goes. So it seems like the audio streaming logic ends up in an eternal start-play-underrun-stop loop.</p>
  
  <p>Every second or so I see the following warning logged:</p>
  
  <pre><code>12-09 00:55:56.982  10842-14365/com.soundrop.android W/AudioTrack﹕ releaseBuffer() track 0x7b03f4e0 name=s:176;n:2;f:-1 disabled due to previous underrun, restarting
  12-09 00:55:57.583  10842-14367/com.soundrop.android W/AudioTrack﹕ releaseBuffer() track 0x7b03f4e0 name=s:176;n:2;f:-1 disabled due to previous underrun, restarting
  12-09 00:55:58.594  10842-14369/com.soundrop.android W/AudioTrack﹕ releaseBuffer() track 0x7b03f4e0 name=s:176;n:2;f:-1 disabled due to previous underrun, restarting
  12-09 00:55:59.595  10842-14371/com.soundrop.android W/AudioTrack﹕ releaseBuffer() track 0x7b03f4e0 name=s:176;n:2;f:-1 disabled due to previous underrun, restarting
  12-09 00:56:02.047  10842-14379/com.soundrop.android W/AudioTrack﹕ releaseBuffer() track 0x7b03f4e0 name=s:176;n:2;f:-1 disabled due to previous underrun, restarting
  </code></pre>
  
  <p>This lead me to think about possible audio buffer differences between the devices, so I did some probing:</p>
  
  <pre><code>HTC One (good playback): AudioTrack.getMinBufferSize(44100, STEREO, ENCODING_PCM_16BIT) =&gt; 16932
  LGE Nexus 4 (bad playback): AudioTrack.getMinBufferSize(44100, STEREO, ENCODING_PCM_16BIT) =&gt; 7056
  </code></pre>
  
  <p>My speculation is that the Deezer Android SDK sets a too small buffer size on this particular device, as it seems to pick a buffer size that is 10x that of the reported minimum size.</p>
  
  <p><strong>UPDATE: Just reproduced the audio stutter on an HTC One running 4.4, where getMinBufferSize() return 16932 (like it did on Android &lt; 4.4). So this issue is clearly not device-specific, but related to OS-specific behavioral changes starting with KitKat.</strong></p>