[MPlayer-dev-eng] Alsa output issue with rme9632 (small buffers)
Ed Wildgoose
lists at wildgooses.com
Wed Aug 4 15:45:36 CEST 2004
I have an RME 9632 card that I would like to use with mplayer. The
problem is constant underruns, and the cause seems to be as a result of
the 9632 only supporting a two period buffer which defaults to 1024
samples long (ie very low latency).
The two period restriction is a hardware limit, and so I have worked
around this by changing the defaults for the code which sets fragment
sizes. I adjusted the fragment_size to 4096 and compensated a little by
dropping the number of buffers down to 8 (from 16). I should imagine
that this will still be quite satisfactory for most people, and might
help other people with restrictions on the number of period buffers. I
didn't drop it below 8 because there are at least a couple of cards like
the RME96/8 PAD which can only do 8 periods as their restriction...
Secondly there are still a few remaining dropouts, and this seems to be
down to the code which sleeps as part of the main video output loop.
It's correctly checking to see if the sleep might cause the audio to
underflow, but it checks for "time_frame>delay*0.6" - clearly in the
case of a 2 period buffer we will occasionally have less than 0.1 of the
second buffer in use.. So I have changed the test to keep the audio
buffers at least 40% full.
Diff is below. I would be grateful if people could test this and commit
if appropriate. There is one bug remaining/introduced - when I fast
forward with the 9632 card the code is skipping forward OK, but the
screen stays frozen until I release a key - however, with other cards
that have longer buffers, then the code skips forward and draws a fames
at high speed like it did before. I imagine this is something to do
with the way the sleep code interacts with the frame drawing code, but
it shouldn't affect anyone else I don't think? Perhaps someone else
could point out what I did wrong and fix that remaining issue?
Thanks
Ed W
diff -r -u ./libao2/ao_alsa.c
../../../mplayer-1.0_pre5-r2.orig/work/MPlayer-1.0pre5/libao2/ao_alsa.c
--- ./libao2/ao_alsa.c 2004-08-04 14:20:33.762025353 +0100
+++
../../../mplayer-1.0_pre5-r2.orig/work/MPlayer-1.0pre5/libao2/ao_alsa.c
2004-07-14 16:46:33.000000000 +0100
@@ -54,11 +54,14 @@
static snd_pcm_hw_params_t *alsa_hwparams;
static snd_pcm_sw_params_t *alsa_swparams;
+/* possible 4096, original 8192
+ * was only needed for calculating chunksize? */
+static int alsa_fragsize = 4096;
/* 16 sets buffersize to 16 * chunksize is as default 1024
* which seems to be good avarge for most situations
* so buffersize is 16384 frames by default */
-static int alsa_fragcount = 8;
-static snd_pcm_uframes_t chunk_size = 4096;//is alsa_fragsize / 4
+static int alsa_fragcount = 16;
+static snd_pcm_uframes_t chunk_size = 1024;//is alsa_fragsize / 4
#define MIN_CHUNK_SIZE 1024
Files ./libao2/ao_alsa.o and
../../../mplayer-1.0_pre5-r2.orig/work/MPlayer-1.0pre5/libao2/ao_alsa.o
differ
Files ./libao2/libao2.a and
../../../mplayer-1.0_pre5-r2.orig/work/MPlayer-1.0pre5/libao2/libao2.a
differ
Files ./mplayer and
../../../mplayer-1.0_pre5-r2.orig/work/MPlayer-1.0pre5/mplayer differ
diff -r -u ./mplayer.c
../../../mplayer-1.0_pre5-r2.orig/work/MPlayer-1.0pre5/mplayer.c
--- ./mplayer.c 2004-08-04 14:22:59.204622577 +0100
+++ ../../../mplayer-1.0_pre5-r2.orig/work/MPlayer-1.0pre5/mplayer.c
2004-08-04 13:56:55.000000000 +0100
@@ -2184,11 +2184,11 @@
// delay = amount of audio buffered in soundcard/driver
if(delay>0.25) delay=0.25; else
- if(delay<0.05) delay=0.05;
- if(time_frame>delay*0.25){
+ if(delay<0.10) delay=0.10;
+ if(time_frame>delay*0.6){
// sleep time too big - may cause audio drops (buffer underrun)
frame_time_remaining=1;
- time_frame=delay*0.25;
+ time_frame=delay*0.5;
}
} else {
More information about the MPlayer-dev-eng
mailing list