Bug 88992 - akodelib incorrectly decodes ogg vorbis on ppc (plays noise)
Summary: akodelib incorrectly decodes ogg vorbis on ppc (plays noise)
Status: RESOLVED FIXED
Alias: None
Product: akodelib
Classification: Miscellaneous
Component: general (show other bugs)
Version: unspecified
Platform: Gentoo Packages Linux
: NOR normal
Target Milestone: ---
Assignee: Allan Sandfeld
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-09-07 13:01 UTC by toojays
Modified: 2004-09-08 16:43 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
Patch for xiph_decoder (1.60 KB, patch)
2004-09-08 15:40 UTC, Allan Sandfeld
Details
fix for akodelib vorbis decoding on big-endian archs (1.25 KB, patch)
2004-09-08 16:14 UTC, toojays
Details

Note You need to log in before you can comment on or make changes to this bug.
Description toojays 2004-09-07 13:01:33 UTC
Version:            (using KDE KDE 3.3.0)
Installed from:    Gentoo Packages
Compiler:          gcc (GCC) 3.4.1 20040803 (Gentoo Linux 3.4.1-r2, ssp-3.4-2, pie-8.7.6.5)
 
OS:                Linux

This is a new bug opened in response to comment 8 of bug 61081.

Playing Ogg Vorbis files in JuK or with artsplay results in white noise coming out of the speakers. Problem does not occur playing MP3s, or playing Ogg Vorbis with ogg123 or gstreamer.

I've tried this with a few different files, 64kbps and 128kbps. One interesting one was this file:

---
bash-2.05b$ ogginfo /home/music/lo-qual/aniligital\ music\ -\ all\ your\ beats\ are\ belong\to\ us/01\ the\ secret.ogg
Processing file "/home/music/lo-qual/aniligital music - all your beats are belong to us/01 the secret.ogg"...

