Wake lock / CPU / Music issues when sleeping.
I'm having some real trouble with music on ICS, when the screen is switched off.
Here are the conditions:
1. My app uses a MediaPlayer to play music.
2. My app holds a PARTIAL_WAKE_LOCK to keep the CPU awake.
3. I'm running a foreground service. It is very interactive with the user (via TTS and music) for about 30 mins. Mustn't be killed, and is tracking GPS updates and doing lots of stuff.
When the screen is switched off with the power button, the music starts to stutter. Not ALL tracks, but I've found a few with a 320 bitrate that have this issue.
I've noticed some interesting stuff.
When the screen is on:
(first line is the media service, second is my app.. they are the top 2 processes)
PID PR CPU% S #THR VSS RSS PCY UID Name
119 0 6% S 12 45484K 5780K fg media /system/bin/mediaserver
8852 1 4% S 23 493580K 65700K fg app_98 com.rundouble.companion
(When the screen is turned off (and the stuttering starts)
PID PR CPU% S #THR VSS RSS PCY UID Name
119 0 5% S 12 45484K 5780K fg media /system/bin/mediaserver
My app drops right off the screen (down to 0%) which I don't understand because I have a wake lock. But also the mediaserver reliably and reproducably drops to 5%. I suspect this is related to the stuttering.
Now, in the Google Music player the SAME HAPPENS, unless I turn on the "Sound Effect" option. However, I don't have API access to this from my app, so I can't turn it on. However, the fact that the Google Music app does the same suggests this is a bug with the MediaPlayer.
Any Ideas?
Thanks
Martin