ExoPlayer AudioTrack Stuttering
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.
Solution 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.