New logical stream (#1, serial: 2ea68c27): type vorbis
Vorbis headers parsed for stream 1, information follows...
Version: 0
Vendor: Xiph.Org libVorbis I 20030909 (1.0.1)
Channels: 2
Rate: 44100

Nominal bitrate: 64.001000 kb/s
Upper bitrate not set
Lower bitrate not set
User comments section follows...
        TITLE=the secret
        ALBUM=all your beats are belong to us
        TRACKNUMBER=01
        ARTIST=t vs. T
Vorbis stream 1:
        Total data length: 2966825 bytes
        Playback length: 6m:24s
        Average bitrate: 61.693179 kbps
Logical stream 1 ended
---

(I don't think there's anything interesting in the above, just providing it for completeness.) The interesting thing about this one is that for the first second or two, the music is audible, but then it quickly degenerates into static.

Example artsd output looks like:
bash-2.05b$ artsd -l0
artsd version is 1.3.0
gsl: using Unix98 pthreads directly for mutexes and conditions
[artsd: 10765] SoundServerStartup --> got lock
autodetecting driver:
 - toss: 4
 - esd: -1
 - null: -1
 - alsa: 15
 - oss: 10
... which means we'll default to alsa
ALSA driver: default
buffering: 8 fragments with 1024 bytes (audio latency is 46.4 ms)
Closing ALSA-driver
virtualize StereoVolumeControl
ALSA driver: default
buffering: 8 fragments with 1024 bytes (audio latency is 46.4 ms)
audio format is 44100 Hz, 16 bits, 2 channels
addDirectory(/usr/kde/3.3/lib/mcop,)
addDirectory(/usr/kde/3.3/lib/mcop/Arts,Arts)
addDirectory(/usr/kde/3.3/lib/mcop/Arts/Environment,Arts::Environment)
addDirectory(/usr/kde/3.3/lib/mcop/Noatun,Noatun)
addDirectory(/usr/kde/3.3/lib/mcop/Amarok,Amarok)
addDirectory(/home/toojays/.mcop/trader-cache,)
Arts::MidiManager registered successfully.
[artsd: 10765] SoundServerStartup <-- released lock
xrun!!

UnixManager: got notifyIO
socketconnection created, fd = 10
search playobject, extension = ogg
creating akodeXiphPlayObject to play file /home/music/lo-qual/aniligital music - all your beats are belong to us/02 too much sake.ogg
akode: opening /home/music/lo-qual/aniligital music - all your beats are belong to us/02 toomuch sake.ogg
akode: play

bash-2.05b$ ldd /usr/kde/3.3/lib/libakode_xiph_decoder.so
        libakode.so.1 => /usr/kde/3.3/lib/libakode.so.1 (0x6ffb6000)
        libpthread.so.0 => /lib/libpthread.so.0 (0x6ff44000)
        libdl.so.2 => /lib/libdl.so.2 (0x6ff21000)
        libFLAC.so.4 => /usr/lib/libFLAC.so.4 (0x6fecd000)
        libOggFLAC.so.1 => /usr/lib/libOggFLAC.so.1 (0x6fea6000)
        libvorbisfile.so.3 => /usr/lib/libvorbisfile.so.3 (0x6fe7e000)
        libvorbis.so.0 => /usr/lib/libvorbis.so.0 (0x6fe33000)
        libogg.so.0 => /usr/lib/libogg.so.0 (0x6fe0d000)
        libstdc++.so.6 => /usr/lib/gcc/powerpc-unknown-linux-gnu/3.4.1/libstdc++.so.6 (0x6fd0a000)
        libm.so.6 => /lib/libm.so.6 (0x6fc74000)
        libc.so.6 => /lib/libc.so.6 (0x6fb2a000)
        libgcc_s.so.1 => /usr/lib/gcc/powerpc-unknown-linux-gnu/3.4.1/libgcc_s.so.1 (0x6fafd000)
        /lib/ld.so.1 => /lib/ld.so.1 (0x08000000)

Any other info I can give you?
Comment 1 Allan Sandfeld 2004-09-07 15:49:24 UTC
If possible send the file to me (kde@carewolf.com), and I will test if it behaves differently here.

The fact that it starts correctly and then changes, could mean that it changes format, or has a data error that puts akodelib in an odd state.
Comment 2 Allan Sandfeld 2004-09-08 15:40:31 UTC
Created attachment 7454 [details]
Patch for xiph_decoder

Someone ought to teach the xiph-developers about a little thing called "native
endian".

Please try the patch and see if it helps.
Comment 3 toojays 2004-09-08 16:13:25 UTC
Yeah, nice one. The actual patch you supplied causes a segfault:

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 16384 (LWP 22937)]
0x0efa7bb0 in VorbisDecoder (this=0x100a8a38, src=0x100a61b0) at vorbis_decoder.cpp:98
98          ((unsigned char*)xiph_developers_suck)[1] = 1;
(gdb) bt
#0  0x0efa7bb0 in VorbisDecoder (this=0x100a8a38, src=0x100a61b0) at vorbis_decoder.cpp:98
#1  0x0efa7ba8 in VorbisDecoder (this=0x100a8a38, src=0x100a61b0) at vorbis_decoder.cpp:95
#2  0x0efa7ba8 in VorbisDecoder (this=0x100a8a38, src=0x100a61b0) at vorbis_decoder.cpp:95
#3  0x0efa7ba8 in VorbisDecoder (this=0x100a8a38, src=0x100a61b0) at vorbis_decoder.cpp:95
#4  0x0efa7ba8 in VorbisDecoder (this=0x100a8a38, src=0x100a61b0) at vorbis_decoder.cpp:95
#5  0x0efa7ba8 in VorbisDecoder (this=0x100a8a38, src=0x100a61b0) at vorbis_decoder.cpp:95
#6  0x0efa7ba8 in VorbisDecoder (this=0x100a8a38, src=0x100a61b0) at vorbis_decoder.cpp:95
#7  0x0efa7ba8 in VorbisDecoder (this=0x100a8a38, src=0x100a61b0) at vorbis_decoder.cpp:95
#8  0x0efa7ba8 in VorbisDecoder (this=0x100a8a38, src=0x100a61b0) at vorbis_decoder.cpp:95
#9  0x0efa7ba8 in VorbisDecoder (this=0x100a8a38, src=0x100a61b0) at vorbis_decoder.cpp:95
#10 0x0efa7ba8 in VorbisDecoder (this=0x100a8a38, src=0x100a61b0) at vorbis_decoder.cpp:95
#11 0x0efa7ba8 in VorbisDecoder (this=0x100a8a38, src=0x100a61b0) at vorbis_decoder.cpp:95
#12 0x0efa7ba8 in VorbisDecoder (this=0x100a8a38, src=0x100a61b0) at vorbis_decoder.cpp:95
#13 0x0efa7ba8 in VorbisDecoder (this=0x100a8a38, src=0x100a61b0) at vorbis_decoder.cpp:95
#14 0x0efa7ba8 in VorbisDecoder (this=0x100a8a38, src=0x100a61b0) at vorbis_decoder.cpp:95
#15 0x0efa7ba8 in VorbisDecoder (this=0x100a8a38, src=0x100a61b0) at vorbis_decoder.cpp:95
#16 0x0efa7ba8 in VorbisDecoder (this=0x100a8a38, src=0x100a61b0) at vorbis_decoder.cpp:95
#17 0x0efa7ba8 in VorbisDecoder (this=0x100a8a38, src=0x100a61b0) at vorbis_decoder.cpp:95
#18 0x0efa7ba8 in VorbisDecoder (this=0x100a8a38, src=0x100a61b0) at vorbis_decoder.cpp:95
#19 0x0efa7ba8 in VorbisDecoder (this=0x100a8a38, src=0x100a61b0) at vorbis_decoder.cpp:95
Previous frame inner to this frame (corrupt stack?)

