Take the 2-minute tour ×
Android Enthusiasts Stack Exchange is a question and answer site for enthusiasts and power users of the Android operating system. It's 100% free, no registration required.

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:

  1. Start WakeLock in "CPU on, Screen Off, Keyboard off" mode
  2. Use mplayer to play music bypassing Android:
ionice -c1 -n4  \
  schedtool -R -p 3 -e \
  mplayer -really-quiet \
        -af volume=-26 -quiet \
        -ao pcm:file=/dev/msm_pcm_out,nowaveheader \
    /mnt/sdcard/music/something.ogg
# (created script to start it easily, of course)

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.

share|improve this question
    
What device do you have? Sounds like it's very resource constrained. Maybe a fast and light custom ROM would improve the performance. –  Flow Jan 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 –  Vi0 Jan 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? –  Vi0 Jan 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. –  Flow Jan 16 '12 at 22:50
    
Including after update to Android 2.3? –  Vi0 Jan 16 '12 at 23:22
show 5 more comments

2 Answers 2

Increase your Audio Buffer size.

I use PlayerPro Music Player with its DSP pack. DSP pack allows me to adjust audio buffer size. I never needed to use this feature, but it will help you.

You can also find other music players to support this feature. The key is Audio Buffer.

Alternatively, you can reduce music quality as well as system load.

share|improve this answer
    
At least setting maximum buffer size in Mixzing player does not help. –  Vi0 Jun 16 '12 at 22:59
1  
"reduce music quality as well as system load" -> workaround, not fix. I already have hacky workarounds (see "Updates") –  Vi0 Jun 16 '12 at 23:00
add comment

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.

share|improve this answer
    
Looks like a general advice, not a solution/workaround to the bug. I tried various modes (described in question). OOM killer is only one of things that trigger the bug. –  Vi0 Jan 16 '12 at 23:22
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.