Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 45111 - Crappy sound while playing MP3 via Artsd and KDE audio infrastructure
Summary: Crappy sound while playing MP3 via Artsd and KDE audio infrastructure
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: x86 Linux
: High normal (vote)
Assignee: Gentoo KDE team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-03-19 01:45 UTC by Davide Ferrari
Modified: 2004-06-14 13:57 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
Patch for current ebuild. (kdemultimedia-3.2.2-r1.diff,911 bytes, patch)
2004-05-25 17:04 UTC, David Connolly
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Davide Ferrari 2004-03-19 01:45:33 UTC
When I play a MP3 file with a KDE-enabled player (like amaroK, JuK and so on), I get every minute or two a couple of seconds where the sound is really crappy and distorced, then it comes back to normal. 
This behaviour DOES NOT OCCOUR while playing Ogg/Vorbis file, so I think it's some kind related to KDE decoding system.
My system is:
Kernel 2.6.3-r1 with ALSA modules loaded, on a NForce2 mobo with intel8x0 alsa module
KDE 3.2.1

Reproducible: Always
Steps to Reproduce:
Comment 1 Steven Robertson 2004-05-22 13:13:24 UTC
I second this behavior, although the symptoms manifest themselves in a slightly different manner.  When playing an MP3 (verified using Kaboodle, Noatun, Juk, and amaroK (with artsd output)), there seems to be more distortion with songs that have high volume high-frequency noise (such as cymbal crashes; a great example of a song with almost continuous distortion is A Perfect Circle's "Thinking of You", where the cymbals playing 8 times a measure throws the bass into a distorted mess).  I've done some testing, and I've ruled out a couple things (the list is dull and uninteresting, and I'm including it mostly for personal reference):

o Any hardware or firmware issues.  Vorbis, uncompressed, or flac compressed files all play perfectly.
o The MP3s themselves.  Using madplay piped to aplay yields expected sound quality.
o Output device.  Audio is piped to my Revo 7.1, tested using both the S/PDIF and stereo analog outputs via OSS emulation, Alsa, and ESD output.  Situation reproduced using a cheesy onboard sound accessed using ESD over XDMCP on a different computer.
o Applications themselves.  amaroK, when using GST output, does not exhibit the behavior.  Nor does Kaffeine, at any time (because xine handles the audio decoding).
o Audio parameters.  Audio was tested at a variety of sample rates and sizes.

The only thing I can see that's left is the actual MP3 decoding library.  mad is set in my USE flags, and artsd is linked to the MAD library.  However, recompiling arts with USE=-mad did not correct the problem.  It should be noted that most, if not all, apps that link against Arts link against libmad as well.

Hope that helps narrow down the search.

Steven
Comment 2 Davide Ferrari 2004-05-22 18:56:59 UTC
I must say that with KDE 3.2.2 (and kernel 2.6.4) this strange behaviour has disappeared. What KDE version are you using?
Comment 3 David Connolly 2004-05-24 16:28:11 UTC
Still happening here with kde-3.2.2, kernel 2.6.6 (alsa), arts 1.2.2, strangely it appears to be much worse with VBR mp3 files further pointing to a problem with there decoding.
Comment 4 Steven Robertson 2004-05-24 16:33:37 UTC
Problem occurs with Arts version 1.2.2, kde 3.2.2, and kernel gentoo-2.6.5-r1.  libmad version 0.15.1b.
Comment 5 Steven Robertson 2004-05-24 16:52:55 UTC
I'm going to rip out libmad, then do a USE=-mad revdep-rebuild, and see what that does.  It'll take a while, though.  (No music for ~12 hours -- GAAA!)  I'll post the results upon completion.
Comment 6 Steven Robertson 2004-05-25 07:31:36 UTC
I removed the mad use flag, unmerged then injected libmad, double-checked that the libmad.0.0.0 library was indeed removed, then recompiled arts, kdelibs, kdebase, and kdemultimedia.  I double-checked several binaries, such as artsd and juk, and made sure that they did not link to libmad in any way.  I killed, then restarted artsd and juk, hit play, let it randomly select a track, and lo and behold...