But, I understood the idea of what you were doing, so replaced the endianness check with one from the bottom of this page: http://www.unixpapa.com/incnote/byteorder.html

I'll attach the resulting patch. It works fine now. Thanks.
Comment 4 toojays 2004-09-08 16:14:31 UTC
Created attachment 7455 [details]
fix for akodelib vorbis decoding on big-endian archs
Comment 5 Allan Sandfeld 2004-09-08 16:43:27 UTC
CVS commit by carewolf: 

Fix big-endian decoding, since libvorbis do not respect native endian.

CCMAIL:88992-done@bugs.kde.org


  M +7 -2      vorbis_decoder.cpp   1.5.2.2


--- kdemultimedia/akode/plugins/xiph_decoder/vorbis_decoder.cpp  #1.5.2.1:1.5.2.2
@@ -71,5 +71,5 @@ extern "C" { VorbisDecoderPlugin vorbis_
 struct VorbisDecoder::private_data
 {
-    private_data() : bitstream(0), eof(false), error(false), initialized(false) {};
+    private_data() : bitstream(0), eof(false), error(false), initialized(false), big_endian(0) {};
     OggVorbis_File *vf;
     vorbis_comment *vc;
@@ -83,4 +83,6 @@ struct VorbisDecoder::private_data
     char buffer[8192];
     bool initialized;
+
+    int big_endian;
 };
 
@@ -92,4 +94,7 @@ VorbisDecoder::VorbisDecoder(File *src) 
     m_data->src->openRO();
     m_data->src->fadvise();
+
+    unsigned short endian_test = 1;
+    m_data->big_endian = 1 - (*((char *)(&endian_test)));
 };
 
@@ -177,5 +182,5 @@ bool VorbisDecoder::readFrame(AudioFrame
 
     int old_bitstream = m_data->bitstream;
-    long v = ov_read(m_data->vf, (char*)m_data->buffer, 8192,0,2,1, &m_data->bitstream);
+    long v = ov_read(m_data->vf, (char*)m_data->buffer, 8192, m_data->big_endian, 2, 1, &m_data->bitstream);
 
     if (v == 0 || v == OV_EOF ) m_data->eof = true;