[MPlayer-users] Re: audio filters drain the cpu

Tobias Diedrich ranma at tdiedrich.de
Sat Dec 17 18:24:31 CET 2005


Fredrik Eriksson wrote:
> playing a audiofile like
> 
> mplayer music.mp3
> 
> works just fine, without any notable cpu usage. However, trying to use a 
> audiofilter, like
> 
> mplayer -af sub music.mp3
> 
> or
> 
> mplayer -af surround music.mp3

I can reproduce that on my SB Live.
Can you try the attached patch and see if it makes the problem go away for you?

It seems like snd_pcm_status_get_avail returns something not a
multiple of chunk_size, but snd_pcm_writei only writes multiples of
chunk_size.  The while-loop in ao_alsa then retries with the remainder
and the next call to snd_pcm_writei is busy-waiting.

-- 
Tobias						PGP: http://9ac7e0bc.uguu.de
-------------- next part --------------
Index: ao_alsa.c
===================================================================
RCS file: /cvsroot/mplayer/main/libao2/ao_alsa.c,v
retrieving revision 1.21
diff -u -r1.21 ao_alsa.c
--- ao_alsa.c	5 Dec 2005 01:31:03 -0000	1.21
+++ ao_alsa.c	17 Dec 2005 17:17:40 -0000
@@ -1085,6 +1084,15 @@
     if (ret < MIN_CHUNK_SIZE)
       ret = 0;
 
+    /*
+     * Round down to multiples of chunk_size, without this CPU usage
+     * is going through the roof with more than 2 channels on emu10k.
+     * snd_pcm_writei seems to not write more than chunk_size, and the
+     * following write seems to be busy-waiting.
+     */
+    ret /= chunk_size;
+    ret *= chunk_size;
+
     return(ret);
 }
 


More information about the MPlayer-users mailing list