Bug 81095 - arts / ALSA / dmix responsiveness
Summary: arts / ALSA / dmix responsiveness
Status: RESOLVED WORKSFORME
Alias: None
Product: arts
Classification: Miscellaneous
Component: general (show other bugs)
Version: unspecified
Platform: Debian testing Linux
: NOR normal
Target Milestone: ---
Assignee: Allan Sandfeld
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-05-07 15:25 UTC by Christian Mayrhuber
Modified: 2004-05-07 23:40 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
Dmix interactivity patch (7.11 KB, patch)
2004-05-07 21:32 UTC, Allan Sandfeld
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Christian Mayrhuber 2004-05-07 15:25:11 UTC
Version:           2.0.1 (using KDE KDE 3.2.2)
Installed from:    Debian testing/unstable Packages

The juk gui becomes incredibly sluggish once a song is playing.
Sometimes, the gui controls are only reacting after one to
two seconds and have to be clicked two or three times till it reacts.
Machine is Athlon XP 2000+ with arts-output consuming around 9% of
CPU, the machine is idle, otherwise.

I guess the player is running in the same thread as the gui.
Please move the player into an extra thread, separated from the one
the gui is running in.
Comment 1 Scott Wheeler 2004-05-07 15:44:13 UTC
I'm pretty sure this is the standard Debian dependency problem.  aRts will play stuff without mpeglib installed, but not very well.  Please install mpeglib and things should be much better.
Comment 2 Christian Mayrhuber 2004-05-07 16:48:22 UTC
Installing libarts1-mpeglib does only help a little bit when it comes
down to slugginess.
The cpu usage of artsd reduces from 9% to 1% with libmpeglib.
But the real problem seems to be the combination of artsd and
alsa+dmix.
As soon I switch artsd to "Threaded Open Sound System" the cpu
usage drops to 0.3% for artsd and Juk becomes perfectly
usable.

Should I file a bug report on arts or alsa?
Comment 3 Christian Mayrhuber 2004-05-07 17:12:52 UTC
Artsd seems to block till the dmix buffer has emptied.
Changing the dmix setup in /etc/asound.conf from

pcm.dmixer  {
        type dmix
        ipc_key 1024
        ipc_key_add_uid true
        slave {
                pcm "hw:0,0"
                period_time 0
                period_size 4096
                buffer_size 16384
                rate 44100
        }
        bindings {
                0 0
                1 1
        }
}

to the insane buffer size of 256 bytes

pcm.dmixer  {
        type dmix
        ipc_key 1024
        ipc_key_add_uid true
        slave {
                pcm "hw:0,0"
                period_time 0
                period_size 128
                buffer_size 256
                rate 44100
        }
        bindings {
                0 0
                1 1
        }
}

makes Juk respond almost immediately, but triples the CPU load
of artsd.
Comment 4 Scott Wheeler 2004-05-07 17:29:55 UTC
Ah, sorry -- yeah I didn't actually understand what you were getting at earlier until this post (and the Debian not installing mpeglib issue comes up so often that it was a reflex).

Honestly I don't really know very much about dmix -- but I would presume that it's possible to terminate a stream even once its entered the buffers.  But this is either an aRts or ALSA issue, so I'm moving it there.

(Oh, and one thing I forgot to respond to in your original post -- JuK doesn't do any decoding or playing in process when using the aRts backend; it simply sends requests to artsd to play something and gets feedback from there.)
Comment 5 Allan Sandfeld 2004-05-07 18:58:02 UTC
It is another known problem. The OSS-emulation layer in ALSA sucks, using the TOSS-driver in aRts is a workaround for bad hardware and also helps in this case. But the best solution is to use the ALSA-driver if you have ALSA. Be aware that to use dmix with aRts you need KDE 3.2.2 or later. Using a newer aRts also changes the default driver from OSS to ALSA.
Comment 6 Christian Mayrhuber 2004-05-07 19:19:31 UTC
Allen, I **am** using alsa + dmix + arts alsa output with kde 3.2.2. I was just experimenting with the threaded oss driver.
The hardware is in no way bad, it's a nvidia nforce2 soundstorm chip.
The sluggishness happens with the above combination, but not with
the threaded oss and not with the oss output arts module.
The sluggishness only goes away by reducing the dmix buffersize to
the small value of 256 bytes.
So I guess it is either a dmix or artsd bug. I have not noticed a similiar
behaviour with xmms and the alsa output module.

Arts version is 1.2.2. Alsa is from kernel-2.6.5 and the alsa-utils
version is 1.0.3.
Comment 7 Allan Sandfeld 2004-05-07 20:29:55 UTC
Okay, that changes things:
aRts do not block until the buffer is empty as you suggest, but it could block for an entire period. You could improve things by keeping the period size small (512 or 1024 bytes) and still have a large buffer.

But seriously it sounds like one of the intermediate problems I had while fixing dmix. Can you tell me the exact installed versions of aRts(most like 1.2.2-1) and libasound2? 
Also does downgrading libasound2 help?
Comment 8 Christian Mayrhuber 2004-05-07 20:48:36 UTC
ii  libarts1       1.2.2-1        aRts Sound system
ii  libasound2     1.0.4-1        Advanced Linux Sound Architecture

I cannot downgrade to the woody version, because the whole kde 3.2.2 will
get uninstalled. I do not have any older sarge alsa version at hand, too.

I already decreased the buffer size to 256 bytes. 512 is not small enough.
See http://bugs.kde.org/show_bug.cgi?id=81095
Comment 9 Allan Sandfeld 2004-05-07 21:06:09 UTC
Okay I managed to reproduce. At least it is already fixed in CVS-HEAD, so I am back-porting a few fixes. If I send you a patch can you compile and test a new version of aRts?
Comment 10 Christian Mayrhuber 2004-05-07 21:08:38 UTC
Yes, I can.
Comment 11 Allan Sandfeld 2004-05-07 21:32:20 UTC
Created attachment 5905 [details]
Dmix interactivity patch
Comment 12 Allan Sandfeld 2004-05-07 21:34:17 UTC
Forgot some comments: This patch is supposed to be applied to in the arts/flow folder. 

It fixes the problem here, but I would like to know if it helps for you too.
Comment 13 Christian Mayrhuber 2004-05-07 21:57:23 UTC
Yes, this patch perfectly fixes this problem for me.

Should I file a bug on libarts1 and append your patch as fix on
bugs.debian.org?

Comment 14 Allan Sandfeld 2004-05-07 22:52:56 UTC
Yes, it's probably a good idea. I am going to commit it to KDE CVS now, but that wont make it to an official release before KDE 3.2.3
Comment 15 Christian Mayrhuber 2004-05-07 23:40:39 UTC
Filed the bug report + patch for debian/libarts1.
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=247905

Allan, thanks a lot!