[MPlayer-advusers] Audio shuttering with Alsa and dmix since r28220

Christian Birchinger joker at netswarm.net
Thu Jan 15 20:06:19 CET 2009


Hello

The SVN r28220 revision added a bug here which causes audio shuttering
with Alsa using dmix under certain conditions (described below).

r28219 works perfectly fine.


Conditions:

- So far it happens with all tested audio files (tested with .ogg and .mp3).

- .avi file with mp3 audio codec was fine. Even playing the video with
  "-vo null" to mimic the audio only behaviour is also fine.

- Only happens with dmix ("-ao alsa:device=dmix"). A direct access with
  "-ao alsa:device=hw=0.0" is ok.

- "-ao sdl" or "-ao sdl:alsa" works good. Stuff like "-ao oss" is fine too.


Audio Hardware: Card: HDA Intel, Chip: Analog Devices AD1984
ALSA (libs/utils): 1.0.17

The "shuttering" can be described as 20ms mute pause every
200ms, sounding like a buffer underrun.


Commit that triggers the problem:

$ svn diff -r28219:28220

Index: mplayer.c
===================================================================
--- mplayer.c   (revision 28219)
+++ mplayer.c   (revision 28220)
@@ -2015,6 +2015,7 @@
     current_module="play_audio";
 
     while (1) {
+       int sleep_time;
        // all the current uses of ao_data.pts seem to be in aos that handle
        // sync completely wrong; there should be no need to use ao_data.pts
        // in get_space()
@@ -2026,7 +2027,9 @@
        // handle audio-only case:
        // this is where mplayer sleeps during audio-only playback
        // to avoid 100% CPU use
-       usec_sleep(10000); // Wait a tick before retry
+       sleep_time = (ao_data.outburst - bytes_to_write) * 1000 / ao_data.samplerate;
+       if (sleep_time < 10) sleep_time = 10; // limit to 100 wakeups per second
+       usec_sleep(sleep_time * 1000);
     }
 
     while (bytes_to_write) {



More information about the MPlayer-advusers mailing list