The problem was still there.

Darn.  Well, at least we know it isn't the libmad library.  I'll keep trying different things.  If anyone wants to suggest something, I'm open to it.
Comment 7 Davide Ferrari 2004-05-25 07:36:56 UTC
I really don't know what to say. I only know that without I was aware of it, it magically disappeared. Probably it's due to KDE3.2.2 update, but I'm not sure at all. Sorry :(
Comment 8 Caleb Tennis (RETIRED) gentoo-dev 2004-05-25 07:42:06 UTC
you can try chmod +s on artswrapper and see if that helps your realtime priority situation.
Comment 9 David Connolly 2004-05-25 11:13:11 UTC
I've gone so far as to renice juk to -20 just to rule priority out, with Arts running setuid and realtime option enabled.

I built arts-1.2.2 without the arts-vorbis patch(affected cpu utilization) being applied, however it had no effect at all :(
Comment 10 Steven Robertson 2004-05-25 13:04:04 UTC
Optimizations.  Duh.

http://forums.gentoo.org/viewtopic.php?t=171962

Odd thing is, my CFLAGS aren't that high.  Arts is a small package; I'll try recompiling many times, removing one CFLAG at a time, and report back on which one if any causes the distortions.  NOTE: I haven't tried this myself, so I don't know if it'll work or not.

Current CFLAGS:

CFLAGS="-O2 -march=athlon-xp -mfpmath=sse -pipe"
Comment 11 Caleb Tennis (RETIRED) gentoo-dev 2004-05-25 13:05:40 UTC
mfpmath would be the only thing I could think of that would be a problem here - -O2 is in kde by default, and the other two shouldn't cause any conflicts.
Comment 12 Steven Robertson 2004-05-25 14:02:44 UTC
OK, got it.  Should have checked the KDE bug database.  See:

http://bugs.kde.org/show_bug.cgi?id=80497

The optimizations trigger a fault in a specific section of code.  The patch is as follows:


--- mpeglib/lib/splay/mpeglayer3.cpp    2004-05-25 16:55:37.742909896 -0400
+++ mpeglib/lib/splay/mpeglayer3.cpp.new        2004-05-25 16:59:03.024702320 -0400
@@ -906,8 +906,8 @@


        do{
-         out[0][index]=factor*TO_FOUR_THIRDS[in[0][index++]];
-         out[0][index]=factor*TO_FOUR_THIRDS[in[0][index++]];
+         out[0][index]=factor*TO_FOUR_THIRDS[in[0][index]];index++;
+         out[0][index]=factor*TO_FOUR_THIRDS[in[0][index]];index++;
        }while(--count);
       }
       cb++;


I've tested it out (unpacked, applied the patch, then just ran a 'make install' in the mpeglib subdir), and applying the patch works.  This solution seems much more appropriate than -O0.  I'm a dunce when it comes to .patch files, so whoever maintains the ebuild will likely need to regenerate the patch, but there's enough context to do it yourself.  

HTH.
Comment 13 Steven Robertson 2004-05-25 14:29:19 UTC
Oh, sorry for being unclear.  The patch is to the 'kdemultimedia' package.
Comment 14 David Connolly 2004-05-25 17:04:30 UTC
Created attachment 32040 [details, diff]
Patch for current ebuild.

Here is a patch for the newest kdemultimedia ebuild

Thanks tracking it down Steven!
Comment 15 Steven Robertson 2004-06-14 12:07:32 UTC
kdemultimedia-3.2.3 contains the patch.  I suggest we close this bug, as long as nobody has a problem with 3.2.3.
Comment 16 Davide Ferrari 2004-06-14 13:57:48 UTC
Ok, it seems that correc patches had been applied on KDE 3.2.3, so since I'm the reporter I have the honour to close the bug :)