diff -ruN mpg123-0.59o.orig/Makefile mpg123-0.59o/Makefile --- mpg123-0.59o.orig/Makefile Sat Oct 24 22:37:54 1998 +++ mpg123-0.59o/Makefile Sat Oct 24 22:49:18 1998 @@ -48,6 +48,7 @@ @echo "make linux-m68k Linux/m68k (Amiga, Atari) using OSS" @echo "make linux-nas Linux, output to Network Audio System" @echo "make linux-sajber Linux, build binary for Sajber Jukebox frontend" + @echo "make linux-alsa Linux with ALSA sound driver" @echo "" @echo "Please read the file INSTALL for additional information." @echo "" @@ -74,6 +75,19 @@ audio_oss.o' \ CFLAGS='-DI386_ASSEM -DREAL_IS_FLOAT -DPENTIUM_OPT -DLINUX \ -DREAD_MMAP -DOSS \ + -Wall \ + -fomit-frame-pointer -funroll-all-loops \ + -finline-functions -ffast-math \ + $(RPM_OPT_FLAGS)' \ + mpg123-make + +linux-alsa: + $(MAKE) CC=gcc LDFLAGS= \ + AUDIO_LIB='-lasound' \ + OBJECTS='decode_i386.o dct64_i386.o getbits.o decode_i586.o \ + audio_alsa.o' \ + CFLAGS='-DI386_ASSEM -DREAL_IS_FLOAT -DPENTIUM_OPT -DLINUX \ + -DREAD_MMAP -DALSA \ -Wall \ -fomit-frame-pointer -funroll-all-loops \ -finline-functions -ffast-math \ diff -ruN mpg123-0.59o.orig/audio.c mpg123-0.59o/audio.c --- mpg123-0.59o.orig/audio.c Sat Jan 17 14:49:52 1998 +++ mpg123-0.59o/audio.c Sat Oct 24 22:41:19 1998 @@ -15,6 +15,12 @@ ai->rate = -1; ai->gain = -1; ai->output = -1; +#ifdef ALSA + ai->handle = NULL; + ai->alsa_format.format = -1; + ai->alsa_format.rate = -1; + ai->alsa_format.channels = -1; +#endif ai->device = NULL; ai->channels = -1; ai->format = -1; diff -ruN mpg123-0.59o.orig/audio.h mpg123-0.59o/audio.h --- mpg123-0.59o.orig/audio.h Mon Nov 10 00:34:04 1997 +++ mpg123-0.59o/audio.h Sat Oct 24 22:41:19 1998 @@ -27,6 +27,10 @@ #include #endif +#ifdef ALSA +#include +#endif + struct audio_info_struct { #ifdef AUDIO_USES_FD @@ -39,6 +43,10 @@ long rate; int gain; int output; +#ifdef ALSA + void *handle; + snd_pcm_format_t alsa_format; +#endif char *device; int channels; int format; diff -ruN mpg123-0.59o.orig/audio_alsa.c mpg123-0.59o/audio_alsa.c --- mpg123-0.59o.orig/audio_alsa.c Thu Jan 1 01:00:00 1970 +++ mpg123-0.59o/audio_alsa.c Sat Oct 24 23:25:40 1998 @@ -0,0 +1,194 @@ +/* + * Driver for Advanced Linux Sound Architecture, http://alsa.jcu.cz + * + * Code by Anders Semb Hermansen + * Cleanups by Jaroslav Kysela + * + * You can use -a :... + * For example: mpg123 -a 1:0 aaa.mpg + * mpg123 -a guspnp:1 aaa.mpg + */ + +#include "mpg123.h" + +#include +#include +#include + +int audio_open(struct audio_info_struct *ai) +{ + int err; + int card=0,device=0; + char scard[128], sdevice[128]; + + if(!ai) + return -1; + if(ai->device) { /* parse ALSA device name */ + if(strchr(ai->device,':')) { /* card with device */ + strncpy(scard, ai->device, sizeof(scard)-1); + scard[sizeof(scard)-1] = '\0'; + if (strchr(scard,':')) *strchr(scard,':') = '\0'; + card = snd_card_name(scard); + if (card < 0) { + fprintf(stderr, "wrong soundcard number: %s\n", scard); + exit(1); + } + strncpy(sdevice, strchr(ai->device, ':') + 1, sizeof(sdevice)-1); + } else { + strncpy(sdevice, ai->device, sizeof(sdevice)-1); + } + sdevice[sizeof(sdevice)-1] = '\0'; + device = atoi(sdevice); + if (!isdigit(sdevice[0]) || device < 0 || device > 31) { + fprintf(stderr, "wrong device number: %s\n", sdevice); + exit(1); + } + } + + if((err=snd_pcm_open(&ai->handle, card, device, SND_PCM_OPEN_PLAYBACK)) < 0 ) + { + fprintf(stderr, "open failed: %s\n", snd_strerror(err)); + exit(1); + } + + if(audio_reset_parameters(ai) < 0) + { + audio_close(ai); + return -1; + } + + return 0; +} + +static void audio_set_playback_params(struct audio_info_struct *ai) +{ + int err; + snd_pcm_playback_info_t pi; + snd_pcm_playback_params_t pp; + + if((err=snd_pcm_playback_info(ai->handle, &pi)) < 0 ) + { + fprintf(stderr, "playback info failed: %s\n", snd_strerror(err)); + return; /* not fatal error */ + } + + bzero(&pp, sizeof(pp)); + pp.fragment_size = pi.buffer_size/4; + if (pp.fragment_size > pi.max_fragment_size) pp.fragment_size = pi.max_fragment_size; + if (pp.fragment_size < pi.min_fragment_size) pp.fragment_size = pi.min_fragment_size; + pp.fragments_max = -1; + pp.fragments_room = 1; + + if((err=snd_pcm_playback_params(ai->handle, &pp)) < 0 ) + { + fprintf(stderr, "playback params failed: %s\n", snd_strerror(err)); + return; /* not fatal error */ + } +} + +int audio_reset_parameters(struct audio_info_struct *ai) +{ + audio_set_format(ai); + audio_set_channels(ai); + audio_set_rate(ai); + + return 0; +} + +int audio_rate_best_match(struct audio_info_struct *ai) +{ + return 0; +} + +int audio_set_rate(struct audio_info_struct *ai) +{ + int ret; + + if(!ai || ai->rate < 0) + return -1; + + ai->alsa_format.rate=ai->rate; + + if((ret=snd_pcm_playback_format(ai->handle, &ai->alsa_format)) < 0 ) + return -1; + + audio_set_playback_params(ai); + + return 0; +} + +int audio_set_channels(struct audio_info_struct *ai) +{ + int ret; + + if(ai->alsa_format.channels < 0) + return 0; + + ai->alsa_format.channels = ai->channels; + + if((ret=snd_pcm_playback_format(ai->handle, &ai->alsa_format)) < 0 ) + return -1; + + audio_set_playback_params(ai); + + return 0; +} + +int audio_set_format(struct audio_info_struct *ai) +{ + int ret; + + if(ai->format == -1) + return 0; + + switch(ai->format) + { + case AUDIO_FORMAT_SIGNED_16: + default: + ai->alsa_format.format=SND_PCM_SFMT_S16_LE; + break; + case AUDIO_FORMAT_UNSIGNED_8: + ai->alsa_format.format=SND_PCM_SFMT_U8; + break; + case AUDIO_FORMAT_SIGNED_8: + ai->alsa_format.format=SND_PCM_SFMT_S8; + break; + case AUDIO_FORMAT_ULAW_8: + ai->alsa_format.format=SND_PCM_SFMT_MU_LAW; + break; + case AUDIO_FORMAT_ALAW_8: + ai->alsa_format.format=SND_PCM_SFMT_A_LAW; + break; + case AUDIO_FORMAT_UNSIGNED_16: + ai->alsa_format.format=SND_PCM_SFMT_U16_LE; + break; + } + + if((ret=snd_pcm_playback_format(ai->handle, &ai->alsa_format)) < 0 ) + return -1; + + audio_set_playback_params(ai); + + return 0; +} + +int audio_get_formats(struct audio_info_struct *ai) +{ + return AUDIO_FORMAT_SIGNED_16; +} + +int audio_play_samples(struct audio_info_struct *ai,unsigned char *buf,int len) +{ + ssize_t ret; + + ret=snd_pcm_write(ai->handle, buf, len); + + return ret; +} + +int audio_close(struct audio_info_struct *ai) +{ + int ret; + ret = snd_pcm_close(ai->handle); + return ret; +} diff -ruN mpg123-0.59o.orig/httpget.c mpg123-0.59o/httpget.c --- mpg123-0.59o.orig/httpget.c Sat Nov 8 18:51:59 1997 +++ mpg123-0.59o/httpget.c Sat Oct 24 22:41:19 1998 @@ -5,6 +5,12 @@ * Wed Apr 9 20:57:47 MET DST 1997 */ +/* + * If we don't do this with get conflicting types when compiling with ALSA + * Anders Hermansen + */ +#undef ALSA + #ifndef WIN32 #include .