52

I have my own implementation of TrackRenderer for an mp3 decoder, that I integrated. When a lollipop device goes to standby and comes back, it's not always repeatable but the audio starts to stutter until I force stop the application.

In the beginning, I thought it was the decoder I implemented, so I tried comparing the file output between a stuttering track to a normal one. The files are identical, I then thought maybe it's taking too long to decode, so I increased the buffer size and called setPlayReady false, in order for the data to buffer. It stutters the same as if I didn't pause. I am currently thinking the issue is with either my implementation of an audio track or an OS bug. The bug only happens on Lollipop devices.

My TrackRenderer uses the same workflow as AudioTrackRenderer, with my own native implementation for the decoder for mp3 and not opus.

Parth Pandya
  • 1,050
  • 7
  • 15
  • 22
Daniel Nuriel
  • 521
  • 3
  • 3
  • If the data is same between good and bad case then perhaps its the metadata. Can you check the sample rate being reported is the same? – Peter Tran Jul 29 '15 at 23:48
  • Ok, because the bug is hard to replicate I haven't had the chance to test the sample rate. I believe they are the same and ill update my post when i can confirm. Adding in 2 changes that made a difference while (feedInputBuffer()) {} while looping with a large buffer the stutter disappears gradually. While not looping it will stutter indefinitely. So looks like I'm dealing with speed of decoding or data being fed to slow. Going to try to prove it with bytes per sec. – Daniel Nuriel Jul 30 '15 at 11:08

1 Answers1

1

I have seen similar behavior couple times and it was related to lowering cpu frequency for power saving. If you have rooted device you can try going to:

cd /sys/devices/system/cpu/

And for all cpu's you see (replace cpuX by cpu0, cpu1 and etc) do:

echo 1 > cpuX/online
echo performance > cpuX/cpufreq/scaling_governor

If this is the case then unfortunately I don't think you can easily workaround this problem.

LLL
  • 1,777
  • 1
  • 15
  • 31