linux-mips
[Top] [All Lists]

mpg123 hack

To: Linux SGI <linux@cthulhu.engr.sgi.com>
Subject: mpg123 hack
From: Ulf Carlsson <ulfc@bun.falkenberg.se>
Date: Mon, 5 Apr 1999 22:33:16 -0400
Mail-followup-to: Linux SGI <linux@cthulhu.engr.sgi.com>
Sender: owner-linux@cthulhu.engr.sgi.com
Hi,

I know this is silly and you don't care about it, but I've patched mpg123 so
that I can play mp3's without generating wav files in between :-). Maybe you say
that I should fix my poor HAL2 driver instead - I will...

About the noise:

I have done some testing with mpg123. The HAL2 is, to say the least, acting
weird. I found that only every other sample is played, and the other ones are
dumped.

Ok now to the really really weird part: If I play audio on the samples which are
dumped and zeros on the ones which are played I can hear this silly noise in the
speakers. If I do not play anything, zeros in both channels, it's death quiet
(although the DMA is acting and the HAL2 is playing the zeros). If I play zeros
on the dumped channel and audio on the other one I can hear this noise again.

Hum, I have been looking at this noise problem for nearly two days now without
any progress. Testing one thing the other with no effect. Quite boring, I'll
hack something else tomorrow..

- Ulf

diff -ur mpg123-0.59q-orig/Makefile mpg123-0.59q/Makefile
--- mpg123-0.59q-orig/Makefile  Tue Jan 26 14:35:18 1999
+++ mpg123-0.59q/Makefile       Tue Jan 18 03:26:46 2000
@@ -56,7 +56,7 @@
        @echo "make linux-nas      Linux, output to Network Audio System"
        @echo "make linux-sparc    Linux/Sparc"
        @echo "make linux-sajber   Linux, build binary for Sajber Jukebox 
frontend"
-       @echo "make linux-alsa     Linux with ALSA sound driver"
+       @echo "make linux-mips-alsa Linux/MIPS with ALSA sound driver"
        @echo ""
        @echo "make linux-esd      Linux, output to EsounD"
        @echo "make linux-alpha-esd Linux/Alpha, output to EsounD"
@@ -148,6 +148,17 @@
                CFLAGS='-DI386_ASSEM -DREAL_IS_FLOAT -DPENTIUM_OPT -DLINUX \
                        -DREAD_MMAP -DALSA \
                        -Wall \
+                       -fomit-frame-pointer -funroll-all-loops \
+                       -finline-functions -ffast-math \
+                       $(RPM_OPT_FLAGS)' \
+               mpg123-make
+
+linux-mips-alsa:
+       $(MAKE) CC=gcc LDFLAGS= \
+               AUDIO_LIB='-lasound' \
+               OBJECTS='decode.o dct64.o audio_alsa.o' \
+               CFLAGS='-DLINUX -DREAD_MMAP -DSWAP_BYTES -DREAL_IS_FLOAT \
+                       -DALSA -Wall -O2 \
                        -fomit-frame-pointer -funroll-all-loops \
                        -finline-functions -ffast-math \
                        $(RPM_OPT_FLAGS)' \
diff -ur mpg123-0.59q-orig/audio_alsa.c mpg123-0.59q/audio_alsa.c
--- mpg123-0.59q-orig/audio_alsa.c      Fri Nov 27 11:16:58 1998
+++ mpg123-0.59q/audio_alsa.c   Tue Jan 18 03:24:40 2000
@@ -182,8 +182,24 @@
 int audio_play_samples(struct audio_info_struct *ai,unsigned char *buf,int len)
 {
        ssize_t ret;
+#ifdef SWAP_BYTES
+       int samples = len >> 1; /* will only work in 16 bit mode .. */
+       unsigned short *sample = (unsigned short *) buf;
+       static unsigned short *swap_buf = NULL;
 
+       if (!swap_buf)
+               swap_buf = (unsigned short *) malloc(len);
+
+       while (samples--) {
+               swap_buf[samples] =
+                       (((sample[samples] & 0x00ff) << 8) |
+                       ((sample[samples] & 0xff00) >> 8));
+       }
+
+       ret=snd_pcm_write(ai->handle, swap_buf, len);
+#else
        ret=snd_pcm_write(ai->handle, buf, len);
+#endif
 
        return ret;
 }

<Prev in Thread] Current Thread [Next in Thread>