When I try to play music on Android 2.3 (using various players, including PowerAmp) on Sony Ericsson Xperia X10 I get not reliable sound. Music pauses for a short time, for example, when:

I press the power button (especially repeatedly) (request_suspend_state: sleep;request_suspend_state: wakeup in dmesg)

When I see messages like send sigkill to 15497 (ndroid.settings), adj 8, size 6428 in dmesg

When some program reacts to changed screen orientation.

When wifi connection gets established, when I force it to "reassociate"

When I go to/from application from home screen (AWDLauncher), except of to/from WidgetLocker screen.

When I enable/disable Airplane Mode.

When the display is off (the most annoying)

When only really stable way to play music is to use StayAwake to force display on, turn off Wi-Fi, turn on Airplane Mode and don't switch applications. Starting CPU hogs like while true; do true; done does not affect chopping.

And it was playing more or less fine on Android 2.1.

"mediaserv" process (that writes to /dev/msm_pcm_out) has realtime io and scheduling priority, but sound is choppy anyway. If I start playing from console with mplayer -ao pcm:file=/dev/msm_pcm_out the sound chop less (notably it does not get interrupted by power button / loading bunches of heavy processes), but still behave not normally when screen is off (even ionice -c1 -p4 cat /dev/urandom > /dev/msm_pcm_out is choppy)

When I start music A by usual way and music B using mplayer to /dev/msm_pcm_out (getting them mixed) music A chops more than usual and I usually hear B when A is in chop. When I turn off screen, both A and B chops in sync (stopping B leads to relatively more fluent playback of A this way).

How to play music on Android reliably in presence of background load? Should I report a bug somewhere?

Update Found a way of playing music. Inconvenient, but without chopping:

Plays without chopping no matter how much applications I start, what do with Wifi, orientation and airplane modes. Even with "powersave" cpufreq governor (everything very slow, but music plays fine). So the hardware have enough resources to play it.

Update 2
Looks like doing

for i in `pgrep ''`; do schedtool -D $i; done

i.e. "Set Idle priority for all processes" makes music play fine even when I {start programs,lock screen,rotate screen;it reconnects to other mobile network stations} at expense of some input lag in games. Don't know exactly why it happens.

What device do you have? Sounds like it's very resource constrained. Maybe a fast and light custom ROM would improve the performance.
– FlowJan 16 '12 at 20:07

Sony Ericsson Xperia X10. What does mean "resource constrained"? It should prioritise media over usual activities, allowing fluent playback independently on how much background load present. Also trying to cause load by explicitly using heavy applications hogging CPU and memory does not lead to choppy audio while just reassociating Wifi always produces chop. Also it played more or less fine on Android 2.1
– Vi0Jan 16 '12 at 21:49

Music plays the same even I force powersave cpufreq governor (and CPU non-nice load is about 20% in this case). What resources can be short?
– Vi0Jan 16 '12 at 22:43

From what I can read from your additional comments: none. And I also have never heard that the X10 has a general problem with audio playback.
– FlowJan 16 '12 at 22:50

2 Answers
2

Try turning off any applications or hardware that uses a lot of the phone's resources. Turn off GPS, WIFI, Network Service, and dim the backlight. Also shut down any other running applications than the ones you need for playing music. If this still doesn't work your device may not have enough memory.