mirror of
http://mpg123.de/trunk/.git
synced 2025-10-29 14:09:21 +03:00
Now up-to-date with the progress I made in my own SVN repository.
Lots of changes to the audio output interface - it is now a lot cleaner. git-svn-id: svn://scm.orgis.org/mpg123/trunk@159 35dc7657-300d-0410-a2e5-dc2837fedb53
This commit is contained in:
@@ -1,4 +1,17 @@
|
||||
#!/bin/sh
|
||||
|
||||
|
||||
#LINE=`grep "AC_INIT(" configure.ac`
|
||||
#AC_INIT([mpg123], [0.60-devel], [mpg123-devel@lists.sourceforge.net])
|
||||
|
||||
|
||||
|
||||
cd src
|
||||
|
||||
# Need to extract this automatically from configure.ac
|
||||
echo "// Created by MakeLegacy.sh" > config.h
|
||||
echo "#define PACKAGE_NAME \"mpg123\"" >> config.h
|
||||
echo "#define PACKAGE_VERSION \"0.60-devel\"" >> config.h
|
||||
|
||||
|
||||
exec make -f Makefile.legacy $*
|
||||
|
||||
@@ -124,7 +124,7 @@ AC_CHECK_HEADERS([CoreAudio/CoreAudio.h], HAVE_COREAUDIO=yes, HAVE_COREAUDIO=no)
|
||||
|
||||
dnl ############## Choose compiler flags and CPU
|
||||
|
||||
CFLAGS="$CFLAGS -DHAVE_CONFIG_H -Wall -std=c99"
|
||||
CFLAGS="$CFLAGS -Wall -std=c99"
|
||||
|
||||
|
||||
# If debugging is enabled then make warnings errors
|
||||
|
||||
@@ -232,7 +232,7 @@ linux-alpha:
|
||||
CFLAGS="$(CFLAGS) $(CPPFLAGS) -DLINUX -DOSS -DHAVE_TERMIOS -Wall -O2 \
|
||||
-fomit-frame-pointer -funroll-all-loops \
|
||||
-finline-functions -ffast-math \
|
||||
-Wall -O6 -DUSE_MMAP" \
|
||||
-Wall -O6 -DHAVE_MMAP" \
|
||||
mpg123-make
|
||||
|
||||
linux-alpha-esd:
|
||||
@@ -242,7 +242,7 @@ linux-alpha-esd:
|
||||
CFLAGS="$(CFLAGS) $(CPPFLAGS) -DLINUX -DOSS -DHAVE_TERMIOS -Wall -O2 \
|
||||
-fomit-frame-pointer -funroll-all-loops \
|
||||
-finline-functions -ffast-math \
|
||||
-Wall -O6 -DUSE_MMAP" \
|
||||
-Wall -O6 -DHAVE_MMAP" \
|
||||
mpg123-make
|
||||
|
||||
#linux-ppc:
|
||||
@@ -286,7 +286,7 @@ linux-ppc-esd:
|
||||
linux-sparc:
|
||||
$(MAKE) CC=gcc \
|
||||
OBJECTS='decode.o dct64.o audio_sun.o term.o' \
|
||||
CFLAGS="$(CFLAGS) $(CPPFLAGS) -DREAL_IS_FLOAT -DUSE_MMAP -DSPARCLINUX -Wall -O2 \
|
||||
CFLAGS="$(CFLAGS) $(CPPFLAGS) -DREAL_IS_FLOAT -DHAVE_MMAP -DSPARCLINUX -Wall -O2 \
|
||||
-DHAVE_TERMIOS \
|
||||
-fomit-frame-pointer -funroll-all-loops \
|
||||
-finline-functions -ffast-math" \
|
||||
@@ -363,7 +363,7 @@ freebsd:
|
||||
CFLAGS="$(CFLAGS) $(CPPFLAGS) -Wall -ansi -pedantic -O4 -mcpu=i486 -fomit-frame-pointer \
|
||||
-funroll-all-loops -ffast-math -DROT_I386 \
|
||||
-DREAD_MMAP \
|
||||
-DI386_ASSEM -DREAL_IS_FLOAT -DUSE_MMAP -DOSS" \
|
||||
-DI386_ASSEM -DREAL_IS_FLOAT -DHAVE_MMAP -DOSS" \
|
||||
mpg123-make
|
||||
|
||||
freebsd-esd:
|
||||
@@ -373,7 +373,7 @@ freebsd-esd:
|
||||
CFLAGS="$(CFLAGS) $(CPPFLAGS) -Wall -ansi -pedantic -O4 -mcpu=i486 -fomit-frame-pointer \
|
||||
-funroll-all-loops -ffast-math -DROT_I386 \
|
||||
-DREAD_MMAP \
|
||||
-DI386_ASSEM -DREAL_IS_FLOAT -DUSE_MMAP -DOSS \
|
||||
-DI386_ASSEM -DREAL_IS_FLOAT -DHAVE_MMAP -DOSS \
|
||||
-I/usr/local/include -L/usr/local/lib" \
|
||||
mpg123-make
|
||||
|
||||
@@ -384,7 +384,7 @@ freebsd-frontend:
|
||||
CFLAGS="$(CFLAGS) $(CPPFLAGS) -Wall -ansi -pedantic -O4 -mcpu=i486 -fomit-frame-pointer \
|
||||
-funroll-all-loops -ffast-math -DROT_I386 \
|
||||
-DFRONTEND \
|
||||
-DI386_ASSEM -DREAL_IS_FLOAT -DUSE_MMAP -DOSS" \
|
||||
-DI386_ASSEM -DREAL_IS_FLOAT -DHAVE_MMAP -DOSS" \
|
||||
$(FRONTEND)
|
||||
|
||||
|
||||
@@ -397,14 +397,14 @@ solaris-pure:
|
||||
LDFLAGS="$(LDFLAGS) -lsocket -lnsl" \
|
||||
OBJECTS='decode.o dct64.o audio_sun.o term.o' \
|
||||
CFLAGS="$(CFLAGS) $(CPPFLAGS) -fast -native -xO4 -DSOLARIS -DHAVE_TERMIOS \
|
||||
-DUSE_MMAP" \
|
||||
-DHAVE_MMAP" \
|
||||
mpg123-make
|
||||
|
||||
solaris-ccscc:
|
||||
$(MAKE) CC=/usr/ccs/bin/ucbcc LDFLAGS="$(LDFLAGS) -lsocket -lnsl" \
|
||||
OBJECTS='decode.o dct64.o audio_sun.o term.o' \
|
||||
CFLAGS="$(CFLAGS) $(CPPFLAGS) -fast -native -xO4 -DSOLARIS \
|
||||
-DUSE_MMAP" \
|
||||
-DHAVE_MMAP" \
|
||||
mpg123-make
|
||||
|
||||
# common solaris compile entries
|
||||
@@ -412,14 +412,14 @@ solaris:
|
||||
$(MAKE) CC=cc LDFLAGS="$(LDFLAGS) -lsocket -lnsl" \
|
||||
OBJECTS='decode.o dct64.o audio_sun.o term.o' \
|
||||
CFLAGS="$(CFLAGS)-fast -native -xO4 -DSOLARIS \
|
||||
-DUSE_MMAP -DHAVE_TERMIOS" \
|
||||
-DHAVE_MMAP -DHAVE_TERMIOS" \
|
||||
mpg123-make
|
||||
|
||||
solaris-gcc-profile:
|
||||
$(MAKE) CC='gcc' \
|
||||
LDFLAGS="$(LDFLAGS) -lsocket -lnsl -pg" \
|
||||
OBJECTS='decode.o dct64.o audio_sun.o' \
|
||||
CFLAGS="$(CFLAGS) $(CPPFLAGS) -g -pg -O2 -Wall -DSOLARIS -DREAL_IS_FLOAT -DUSE_MMAP \
|
||||
CFLAGS="$(CFLAGS) $(CPPFLAGS) -g -pg -O2 -Wall -DSOLARIS -DREAL_IS_FLOAT -DHAVE_MMAP \
|
||||
-DREAD_MMAP \
|
||||
-funroll-all-loops -finline-functions" \
|
||||
mpg123-make
|
||||
@@ -428,7 +428,7 @@ solaris-gcc:
|
||||
$(MAKE) CC=gcc \
|
||||
LDFLAGS="$(LDFLAGS) -lsocket -lnsl" \
|
||||
OBJECTS='decode.o dct64.o audio_sun.o term.o' \
|
||||
CFLAGS="$(CFLAGS) $(CPPFLAGS) -O2 -Wall -pedantic -DSOLARIS -DREAL_IS_FLOAT -DUSE_MMAP \
|
||||
CFLAGS="$(CFLAGS) $(CPPFLAGS) -O2 -Wall -pedantic -DSOLARIS -DREAL_IS_FLOAT -DHAVE_MMAP \
|
||||
-DREAD_MMAP -DHAVE_TERMIOS \
|
||||
-funroll-all-loops -finline-functions" \
|
||||
mpg123-make
|
||||
@@ -437,7 +437,7 @@ solaris-gcc-esd:
|
||||
$(MAKE) CC=gcc LDFLAGS="$(LDFLAGS) -lsocket -lnsl" \
|
||||
AUDIO_LIB='-lesd -lresolv' \
|
||||
OBJECTS='decode.o dct64.o audio_esd.o' \
|
||||
CFLAGS="$(CFLAGS) $(CPPFLAGS) -O2 -Wall -DSOLARIS -DREAL_IS_FLOAT -DUSE_MMAP \
|
||||
CFLAGS="$(CFLAGS) $(CPPFLAGS) -O2 -Wall -DSOLARIS -DREAL_IS_FLOAT -DHAVE_MMAP \
|
||||
-DREAD_MMAP \
|
||||
-funroll-all-loops -finline-functions" \
|
||||
mpg123-make
|
||||
@@ -446,7 +446,7 @@ solaris-x86-gcc-oss:
|
||||
$(MAKE) CC=gcc LDFLAGS="$(LDFLAGS) -lsocket -lnsl" \
|
||||
OBJECTS='decode_i386.o dct64_i386.o $(PENTIUM_DECODE).o \
|
||||
audio_oss.o' \
|
||||
CFLAGS="$(CFLAGS) $(CPPFLAGS) -DI386_ASSEM -DREAL_IS_FLOAT -DPENTIUM_OPT -DUSE_MMAP \
|
||||
CFLAGS="$(CFLAGS) $(CPPFLAGS) -DI386_ASSEM -DREAL_IS_FLOAT -DPENTIUM_OPT -DHAVE_MMAP \
|
||||
-DREAD_MMAP -DOSS \
|
||||
-Wall -O2 -mcpu=i486 \
|
||||
-funroll-all-loops -finline-functions" \
|
||||
@@ -457,7 +457,7 @@ solaris-gcc-nas:
|
||||
AUDIO_LIB='-L/usr/openwin/lib -laudio -lXau'\
|
||||
OBJECTS='decode.o dct64.o audio_nas.o' \
|
||||
CFLAGS="$(CFLAGS) $(CPPFLAGS) -O2 -I/usr/openwin/include -Wall \
|
||||
-DSOLARIS -DREAL_IS_FLOAT -DUSE_MMAP \
|
||||
-DSOLARIS -DREAL_IS_FLOAT -DHAVE_MMAP \
|
||||
-DREAD_MMAP -DNAS \
|
||||
-funroll-all-loops -finline-functions" \
|
||||
mpg123-make
|
||||
@@ -465,7 +465,7 @@ solaris-gcc-nas:
|
||||
sunos:
|
||||
$(MAKE) CC=gcc \
|
||||
OBJECTS='decode.o dct64.o audio_sun.o' \
|
||||
CFLAGS="$(CFLAGS) $(CPPFLAGS) -O2 -DSUNOS -DREAL_IS_FLOAT -DUSE_MMAP \
|
||||
CFLAGS="$(CFLAGS) $(CPPFLAGS) -O2 -DSUNOS -DREAL_IS_FLOAT -DHAVE_MMAP \
|
||||
-funroll-loops" \
|
||||
mpg123-make
|
||||
|
||||
@@ -491,24 +491,24 @@ hpux-gcc:
|
||||
sgi:
|
||||
$(MAKE) CC=cc \
|
||||
OBJECTS='decode.o dct64.o audio_sgi.o' AUDIO_LIB=-laudio \
|
||||
CFLAGS="$(CFLAGS) $(CPPFLAGS) -O2 -DSGI -DREAL_IS_FLOAT -DUSE_MMAP' \
|
||||
CFLAGS="$(CFLAGS) $(CPPFLAGS) -O2 -DSGI -DREAL_IS_FLOAT -DHAVE_MMAP' \
|
||||
mpg123-make
|
||||
|
||||
sgi-gcc:
|
||||
$(MAKE) CC=gcc \
|
||||
OBJECTS='decode.o dct64.o audio_sgi.o' AUDIO_LIB=-laudio \
|
||||
CFLAGS="$(CFLAGS) $(CPPFLAGS) -O2 -DSGI -DREAL_IS_FLOAT -DUSE_MMAP" \
|
||||
CFLAGS="$(CFLAGS) $(CPPFLAGS) -O2 -DSGI -DREAL_IS_FLOAT -DHAVE_MMAP" \
|
||||
mpg123-make
|
||||
|
||||
dec:
|
||||
$(MAKE) CC=cc OBJECTS='decode.o dct64.o audio_dummy.o' \
|
||||
CFLAGS="$(CFLAGS) $(CPPFLAGS) -std1 -warnprotos -O4 -DUSE_MMAP" \
|
||||
CFLAGS="$(CFLAGS) $(CPPFLAGS) -std1 -warnprotos -O4 -DHAVE_MMAP" \
|
||||
LDFLAGS="$(LDFLAGS) -lrt" \
|
||||
mpg123-make
|
||||
|
||||
dec-debug:
|
||||
$(MAKE) CC=cc OBJECTS='decode.o dct64.o audio_dummy.o' \
|
||||
CFLAGS="$(CFLAGS) $(CPPFLAGS) -g3 -std1 -warnprotos -O4 -DUSE_MMAP" \
|
||||
CFLAGS="$(CFLAGS) $(CPPFLAGS) -g3 -std1 -warnprotos -O4 -DHAVE_MMAP" \
|
||||
LDFLAGS="$(LDFLAGS) -lrt" \
|
||||
mpg123-make
|
||||
|
||||
@@ -516,7 +516,7 @@ dec-nas:
|
||||
$(MAKE) CC=cc LDFLAGS="$(LDFLAGS) -L/usr/X11R6/lib" \
|
||||
AUDIO_LIB='-laudio -lXau -ldnet_stub'\
|
||||
OBJECTS='decode.o dct64.o audio_nas.o' \
|
||||
CFLAGS="$(CFLAGS) $(CPPFLAGS) -I/usr/X11R6/include -std1 -warnprotos -O4 -DUSE_MMAP" \
|
||||
CFLAGS="$(CFLAGS) $(CPPFLAGS) -I/usr/X11R6/include -std1 -warnprotos -O4 -DHAVE_MMAP" \
|
||||
mpg123-make
|
||||
|
||||
ultrix:
|
||||
@@ -526,14 +526,14 @@ ultrix:
|
||||
|
||||
aix-gcc:
|
||||
$(MAKE) CC=gcc OBJECTS='decode.o dct64.o audio_aix.o' \
|
||||
CFLAGS="$(CFLAGS) $(CPPFLAGS) -DAIX -Wall -O6 -DUSE_MMAP -DREAD_MMAP -DREAL_IS_FLOAT \
|
||||
CFLAGS="$(CFLAGS) $(CPPFLAGS) -DAIX -Wall -O6 -DHAVE_MMAP -DREAD_MMAP -DREAL_IS_FLOAT \
|
||||
-fomit-frame-pointer -funroll-all-loops \
|
||||
-finline-functions -ffast-math" \
|
||||
mpg123-make
|
||||
|
||||
aix-xlc:
|
||||
$(MAKE) OBJECTS='decode.o dct64.o audio_aix.o' \
|
||||
CFLAGS="$(CFLAGS) $(CPPFLAGS) -O3 -qstrict -qcpluscmt -DAIX -DUSE_MMAP \
|
||||
CFLAGS="$(CFLAGS) $(CPPFLAGS) -O3 -qstrict -qcpluscmt -DAIX -DHAVE_MMAP \
|
||||
-DREAD_MMAP" \
|
||||
mpg123-make
|
||||
|
||||
@@ -543,7 +543,7 @@ aix-tk3play:
|
||||
aix-frontend:
|
||||
$(MAKE) OBJECTS='decode.o dct64.o audio_aix.o \
|
||||
control_sajber.o control_tk3play.o' \
|
||||
CFLAGS="$(CFLAGS) $(CPPFLAGS) -DAIX -Wall -O6 -DUSE_MMAP -DFRONTEND \
|
||||
CFLAGS="$(CFLAGS) $(CPPFLAGS) -DAIX -Wall -O6 -DHAVE_MMAP -DFRONTEND \
|
||||
-fomit-frame-pointer -funroll-all-loops \
|
||||
-finline-functions -ffast-math" \
|
||||
$(FRONTEND)
|
||||
@@ -562,7 +562,7 @@ netbsd:
|
||||
OBJECTS='decode.o dct64.o audio_sun.o' \
|
||||
CFLAGS="$(CFLAGS) $(CPPFLAGS) -Wall -ansi -pedantic -O3 -fomit-frame-pointer \
|
||||
-funroll-all-loops -ffast-math \
|
||||
-DREAL_IS_FLOAT -DUSE_MMAP -DNETBSD -DNO_RT" \
|
||||
-DREAL_IS_FLOAT -DHAVE_MMAP -DNETBSD -DNO_RT" \
|
||||
mpg123-make
|
||||
|
||||
netbsd-x86:
|
||||
@@ -570,7 +570,7 @@ netbsd-x86:
|
||||
OBJECTS='decode_i386.o dct64_i386.o audio_sun.o' \
|
||||
CFLAGS="$(CFLAGS) $(CPPFLAGS) -Wall -ansi -pedantic -O4 -mcpu=i486 -fomit-frame-pointer \
|
||||
-funroll-all-loops -ffast-math -DROT_I386 \
|
||||
-DI386_ASSEM -DREAL_IS_FLOAT -DUSE_MMAP -DNETBSD -DNO_RT" \
|
||||
-DI386_ASSEM -DREAL_IS_FLOAT -DHAVE_MMAP -DNETBSD -DNO_RT" \
|
||||
mpg123-make
|
||||
|
||||
netbsd-rt:
|
||||
@@ -578,7 +578,7 @@ netbsd-rt:
|
||||
OBJECTS='decode.o dct64.o audio_sun.o' \
|
||||
CFLAGS="$(CFLAGS) $(CPPFLAGS) -Wall -ansi -pedantic -O3 -fomit-frame-pointer \
|
||||
-funroll-all-loops -ffast-math \
|
||||
-DREAL_IS_FLOAT -DUSE_MMAP -DNETBSD" \
|
||||
-DREAL_IS_FLOAT -DHAVE_MMAP -DNETBSD" \
|
||||
mpg123-make
|
||||
|
||||
netbsd-x86-rt:
|
||||
@@ -586,7 +586,7 @@ netbsd-x86-rt:
|
||||
OBJECTS='decode_i386.o dct64_i386.o audio_sun.o' \
|
||||
CFLAGS="$(CFLAGS) $(CPPFLAGS) -Wall -ansi -pedantic -O4 -mcpu=i486 -fomit-frame-pointer \
|
||||
-funroll-all-loops -ffast-math -DROT_I386 \
|
||||
-DI386_ASSEM -DREAL_IS_FLOAT -DUSE_MMAP -DNETBSD" \
|
||||
-DI386_ASSEM -DREAL_IS_FLOAT -DHAVE_MMAP -DNETBSD" \
|
||||
mpg123-make
|
||||
|
||||
bsdos:
|
||||
@@ -595,7 +595,7 @@ bsdos:
|
||||
audio_oss.o' \
|
||||
CFLAGS="$(CFLAGS) $(CPPFLAGS) -Wall -O4 -mcpu=i486 -fomit-frame-pointer \
|
||||
-funroll-all-loops -ffast-math -DROT_I386 \
|
||||
-DI386_ASSEM -DREAL_IS_FLOAT -DUSE_MMAP -DOSS \
|
||||
-DI386_ASSEM -DREAL_IS_FLOAT -DHAVE_MMAP -DOSS \
|
||||
-DDONT_CATCH_SIGNALS" \
|
||||
mpg123-make
|
||||
|
||||
@@ -604,7 +604,7 @@ bsdos4:
|
||||
OBJECTS='decode_i386.o dct64_i386.o audio_oss.o' \
|
||||
CFLAGS="$(CFLAGS) $(CPPFLAGS) -Wall -O4 -mcpu=i486 -fomit-frame-pointer \
|
||||
-funroll-all-loops -ffast-math -DROT_I386 \
|
||||
-DI386_ASSEM -DREAL_IS_FLOAT -DUSE_MMAP -DOSS \
|
||||
-DI386_ASSEM -DREAL_IS_FLOAT -DHAVE_MMAP -DOSS \
|
||||
-DREAD_MMAP -DDONT_CATCH_SIGNALS" \
|
||||
mpg123-make
|
||||
|
||||
@@ -615,7 +615,7 @@ bsdos-nas:
|
||||
audio_nas.o' \
|
||||
CFLAGS="$(CFLAGS) $(CPPFLAGS) -Wall -O4 -mcpu=i486 -fomit-frame-pointer \
|
||||
-funroll-all-loops -ffast-math -DROT_I386 \
|
||||
-DI386_ASSEM -DREAL_IS_FLOAT -DUSE_MMAP -DOSS \
|
||||
-DI386_ASSEM -DREAL_IS_FLOAT -DHAVE_MMAP -DOSS \
|
||||
-DDONT_CATCH_SIGNALS -DNAS" \
|
||||
mpg123-make
|
||||
|
||||
|
||||
24
src/audio.c
24
src/audio.c
@@ -3,20 +3,12 @@
|
||||
|
||||
void audio_info_struct_init(struct audio_info_struct *ai)
|
||||
{
|
||||
#ifdef AUDIO_USES_FD
|
||||
ai->fn = -1;
|
||||
#endif
|
||||
#ifdef SGI
|
||||
#if 0
|
||||
ALconfig config;
|
||||
ALport port;
|
||||
#endif
|
||||
#endif
|
||||
ai->rate = -1;
|
||||
ai->gain = -1;
|
||||
ai->output = -1;
|
||||
#ifdef ALSA
|
||||
ai->handle = NULL;
|
||||
#ifdef ALSA
|
||||
ai->alsa_format.format = -1;
|
||||
ai->alsa_format.rate = -1;
|
||||
ai->alsa_format.channels = -1;
|
||||
@@ -26,6 +18,20 @@ void audio_info_struct_init(struct audio_info_struct *ai)
|
||||
ai->format = -1;
|
||||
}
|
||||
|
||||
|
||||
void audio_info_struct_dump(struct audio_info_struct *ai)
|
||||
{
|
||||
fprintf(stderr, "ai->fn=%d\n", ai->fn);
|
||||
fprintf(stderr, "ai->handle=%p\n", ai->handle);
|
||||
fprintf(stderr, "ai->rate=%ld\n", ai->rate);
|
||||
fprintf(stderr, "ai->gain=%ld\n", ai->gain);
|
||||
fprintf(stderr, "ai->output=%d\n", ai->output);
|
||||
fprintf(stderr, "ai->device='%s'\n", ai->device);
|
||||
fprintf(stderr, "ai->channels=%d\n", ai->channels);
|
||||
fprintf(stderr, "ai->format=%d\n", ai->format);
|
||||
}
|
||||
|
||||
|
||||
#define NUM_CHANNELS 2
|
||||
#define NUM_ENCODINGS 6
|
||||
#define NUM_RATES 10
|
||||
|
||||
69
src/audio.h
69
src/audio.h
@@ -6,8 +6,16 @@
|
||||
#define AUDIO_OUT_INTERNAL_SPEAKER 0x02
|
||||
#define AUDIO_OUT_LINE_OUT 0x04
|
||||
|
||||
enum { DECODE_TEST, DECODE_AUDIO, DECODE_FILE, DECODE_BUFFER, DECODE_WAV,
|
||||
DECODE_AU,DECODE_CDR,DECODE_AUDIOFILE };
|
||||
enum {
|
||||
DECODE_TEST,
|
||||
DECODE_AUDIO,
|
||||
DECODE_FILE,
|
||||
DECODE_BUFFER,
|
||||
DECODE_WAV,
|
||||
DECODE_AU,
|
||||
DECODE_CDR,
|
||||
DECODE_AUDIOFILE
|
||||
};
|
||||
|
||||
#define AUDIO_FORMAT_MASK 0x100
|
||||
#define AUDIO_FORMAT_16 0x100
|
||||
@@ -23,44 +31,21 @@ enum { DECODE_TEST, DECODE_AUDIO, DECODE_FILE, DECODE_BUFFER, DECODE_WAV,
|
||||
/* 3% rate tolerance */
|
||||
#define AUDIO_RATE_TOLERANCE 3
|
||||
|
||||
#if 0
|
||||
#if defined(HPUX) || defined(SUNOS) || defined(SOLARIS) || defined(OSS) || defined(__NetBSD__) || defined(SPARCLINUX) || defined(__FreeBSD__)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define AUDIO_USES_FD
|
||||
|
||||
#ifdef SGI
|
||||
/* #include <audio.h> */
|
||||
#include <dmedia/audio.h>
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef ALSA
|
||||
#include <sys/asoundlib.h>
|
||||
#endif
|
||||
|
||||
struct audio_info_struct
|
||||
{
|
||||
#ifdef AUDIO_USES_FD
|
||||
int fn; /* filenumber */
|
||||
#endif
|
||||
#ifdef SGI
|
||||
ALconfig config;
|
||||
ALport port;
|
||||
#endif
|
||||
void *handle; /* driver specific pointer */
|
||||
|
||||
long rate;
|
||||
long gain;
|
||||
int output;
|
||||
#ifdef ALSA
|
||||
void *handle;
|
||||
snd_pcm_format_t alsa_format;
|
||||
#endif
|
||||
|
||||
char *device;
|
||||
int channels;
|
||||
int format;
|
||||
int private1;
|
||||
void *private2;
|
||||
|
||||
};
|
||||
|
||||
struct audio_name {
|
||||
@@ -69,21 +54,21 @@ struct audio_name {
|
||||
char *sname;
|
||||
};
|
||||
|
||||
|
||||
/* ------ Declarations from "audio.c" ------ */
|
||||
|
||||
extern void audio_info_struct_init(struct audio_info_struct *);
|
||||
extern void audio_info_struct_dump(struct audio_info_struct *ai);
|
||||
extern void audio_capabilities(struct audio_info_struct *);
|
||||
extern void audio_fit_capabilities(struct audio_info_struct *ai,int c,int r);
|
||||
|
||||
extern char *audio_encoding_name(int format);
|
||||
|
||||
extern int audio_play_samples(struct audio_info_struct *,unsigned char *,int);
|
||||
extern int audio_open(struct audio_info_struct *);
|
||||
extern int audio_reset_parameters(struct audio_info_struct *);
|
||||
extern int audio_rate_best_match(struct audio_info_struct *ai);
|
||||
extern int audio_set_rate(struct audio_info_struct *);
|
||||
extern int audio_set_format(struct audio_info_struct *);
|
||||
extern int audio_get_formats(struct audio_info_struct *);
|
||||
extern int audio_set_channels(struct audio_info_struct *);
|
||||
extern int audio_write_sample(struct audio_info_struct *,short *,int);
|
||||
extern int audio_close(struct audio_info_struct *);
|
||||
extern void audio_info_struct_init(struct audio_info_struct *);
|
||||
extern void audio_queueflush(struct audio_info_struct *ai);
|
||||
|
||||
/* ------ Declarations from "audio_*.c" ------ */
|
||||
|
||||
extern int audio_open(struct audio_info_struct *);
|
||||
extern int audio_get_formats(struct audio_info_struct *);
|
||||
extern int audio_play_samples(struct audio_info_struct *, unsigned char *,int);
|
||||
extern void audio_queueflush(struct audio_info_struct *ai);
|
||||
extern int audio_close(struct audio_info_struct *);
|
||||
|
||||
|
||||
@@ -30,6 +30,30 @@
|
||||
/* #define AUDIO_BSIZE AUDIO_IGNORE */
|
||||
#define AUDIO_BSIZE 200
|
||||
|
||||
int audio_rate_best_match(struct audio_info_struct *ai)
|
||||
{
|
||||
static long valid [ ] = { 5510, 6620, 8000, 9600, 11025, 16000, 18900,
|
||||
22050, 27420, 32000, 33075, 37800, 44100, 48000, 0 };
|
||||
int i = 0;
|
||||
long best = 8000;
|
||||
|
||||
if(!ai || ai->fn < 0 || ai->rate < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
while (valid [i])
|
||||
{
|
||||
if (abs(valid[i] - ai->rate) < abs(best - ai->rate))
|
||||
{
|
||||
best = valid [i];
|
||||
}
|
||||
i = i + 1;
|
||||
}
|
||||
|
||||
ai->rate = best;
|
||||
return best;
|
||||
}
|
||||
|
||||
|
||||
int audio_open(struct audio_info_struct *ai)
|
||||
{
|
||||
@@ -182,45 +206,6 @@ int audio_reset_parameters(struct audio_info_struct *ai)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int audio_rate_best_match(struct audio_info_struct *ai)
|
||||
{
|
||||
static long valid [ ] = { 5510, 6620, 8000, 9600, 11025, 16000, 18900,
|
||||
22050, 27420, 32000, 33075, 37800, 44100, 48000, 0 };
|
||||
int i = 0;
|
||||
long best = 8000;
|
||||
|
||||
if(!ai || ai->fn < 0 || ai->rate < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
while (valid [i])
|
||||
{
|
||||
if (abs(valid[i] - ai->rate) < abs(best - ai->rate))
|
||||
{
|
||||
best = valid [i];
|
||||
}
|
||||
i = i + 1;
|
||||
}
|
||||
|
||||
ai->rate = best;
|
||||
return best;
|
||||
}
|
||||
|
||||
int audio_set_rate(struct audio_info_struct *ai)
|
||||
{
|
||||
return audio_reset_parameters(ai);
|
||||
}
|
||||
|
||||
int audio_set_channels(struct audio_info_struct *ai)
|
||||
{
|
||||
return audio_reset_parameters(ai);
|
||||
}
|
||||
|
||||
int audio_set_format(struct audio_info_struct *ai)
|
||||
{
|
||||
return audio_reset_parameters(ai);
|
||||
}
|
||||
|
||||
int audio_get_formats(struct audio_info_struct *ai)
|
||||
{
|
||||
/* ULTIMEDIA DOCUMENTATION SAYS:
|
||||
@@ -285,3 +270,8 @@ int audio_close(struct audio_info_struct *ai)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void audio_queueflush(struct audio_info_struct *ai)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -175,23 +175,15 @@ inline int audio_play_samples(struct audio_info_struct *ai,unsigned char *buf,in
|
||||
|
||||
/**************************************************************************/
|
||||
|
||||
/* unused */
|
||||
int audio_set_rate(struct audio_info_struct *ai) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
|
||||
/* unused */
|
||||
int audio_set_channels(struct audio_info_struct *ai) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int audio_get_formats(struct audio_info_struct *ai)
|
||||
{
|
||||
return AUDIO_FORMAT_SIGNED_16;
|
||||
}
|
||||
|
||||
void audio_queueflush(struct audio_info_struct *ai)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
* T H A T ' S A L L F O L K S
|
||||
|
||||
143
src/audio_alsa.c
143
src/audio_alsa.c
@@ -30,6 +30,9 @@
|
||||
#define SND_PCM_FMT_U16_NE SND_PCM_FMT_U16_BE
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
int audio_open(struct audio_info_struct *ai)
|
||||
{
|
||||
int err;
|
||||
@@ -38,6 +41,7 @@ int audio_open(struct audio_info_struct *ai)
|
||||
|
||||
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);
|
||||
@@ -60,21 +64,62 @@ int audio_open(struct audio_info_struct *ai)
|
||||
}
|
||||
}
|
||||
|
||||
// Open the ALSA device
|
||||
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;
|
||||
}
|
||||
|
||||
// Now configure the device
|
||||
audio_set_playback_format( ai )
|
||||
audio_set_playback_params( ai );
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static void audio_set_playback_format(struct audio_info_struct *ai)
|
||||
{
|
||||
snd_pcm_format_t alsa_format;
|
||||
int err;
|
||||
|
||||
alsa_format.rat = ai->rate;
|
||||
alsa_format.channels = ai->channels;
|
||||
|
||||
switch(ai->format)
|
||||
{
|
||||
case AUDIO_FORMAT_SIGNED_16:
|
||||
default:
|
||||
ai->alsa_format.format=SND_PCM_SFMT_S16_NE;
|
||||
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_NE;
|
||||
break;
|
||||
}
|
||||
|
||||
if((err=snd_pcm_playback_format(ai->handle, &alsa_format)) < 0 )
|
||||
{
|
||||
fprintf(stderr, "snd_pcm_playback_format failed: %s\n", snd_strerror(err));
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void audio_set_playback_params(struct audio_info_struct *ai)
|
||||
{
|
||||
int err;
|
||||
@@ -101,91 +146,8 @@ static void audio_set_playback_params(struct audio_info_struct *ai)
|
||||
}
|
||||
}
|
||||
|
||||
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_NE;
|
||||
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_NE;
|
||||
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)
|
||||
{
|
||||
@@ -236,3 +198,8 @@ int audio_close(struct audio_info_struct *ai)
|
||||
ret = snd_pcm_close(ai->handle);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void audio_queueflush(struct audio_info_struct *ai)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -7,31 +7,6 @@ int audio_open(struct audio_info_struct *ai)
|
||||
return -1;
|
||||
}
|
||||
|
||||
int audio_reset_parameters(struct audio_info_struct *ai)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int audio_rate_best_match(struct audio_info_struct *ai)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int audio_set_rate(struct audio_info_struct *ai)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int audio_set_channels(struct audio_info_struct *ai)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int audio_set_format(struct audio_info_struct *ai)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int audio_get_formats(struct audio_info_struct *ai)
|
||||
{
|
||||
return AUDIO_FORMAT_SIGNED_16;
|
||||
@@ -46,3 +21,7 @@ int audio_close(struct audio_info_struct *ai)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void audio_queueflush(struct audio_info_struct *ai)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -76,38 +76,10 @@ int audio_open(struct audio_info_struct *ai)
|
||||
else if (ai->rate > esd_rate)
|
||||
return -1;
|
||||
|
||||
ai->fn = esd_play_stream_fallback(format, ai->rate, esdserver, "mpg123");
|
||||
ai->fn = esd_play_stream_fallback(format, ai->rate, ai->device, "mpg123");
|
||||
return (ai->fn);
|
||||
}
|
||||
|
||||
int audio_reset_parameters(struct audio_info_struct *ai)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int audio_rate_best_match(struct audio_info_struct *ai)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int audio_set_rate(struct audio_info_struct *ai)
|
||||
{
|
||||
audio_close(ai);
|
||||
return audio_open(ai);
|
||||
}
|
||||
|
||||
int audio_set_channels(struct audio_info_struct *ai)
|
||||
{
|
||||
audio_close(ai);
|
||||
return audio_open(ai);
|
||||
}
|
||||
|
||||
int audio_set_format(struct audio_info_struct *ai)
|
||||
{
|
||||
audio_close(ai);
|
||||
return audio_open(ai);
|
||||
}
|
||||
|
||||
int audio_get_formats(struct audio_info_struct *ai)
|
||||
{
|
||||
if (0 < ai->channels && ai->channels <= esd_channels
|
||||
|
||||
124
src/audio_hp.c
124
src/audio_hp.c
@@ -8,6 +8,65 @@
|
||||
|
||||
#include <sys/audio.h>
|
||||
|
||||
|
||||
|
||||
static int audio_set_rate(struct audio_info_struct *ai)
|
||||
{
|
||||
if(ai->rate >= 0)
|
||||
return ioctl(ai->fn,AUDIO_SET_SAMPLE_RATE,ai->rate);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int audio_set_channels(struct audio_info_struct *ai)
|
||||
{
|
||||
if(ai->channels<0)
|
||||
return 0;
|
||||
return ioctl(ai->fn,AUDIO_SET_CHANNELS,ai->channels);
|
||||
}
|
||||
|
||||
static int audio_set_format(struct audio_info_struct *ai)
|
||||
{
|
||||
int fmt;
|
||||
|
||||
switch(ai->format) {
|
||||
case -1:
|
||||
case AUDIO_FORMAT_SIGNED_16:
|
||||
default:
|
||||
fmt = AUDIO_FORMAT_LINEAR16BIT;
|
||||
break;
|
||||
case AUDIO_FORMAT_UNSIGNED_8:
|
||||
fprintf(stderr,"unsigned 8 bit linear not supported\n");
|
||||
return -1;
|
||||
case AUDIO_FORMAT_SIGNED_8:
|
||||
fprintf(stderr,"signed 8 bit linear not supported\n");
|
||||
return -1;
|
||||
case AUDIO_FORMAT_ALAW_8:
|
||||
fmt = AUDIO_FORMAT_ALAW;
|
||||
break;
|
||||
case AUDIO_FORMAT_ULAW_8:
|
||||
fmt = AUDIO_FORMAT_ULAW;
|
||||
break;
|
||||
}
|
||||
return ioctl(ai->fn,AUDIO_SET_DATA_FORMAT,fmt);
|
||||
}
|
||||
|
||||
static int audio_get_formats(struct audio_info_struct *ai)
|
||||
{
|
||||
return AUDIO_FORMAT_SIGNED_16;
|
||||
}
|
||||
|
||||
static int audio_reset_parameters(struct audio_info_struct *ai)
|
||||
{
|
||||
int ret;
|
||||
ret = audio_set_format(ai);
|
||||
if(ret >= 0)
|
||||
ret = audio_set_channels(ai);
|
||||
if(ret >= 0)
|
||||
ret = audio_set_rate(ai);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int audio_open(struct audio_info_struct *ai)
|
||||
{
|
||||
struct audio_describe ades;
|
||||
@@ -72,66 +131,6 @@ int audio_open(struct audio_info_struct *ai)
|
||||
return ai->fn;
|
||||
}
|
||||
|
||||
int audio_reset_parameters(struct audio_info_struct *ai)
|
||||
{
|
||||
int ret;
|
||||
ret = audio_set_format(ai);
|
||||
if(ret >= 0)
|
||||
ret = audio_set_channels(ai);
|
||||
if(ret >= 0)
|
||||
ret = audio_set_rate(ai);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int audio_rate_best_match(struct audio_info_struct *ai)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int audio_set_rate(struct audio_info_struct *ai)
|
||||
{
|
||||
if(ai->rate >= 0)
|
||||
return ioctl(ai->fn,AUDIO_SET_SAMPLE_RATE,ai->rate);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int audio_set_channels(struct audio_info_struct *ai)
|
||||
{
|
||||
if(ai->channels<0)
|
||||
return 0;
|
||||
return ioctl(ai->fn,AUDIO_SET_CHANNELS,ai->channels);
|
||||
}
|
||||
|
||||
int audio_set_format(struct audio_info_struct *ai)
|
||||
{
|
||||
int fmt;
|
||||
|
||||
switch(ai->format) {
|
||||
case -1:
|
||||
case AUDIO_FORMAT_SIGNED_16:
|
||||
default:
|
||||
fmt = AUDIO_FORMAT_LINEAR16BIT;
|
||||
break;
|
||||
case AUDIO_FORMAT_UNSIGNED_8:
|
||||
fprintf(stderr,"unsigned 8 bit linear not supported\n");
|
||||
return -1;
|
||||
case AUDIO_FORMAT_SIGNED_8:
|
||||
fprintf(stderr,"signed 8 bit linear not supported\n");
|
||||
return -1;
|
||||
case AUDIO_FORMAT_ALAW_8:
|
||||
fmt = AUDIO_FORMAT_ALAW;
|
||||
break;
|
||||
case AUDIO_FORMAT_ULAW_8:
|
||||
fmt = AUDIO_FORMAT_ULAW;
|
||||
break;
|
||||
}
|
||||
return ioctl(ai->fn,AUDIO_SET_DATA_FORMAT,fmt);
|
||||
}
|
||||
|
||||
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)
|
||||
@@ -144,3 +143,8 @@ int audio_close(struct audio_info_struct *ai)
|
||||
close (ai->fn);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void audio_queueflush(struct audio_info_struct *ai)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -123,7 +123,7 @@ int audio_play_samples(struct audio_info_struct *ai,unsigned char *buf,int len)
|
||||
int res = 0;
|
||||
ao_device *device = (ao_device*)ai->handle;
|
||||
|
||||
res = ao_play(device, buf, len);
|
||||
res = ao_play(device, (char*)buf, len);
|
||||
if (res==0) {
|
||||
fprintf(stderr, "audio_play_samples(): error playing samples\n");
|
||||
return -1;
|
||||
|
||||
@@ -223,7 +223,7 @@ void start(int n)
|
||||
|
||||
int audio_open(struct audio_info_struct *ai)
|
||||
{
|
||||
long size;
|
||||
UInt32 size;
|
||||
AudioStreamBasicDescription format;
|
||||
#if MOSX_USES_SEM
|
||||
char s[10];
|
||||
|
||||
176
src/audio_mint.c
176
src/audio_mint.c
@@ -8,6 +8,93 @@ extern int outburst;
|
||||
|
||||
int real_rate_printed = 0;
|
||||
|
||||
|
||||
|
||||
static int audio_rate_best_match(struct audio_info_struct *ai)
|
||||
{
|
||||
int ret,dsp_rate;
|
||||
|
||||
if(!ai || ai->fn < 0 || ai->rate < 0)
|
||||
return -1;
|
||||
dsp_rate = ai->rate;
|
||||
ret = ioctl(ai->fn,AIOCSSPEED, (void *)dsp_rate);
|
||||
ret = ioctl(ai->fn,AIOCGSPEED,&dsp_rate);
|
||||
if(ret < 0)
|
||||
return ret;
|
||||
ai->rate = dsp_rate;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int audio_set_rate(struct audio_info_struct *ai)
|
||||
{
|
||||
int dsp_rate = ai->rate;
|
||||
|
||||
if(ai->rate >= 0) {
|
||||
int ret, real_rate;
|
||||
ret = ioctl(ai->fn, AIOCSSPEED, (void *)dsp_rate);
|
||||
if (ret >= 0 && !real_rate_printed) {
|
||||
ioctl(ai->fn,AIOCGSPEED,&real_rate);
|
||||
if (real_rate != dsp_rate) {
|
||||
fprintf(stderr, "Replay rate: %d Hz\n", real_rate);
|
||||
real_rate_printed = 1;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int audio_set_channels(struct audio_info_struct *ai)
|
||||
{
|
||||
int chan = ai->channels;
|
||||
|
||||
if(ai->channels < 1)
|
||||
return 0;
|
||||
|
||||
return ioctl(ai->fn, AIOCSCHAN, (void *)chan);
|
||||
}
|
||||
|
||||
static int audio_set_format(struct audio_info_struct *ai)
|
||||
{
|
||||
int fmts;
|
||||
|
||||
if(ai->format == -1)
|
||||
return 0;
|
||||
|
||||
switch(ai->format) {
|
||||
case AUDIO_FORMAT_SIGNED_16:
|
||||
default:
|
||||
fmts = AFMT_S16;
|
||||
break;
|
||||
case AUDIO_FORMAT_UNSIGNED_8:
|
||||
fmts = AFMT_U8;
|
||||
break;
|
||||
case AUDIO_FORMAT_SIGNED_8:
|
||||
fmts = AFMT_S8;
|
||||
break;
|
||||
case AUDIO_FORMAT_ULAW_8:
|
||||
fmts = AFMT_ULAW;
|
||||
break;
|
||||
}
|
||||
return ioctl(ai->fn, AIOCSFMT, (void *)fmts);
|
||||
}
|
||||
|
||||
static int audio_reset_parameters(struct audio_info_struct *ai)
|
||||
{
|
||||
int ret;
|
||||
ret = ioctl(ai->fn,AIOCRESET,NULL);
|
||||
if(ret >= 0)
|
||||
ret = audio_set_format(ai);
|
||||
if(ret >= 0)
|
||||
ret = audio_set_channels(ai);
|
||||
if(ret >= 0)
|
||||
ret = audio_set_rate(ai);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int audio_open(struct audio_info_struct *ai)
|
||||
{
|
||||
if(!ai)
|
||||
@@ -32,90 +119,6 @@ int audio_open(struct audio_info_struct *ai)
|
||||
}
|
||||
return ai->fn;
|
||||
}
|
||||
|
||||
int audio_reset_parameters(struct audio_info_struct *ai)
|
||||
{
|
||||
int ret;
|
||||
ret = ioctl(ai->fn,AIOCRESET,NULL);
|
||||
if(ret >= 0)
|
||||
ret = audio_set_format(ai);
|
||||
if(ret >= 0)
|
||||
ret = audio_set_channels(ai);
|
||||
if(ret >= 0)
|
||||
ret = audio_set_rate(ai);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int audio_rate_best_match(struct audio_info_struct *ai)
|
||||
{
|
||||
int ret,dsp_rate;
|
||||
|
||||
if(!ai || ai->fn < 0 || ai->rate < 0)
|
||||
return -1;
|
||||
dsp_rate = ai->rate;
|
||||
ret = ioctl(ai->fn,AIOCSSPEED, (void *)dsp_rate);
|
||||
ret = ioctl(ai->fn,AIOCGSPEED,&dsp_rate);
|
||||
if(ret < 0)
|
||||
return ret;
|
||||
ai->rate = dsp_rate;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int audio_set_rate(struct audio_info_struct *ai)
|
||||
{
|
||||
int dsp_rate = ai->rate;
|
||||
|
||||
if(ai->rate >= 0) {
|
||||
int ret, real_rate;
|
||||
ret = ioctl(ai->fn, AIOCSSPEED, (void *)dsp_rate);
|
||||
if (ret >= 0 && !real_rate_printed) {
|
||||
ioctl(ai->fn,AIOCGSPEED,&real_rate);
|
||||
if (real_rate != dsp_rate) {
|
||||
fprintf(stderr, "Replay rate: %d Hz\n", real_rate);
|
||||
real_rate_printed = 1;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int audio_set_channels(struct audio_info_struct *ai)
|
||||
{
|
||||
int chan = ai->channels;
|
||||
|
||||
if(ai->channels < 1)
|
||||
return 0;
|
||||
|
||||
return ioctl(ai->fn, AIOCSCHAN, (void *)chan);
|
||||
}
|
||||
|
||||
int audio_set_format(struct audio_info_struct *ai)
|
||||
{
|
||||
int fmts;
|
||||
|
||||
if(ai->format == -1)
|
||||
return 0;
|
||||
|
||||
switch(ai->format) {
|
||||
case AUDIO_FORMAT_SIGNED_16:
|
||||
default:
|
||||
fmts = AFMT_S16;
|
||||
break;
|
||||
case AUDIO_FORMAT_UNSIGNED_8:
|
||||
fmts = AFMT_U8;
|
||||
break;
|
||||
case AUDIO_FORMAT_SIGNED_8:
|
||||
fmts = AFMT_S8;
|
||||
break;
|
||||
case AUDIO_FORMAT_ULAW_8:
|
||||
fmts = AFMT_ULAW;
|
||||
break;
|
||||
}
|
||||
return ioctl(ai->fn, AIOCSFMT, (void *)fmts);
|
||||
}
|
||||
|
||||
int audio_get_formats(struct audio_info_struct *ai)
|
||||
{
|
||||
int ret = 0;
|
||||
@@ -146,3 +149,8 @@ int audio_close(struct audio_info_struct *ai)
|
||||
close (ai->fn);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void audio_queueflush(struct audio_info_struct *ai)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -185,7 +185,7 @@ void nas_createFlow(struct audio_info_struct *ai)
|
||||
info.buf_size = buf_samples * ai->channels * AuSizeofFormat(format);
|
||||
info.buf = (char *) malloc(info.buf_size);
|
||||
if (info.buf == NULL) {
|
||||
fprintf(stderr, "Unable to allocate input/output buffer of size %d\n",
|
||||
fprintf(stderr, "Unable to allocate input/output buffer of size %ld\n",
|
||||
info.buf_size);
|
||||
exit(1);
|
||||
}
|
||||
@@ -230,43 +230,7 @@ int audio_open(struct audio_info_struct *ai)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int audio_reset_parameters(struct audio_info_struct *ai)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = audio_close(ai);
|
||||
if (ret >= 0)
|
||||
ret = audio_open(ai);
|
||||
return ret;
|
||||
}
|
||||
|
||||
extern int audio_rate_best_match(struct audio_info_struct *ai)
|
||||
{
|
||||
int maxRate, minRate;
|
||||
|
||||
if(!ai || ai->rate < 0)
|
||||
return -1;
|
||||
maxRate = AuServerMaxSampleRate(info.aud);
|
||||
minRate = AuServerMinSampleRate(info.aud);
|
||||
if (ai->rate > maxRate) ai->rate = maxRate;
|
||||
if (ai->rate < minRate) ai->rate = minRate;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int audio_set_rate(struct audio_info_struct *ai)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int audio_set_channels(struct audio_info_struct *ai)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int audio_set_format(struct audio_info_struct *ai)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int audio_get_formats(struct audio_info_struct *ai)
|
||||
{
|
||||
@@ -337,3 +301,7 @@ int audio_close(struct audio_info_struct *ai)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void audio_queueflush(struct audio_info_struct *ai)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -575,11 +575,6 @@ int audio_get_formats(struct audio_info_struct *ai)
|
||||
return fmts;
|
||||
}
|
||||
|
||||
int audio_rate_best_match(struct audio_info_struct *ai)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int audio_get_devices(char *info, int deviceid)
|
||||
{
|
||||
char buffer[128];
|
||||
@@ -632,3 +627,6 @@ int audio_get_devices(char *info, int deviceid)
|
||||
}
|
||||
}
|
||||
|
||||
void audio_queueflush(struct audio_info_struct *ai)
|
||||
{
|
||||
}
|
||||
|
||||
260
src/audio_oss.c
260
src/audio_oss.c
@@ -34,6 +34,124 @@
|
||||
|
||||
extern int outburst;
|
||||
|
||||
|
||||
static int audio_rate_best_match(struct audio_info_struct *ai)
|
||||
{
|
||||
int ret,dsp_rate;
|
||||
|
||||
if(!ai || ai->fn < 0 || ai->rate < 0)
|
||||
return -1;
|
||||
dsp_rate = ai->rate;
|
||||
ret = ioctl(ai->fn, SNDCTL_DSP_SPEED,&dsp_rate);
|
||||
if(ret < 0)
|
||||
return ret;
|
||||
ai->rate = dsp_rate;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int audio_set_rate(struct audio_info_struct *ai)
|
||||
{
|
||||
int dsp_rate;
|
||||
int ret = 0;
|
||||
|
||||
if(ai->rate >= 0) {
|
||||
dsp_rate = ai->rate;
|
||||
ret = ioctl(ai->fn, SNDCTL_DSP_SPEED,&dsp_rate);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int audio_set_channels(struct audio_info_struct *ai)
|
||||
{
|
||||
int chan = ai->channels - 1;
|
||||
int ret;
|
||||
|
||||
if(ai->channels < 0)
|
||||
return 0;
|
||||
|
||||
ret = ioctl(ai->fn, SNDCTL_DSP_STEREO, &chan);
|
||||
if(chan != (ai->channels-1)) {
|
||||
return -1;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int audio_set_format(struct audio_info_struct *ai)
|
||||
{
|
||||
int sample_size,fmts;
|
||||
int sf,ret;
|
||||
|
||||
if(ai->format == -1)
|
||||
return 0;
|
||||
|
||||
switch(ai->format) {
|
||||
case AUDIO_FORMAT_SIGNED_16:
|
||||
default:
|
||||
fmts = AFMT_S16_NE;
|
||||
sample_size = 16;
|
||||
break;
|
||||
case AUDIO_FORMAT_UNSIGNED_8:
|
||||
fmts = AFMT_U8;
|
||||
sample_size = 8;
|
||||
break;
|
||||
case AUDIO_FORMAT_SIGNED_8:
|
||||
fmts = AFMT_S8;
|
||||
sample_size = 8;
|
||||
break;
|
||||
case AUDIO_FORMAT_ULAW_8:
|
||||
fmts = AFMT_MU_LAW;
|
||||
sample_size = 8;
|
||||
break;
|
||||
case AUDIO_FORMAT_ALAW_8:
|
||||
fmts = AFMT_A_LAW;
|
||||
sample_size = 8;
|
||||
break;
|
||||
case AUDIO_FORMAT_UNSIGNED_16:
|
||||
fmts = AFMT_U16_NE;
|
||||
break;
|
||||
}
|
||||
#if 0
|
||||
if(ioctl(ai->fn, SNDCTL_DSP_SAMPLESIZE,&sample_size) < 0)
|
||||
return -1;
|
||||
#endif
|
||||
sf = fmts;
|
||||
ret = ioctl(ai->fn, SNDCTL_DSP_SETFMT, &fmts);
|
||||
if(sf != fmts) {
|
||||
return -1;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
static int audio_reset_parameters(struct audio_info_struct *ai)
|
||||
{
|
||||
int ret;
|
||||
ret = ioctl(ai->fn, SNDCTL_DSP_RESET, NULL);
|
||||
if(ret < 0)
|
||||
fprintf(stderr,"Can't reset audio!\n");
|
||||
ret = audio_set_format(ai);
|
||||
if (ret == -1)
|
||||
goto err;
|
||||
ret = audio_set_channels(ai);
|
||||
if (ret == -1)
|
||||
goto err;
|
||||
ret = audio_set_rate(ai);
|
||||
if (ret == -1)
|
||||
goto err;
|
||||
|
||||
/* Careful here. As per OSS v1.1, the next ioctl() commits the format
|
||||
* set above, so we must issue SNDCTL_DSP_RESET before we're allowed to
|
||||
* change it again. [dk]
|
||||
*/
|
||||
if (ioctl(ai->fn, SNDCTL_DSP_GETBLKSIZE, &outburst) == -1 ||
|
||||
outburst > MAXOUTBURST)
|
||||
outburst = MAXOUTBURST;
|
||||
|
||||
err:
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int audio_open(struct audio_info_struct *ai)
|
||||
{
|
||||
char usingdefdev = 0;
|
||||
@@ -90,141 +208,7 @@ int audio_open(struct audio_info_struct *ai)
|
||||
return ai->fn;
|
||||
}
|
||||
|
||||
int audio_reset_parameters(struct audio_info_struct *ai)
|
||||
{
|
||||
int ret;
|
||||
ret = ioctl(ai->fn, SNDCTL_DSP_RESET, NULL);
|
||||
if(ret < 0)
|
||||
fprintf(stderr,"Can't reset audio!\n");
|
||||
ret = audio_set_format(ai);
|
||||
if (ret == -1)
|
||||
goto err;
|
||||
ret = audio_set_channels(ai);
|
||||
if (ret == -1)
|
||||
goto err;
|
||||
ret = audio_set_rate(ai);
|
||||
if (ret == -1)
|
||||
goto err;
|
||||
|
||||
/* Careful here. As per OSS v1.1, the next ioctl() commits the format
|
||||
* set above, so we must issue SNDCTL_DSP_RESET before we're allowed to
|
||||
* change it again. [dk]
|
||||
*/
|
||||
if (ioctl(ai->fn, SNDCTL_DSP_GETBLKSIZE, &outburst) == -1 ||
|
||||
outburst > MAXOUTBURST)
|
||||
outburst = MAXOUTBURST;
|
||||
|
||||
err:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int audio_get_parameters(struct audio_info_struct *ai)
|
||||
{
|
||||
int c=-1;
|
||||
int r=-1;
|
||||
int f=-1;
|
||||
|
||||
if(ioctl(ai->fn,SNDCTL_DSP_SPEED,&r) < 0)
|
||||
return -1;
|
||||
if(ioctl(ai->fn,SNDCTL_DSP_STEREO,&c) < 0)
|
||||
return -1;
|
||||
if(ioctl(ai->fn,SNDCTL_DSP_SETFMT,&f) < 0)
|
||||
return -1;
|
||||
|
||||
ai->rate = r;
|
||||
ai->channels = c + 1;
|
||||
ai->format = f;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int audio_rate_best_match(struct audio_info_struct *ai)
|
||||
{
|
||||
int ret,dsp_rate;
|
||||
|
||||
if(!ai || ai->fn < 0 || ai->rate < 0)
|
||||
return -1;
|
||||
dsp_rate = ai->rate;
|
||||
ret = ioctl(ai->fn, SNDCTL_DSP_SPEED,&dsp_rate);
|
||||
if(ret < 0)
|
||||
return ret;
|
||||
ai->rate = dsp_rate;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int audio_set_rate(struct audio_info_struct *ai)
|
||||
{
|
||||
int dsp_rate;
|
||||
int ret = 0;
|
||||
|
||||
if(ai->rate >= 0) {
|
||||
dsp_rate = ai->rate;
|
||||
ret = ioctl(ai->fn, SNDCTL_DSP_SPEED,&dsp_rate);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int audio_set_channels(struct audio_info_struct *ai)
|
||||
{
|
||||
int chan = ai->channels - 1;
|
||||
int ret;
|
||||
|
||||
if(ai->channels < 0)
|
||||
return 0;
|
||||
|
||||
ret = ioctl(ai->fn, SNDCTL_DSP_STEREO, &chan);
|
||||
if(chan != (ai->channels-1)) {
|
||||
return -1;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int audio_set_format(struct audio_info_struct *ai)
|
||||
{
|
||||
int sample_size,fmts;
|
||||
int sf,ret;
|
||||
|
||||
if(ai->format == -1)
|
||||
return 0;
|
||||
|
||||
switch(ai->format) {
|
||||
case AUDIO_FORMAT_SIGNED_16:
|
||||
default:
|
||||
fmts = AFMT_S16_NE;
|
||||
sample_size = 16;
|
||||
break;
|
||||
case AUDIO_FORMAT_UNSIGNED_8:
|
||||
fmts = AFMT_U8;
|
||||
sample_size = 8;
|
||||
break;
|
||||
case AUDIO_FORMAT_SIGNED_8:
|
||||
fmts = AFMT_S8;
|
||||
sample_size = 8;
|
||||
break;
|
||||
case AUDIO_FORMAT_ULAW_8:
|
||||
fmts = AFMT_MU_LAW;
|
||||
sample_size = 8;
|
||||
break;
|
||||
case AUDIO_FORMAT_ALAW_8:
|
||||
fmts = AFMT_A_LAW;
|
||||
sample_size = 8;
|
||||
break;
|
||||
case AUDIO_FORMAT_UNSIGNED_16:
|
||||
fmts = AFMT_U16_NE;
|
||||
break;
|
||||
}
|
||||
#if 0
|
||||
if(ioctl(ai->fn, SNDCTL_DSP_SAMPLESIZE,&sample_size) < 0)
|
||||
return -1;
|
||||
#endif
|
||||
sf = fmts;
|
||||
ret = ioctl(ai->fn, SNDCTL_DSP_SETFMT, &fmts);
|
||||
if(sf != fmts) {
|
||||
return -1;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* get formats for specific channel/rate parameters
|
||||
@@ -288,7 +272,7 @@ fprintf(stderr,"No");
|
||||
|
||||
int audio_play_samples(struct audio_info_struct *ai,unsigned char *buf,int len)
|
||||
{
|
||||
#ifdef PPC_ENDIAN
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
#define BYTE0(n) ((unsigned char)(n) & (0xFF))
|
||||
#define BYTE1(n) BYTE0((unsigned int)(n) >> 8)
|
||||
#define BYTE2(n) BYTE0((unsigned int)(n) >> 16)
|
||||
@@ -311,7 +295,7 @@ int audio_play_samples(struct audio_info_struct *ai,unsigned char *buf,int len)
|
||||
intPtr++;
|
||||
}
|
||||
}
|
||||
#endif /* PPC_ENDIAN */
|
||||
#endif /* WORDS_BIGENDIAN */
|
||||
|
||||
return write(ai->fn,buf,len);
|
||||
}
|
||||
@@ -321,3 +305,7 @@ int audio_close(struct audio_info_struct *ai)
|
||||
close (ai->fn);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void audio_queueflush(struct audio_info_struct *ai)
|
||||
{
|
||||
}
|
||||
|
||||
170
src/audio_sgi.c
170
src/audio_sgi.c
@@ -4,6 +4,9 @@
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/* #include <audio.h> */
|
||||
#include <dmedia/audio.h>
|
||||
|
||||
#include "mpg123.h"
|
||||
|
||||
|
||||
@@ -11,27 +14,75 @@
|
||||
static const char analog_output_res_name[] = ".AnalogOut";
|
||||
|
||||
|
||||
static int audio_set_rate(struct audio_info_struct *ai, ALconfig config)
|
||||
{
|
||||
int dev = alGetDevice(config);
|
||||
ALpv params[1];
|
||||
|
||||
/* Make sure the device is OK */
|
||||
if (dev < 0)
|
||||
{
|
||||
fprintf(stderr,"audio_set_rate : %s\n",alGetErrorString(oserror()));
|
||||
return 1;
|
||||
}
|
||||
|
||||
params[0].param = AL_OUTPUT_RATE;
|
||||
params[0].value.ll = alDoubleToFixed(ai->rate);
|
||||
|
||||
if (alSetParams(dev, params,1) < 0)
|
||||
fprintf(stderr,"audio_set_rate : %s\n",alGetErrorString(oserror()));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int audio_set_channels(struct audio_info_struct *ai, ALconfig config)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if(ai->channels == 2)
|
||||
ret = alSetChannels(config, AL_STEREO);
|
||||
else
|
||||
ret = alSetChannels(config, AL_MONO);
|
||||
|
||||
if (ret < 0)
|
||||
fprintf(stderr,"audio_set_channels : %s\n",alGetErrorString(oserror()));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int audio_set_format(struct audio_info_struct *ai, ALconfig config)
|
||||
{
|
||||
if (alSetSampFmt(config,AL_SAMPFMT_TWOSCOMP) < 0)
|
||||
fprintf(stderr,"audio_set_format : %s\n",alGetErrorString(oserror()));
|
||||
|
||||
if (alSetWidth(config,AL_SAMPLE_16) < 0)
|
||||
fprintf(stderr,"audio_set_format : %s\n",alGetErrorString(oserror()));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int audio_open(struct audio_info_struct *ai)
|
||||
{
|
||||
int dev = AL_DEFAULT_OUTPUT;
|
||||
|
||||
ai->config = alNewConfig();
|
||||
|
||||
ALconfig config = alNewConfig();
|
||||
ALport port = NULL;
|
||||
|
||||
/* Test for correct completion */
|
||||
if (ai->config == 0) {
|
||||
if (config == 0) {
|
||||
fprintf(stderr,"audio_open : %s\n",alGetErrorString(oserror()));
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
/* Set port parameters */
|
||||
if(ai->channels == 2)
|
||||
alSetChannels(ai->config, AL_STEREO);
|
||||
alSetChannels(config, AL_STEREO);
|
||||
else
|
||||
alSetChannels(ai->config, AL_MONO);
|
||||
alSetChannels(config, AL_MONO);
|
||||
|
||||
alSetWidth(ai->config, AL_SAMPLE_16);
|
||||
alSetSampFmt(ai->config,AL_SAMPFMT_TWOSCOMP);
|
||||
alSetQueueSize(ai->config, 131069);
|
||||
alSetWidth(config, AL_SAMPLE_16);
|
||||
alSetSampFmt(config,AL_SAMPFMT_TWOSCOMP);
|
||||
alSetQueueSize(config, 131069);
|
||||
|
||||
/* Setup output device to specified module. If there is no module
|
||||
specified in ai structure, use the default four output */
|
||||
@@ -59,90 +110,33 @@ int audio_open(struct audio_info_struct *ai)
|
||||
}
|
||||
|
||||
/* Set the device */
|
||||
if (alSetDevice(ai->config,dev) < 0)
|
||||
if (alSetDevice(config,dev) < 0)
|
||||
{
|
||||
fprintf(stderr,"audio_open : %s\n",alGetErrorString(oserror()));
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
/* Open the audio port */
|
||||
ai->port = alOpenPort("mpg123-VSC", "w", ai->config);
|
||||
if(ai->port == NULL) {
|
||||
port = alOpenPort("mpg123-VSC", "w", config);
|
||||
if(port == NULL) {
|
||||
fprintf(stderr, "Unable to open audio channel: %s\n",
|
||||
alGetErrorString(oserror()));
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
audio_reset_parameters(ai);
|
||||
ai->handle = (void*)port;
|
||||
|
||||
|
||||
audio_set_format(ai, config);
|
||||
audio_set_channels(ai, config);
|
||||
audio_set_rate(ai, config);
|
||||
|
||||
|
||||
alFreeConfig(config);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int audio_reset_parameters(struct audio_info_struct *ai)
|
||||
{
|
||||
int ret;
|
||||
ret = audio_set_format(ai);
|
||||
if(ret >= 0)
|
||||
ret = audio_set_channels(ai);
|
||||
if(ret >= 0)
|
||||
ret = audio_set_rate(ai);
|
||||
|
||||
/* todo: Set new parameters here */
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int audio_rate_best_match(struct audio_info_struct *ai)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int audio_set_rate(struct audio_info_struct *ai)
|
||||
{
|
||||
int dev = alGetDevice(ai->config);
|
||||
ALpv params[1];
|
||||
|
||||
/* Make sure the device is OK */
|
||||
if (dev < 0)
|
||||
{
|
||||
fprintf(stderr,"audio_set_rate : %s\n",alGetErrorString(oserror()));
|
||||
return 1;
|
||||
}
|
||||
|
||||
params[0].param = AL_OUTPUT_RATE;
|
||||
params[0].value.ll = alDoubleToFixed(ai->rate);
|
||||
|
||||
if (alSetParams(dev, params,1) < 0)
|
||||
fprintf(stderr,"audio_set_rate : %s\n",alGetErrorString(oserror()));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int audio_set_channels(struct audio_info_struct *ai)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if(ai->channels == 2)
|
||||
ret = alSetChannels(ai->config, AL_STEREO);
|
||||
else
|
||||
ret = alSetChannels(ai->config, AL_MONO);
|
||||
|
||||
if (ret < 0)
|
||||
fprintf(stderr,"audio_set_channels : %s\n",alGetErrorString(oserror()));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int audio_set_format(struct audio_info_struct *ai)
|
||||
{
|
||||
if (alSetSampFmt(ai->config,AL_SAMPFMT_TWOSCOMP) < 0)
|
||||
fprintf(stderr,"audio_set_format : %s\n",alGetErrorString(oserror()));
|
||||
|
||||
if (alSetWidth(ai->config,AL_SAMPLE_16) < 0)
|
||||
fprintf(stderr,"audio_set_format : %s\n",alGetErrorString(oserror()));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int audio_get_formats(struct audio_info_struct *ai)
|
||||
{
|
||||
@@ -152,22 +146,30 @@ int audio_get_formats(struct audio_info_struct *ai)
|
||||
|
||||
int audio_play_samples(struct audio_info_struct *ai,unsigned char *buf,int len)
|
||||
{
|
||||
ALport port = (ALport)ai->handle;
|
||||
|
||||
if(ai->format == AUDIO_FORMAT_SIGNED_8)
|
||||
alWriteFrames(ai->port, buf, len>>1);
|
||||
alWriteFrames(port, buf, len>>1);
|
||||
else
|
||||
alWriteFrames(ai->port, buf, len>>2);
|
||||
alWriteFrames(port, buf, len>>2);
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
int audio_close(struct audio_info_struct *ai)
|
||||
{
|
||||
if (ai->port) {
|
||||
while(alGetFilled(ai->port) > 0)
|
||||
ALport port = (ALport)ai->handle;
|
||||
|
||||
if (port) {
|
||||
while(alGetFilled(port) > 0)
|
||||
sginap(1);
|
||||
alClosePort(ai->port);
|
||||
alFreeConfig(ai->config);
|
||||
alClosePort(port);
|
||||
ai->handle=NULL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void audio_queueflush(struct audio_info_struct *ai)
|
||||
{
|
||||
}
|
||||
|
||||
212
src/audio_sun.c
212
src/audio_sun.c
@@ -29,8 +29,114 @@
|
||||
#include <sys/ioctl.h>
|
||||
#endif
|
||||
|
||||
static void audio_set_format_helper(struct audio_info_struct *ai,audio_info_t *ainfo);
|
||||
|
||||
static int audio_reset_parameters(struct audio_info_struct *ai)
|
||||
{
|
||||
audio_info_t ainfo;
|
||||
|
||||
AUDIO_INITINFO(&ainfo);
|
||||
|
||||
if(ai->rate != -1)
|
||||
ainfo.play.sample_rate = ai->rate;
|
||||
if(ai->channels >= 0)
|
||||
ainfo.play.channels = ai->channels;
|
||||
audio_set_format_helper(ai,&ainfo);
|
||||
|
||||
if(ioctl(ai->fn, AUDIO_SETINFO, &ainfo) == -1)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int audio_rate_best_match(struct audio_info_struct *ai)
|
||||
{
|
||||
audio_info_t ainfo;
|
||||
AUDIO_INITINFO(&ainfo);
|
||||
|
||||
ainfo.play.sample_rate = ai->rate;
|
||||
if(ioctl(ai->fn, AUDIO_SETINFO, &ainfo) < 0) {
|
||||
ai->rate = 0;
|
||||
return 0;
|
||||
}
|
||||
if(ioctl(ai->fn, AUDIO_GETINFO, &ainfo) < 0) {
|
||||
return -1;
|
||||
}
|
||||
ai->rate = ainfo.play.sample_rate;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int audio_set_rate(struct audio_info_struct *ai)
|
||||
{
|
||||
audio_info_t ainfo;
|
||||
|
||||
if(ai->rate != -1) {
|
||||
AUDIO_INITINFO(&ainfo);
|
||||
ainfo.play.sample_rate = ai->rate;
|
||||
if(ioctl(ai->fn, AUDIO_SETINFO, &ainfo) == -1)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int audio_set_channels(struct audio_info_struct *ai)
|
||||
{
|
||||
audio_info_t ainfo;
|
||||
|
||||
AUDIO_INITINFO(&ainfo);
|
||||
ainfo.play.channels = ai->channels;
|
||||
if(ioctl(ai->fn, AUDIO_SETINFO, &ainfo) == -1)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void audio_set_format_helper(struct audio_info_struct *ai,audio_info_t *ainfo)
|
||||
{
|
||||
|
||||
|
||||
switch(ai->format) {
|
||||
case -1:
|
||||
case AUDIO_FORMAT_SIGNED_16:
|
||||
default:
|
||||
ainfo->play.encoding = AUDIO_ENCODING_LINEAR;
|
||||
ainfo->play.precision = 16;
|
||||
break;
|
||||
case AUDIO_FORMAT_UNSIGNED_8:
|
||||
#if defined(SOLARIS) || defined(SPARCLINUX)
|
||||
ainfo->play.encoding = AUDIO_ENCODING_LINEAR8;
|
||||
ainfo->play.precision = 8;
|
||||
break;
|
||||
#endif
|
||||
#ifdef NETBSD
|
||||
ainfo->play.encoding = AUDIO_ENCODING_LINEAR;
|
||||
ainfo->play.precision = 8;
|
||||
break;
|
||||
#endif
|
||||
case AUDIO_FORMAT_SIGNED_8:
|
||||
fprintf(stderr,"Linear signed 8 bit not supported!\n");
|
||||
return;
|
||||
case AUDIO_FORMAT_ULAW_8:
|
||||
ainfo->play.encoding = AUDIO_ENCODING_ULAW;
|
||||
ainfo->play.precision = 8;
|
||||
break;
|
||||
case AUDIO_FORMAT_ALAW_8:
|
||||
ainfo->play.encoding = AUDIO_ENCODING_ALAW;
|
||||
ainfo->play.precision = 8;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static int audio_set_format(struct audio_info_struct *ai)
|
||||
{
|
||||
audio_info_t ainfo;
|
||||
|
||||
AUDIO_INITINFO(&ainfo);
|
||||
audio_set_format_helper(ai,&ainfo);
|
||||
if(ioctl(ai->fn, AUDIO_SETINFO, &ainfo) == -1)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int audio_open(struct audio_info_struct *ai)
|
||||
{
|
||||
@@ -100,112 +206,8 @@ int audio_open(struct audio_info_struct *ai)
|
||||
return ai->fn;
|
||||
}
|
||||
|
||||
int audio_reset_parameters(struct audio_info_struct *ai)
|
||||
{
|
||||
audio_info_t ainfo;
|
||||
|
||||
AUDIO_INITINFO(&ainfo);
|
||||
|
||||
if(ai->rate != -1)
|
||||
ainfo.play.sample_rate = ai->rate;
|
||||
if(ai->channels >= 0)
|
||||
ainfo.play.channels = ai->channels;
|
||||
audio_set_format_helper(ai,&ainfo);
|
||||
|
||||
if(ioctl(ai->fn, AUDIO_SETINFO, &ainfo) == -1)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int audio_rate_best_match(struct audio_info_struct *ai)
|
||||
{
|
||||
audio_info_t ainfo;
|
||||
AUDIO_INITINFO(&ainfo);
|
||||
|
||||
ainfo.play.sample_rate = ai->rate;
|
||||
if(ioctl(ai->fn, AUDIO_SETINFO, &ainfo) < 0) {
|
||||
ai->rate = 0;
|
||||
return 0;
|
||||
}
|
||||
if(ioctl(ai->fn, AUDIO_GETINFO, &ainfo) < 0) {
|
||||
return -1;
|
||||
}
|
||||
ai->rate = ainfo.play.sample_rate;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int audio_set_rate(struct audio_info_struct *ai)
|
||||
{
|
||||
audio_info_t ainfo;
|
||||
|
||||
if(ai->rate != -1) {
|
||||
AUDIO_INITINFO(&ainfo);
|
||||
ainfo.play.sample_rate = ai->rate;
|
||||
if(ioctl(ai->fn, AUDIO_SETINFO, &ainfo) == -1)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int audio_set_channels(struct audio_info_struct *ai)
|
||||
{
|
||||
audio_info_t ainfo;
|
||||
|
||||
AUDIO_INITINFO(&ainfo);
|
||||
ainfo.play.channels = ai->channels;
|
||||
if(ioctl(ai->fn, AUDIO_SETINFO, &ainfo) == -1)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void audio_set_format_helper(struct audio_info_struct *ai,audio_info_t *ainfo)
|
||||
{
|
||||
|
||||
|
||||
switch(ai->format) {
|
||||
case -1:
|
||||
case AUDIO_FORMAT_SIGNED_16:
|
||||
default:
|
||||
ainfo->play.encoding = AUDIO_ENCODING_LINEAR;
|
||||
ainfo->play.precision = 16;
|
||||
break;
|
||||
case AUDIO_FORMAT_UNSIGNED_8:
|
||||
#if defined(SOLARIS) || defined(SPARCLINUX)
|
||||
ainfo->play.encoding = AUDIO_ENCODING_LINEAR8;
|
||||
ainfo->play.precision = 8;
|
||||
break;
|
||||
#endif
|
||||
#ifdef NETBSD
|
||||
ainfo->play.encoding = AUDIO_ENCODING_LINEAR;
|
||||
ainfo->play.precision = 8;
|
||||
break;
|
||||
#endif
|
||||
case AUDIO_FORMAT_SIGNED_8:
|
||||
fprintf(stderr,"Linear signed 8 bit not supported!\n");
|
||||
return;
|
||||
case AUDIO_FORMAT_ULAW_8:
|
||||
ainfo->play.encoding = AUDIO_ENCODING_ULAW;
|
||||
ainfo->play.precision = 8;
|
||||
break;
|
||||
case AUDIO_FORMAT_ALAW_8:
|
||||
ainfo->play.encoding = AUDIO_ENCODING_ALAW;
|
||||
ainfo->play.precision = 8;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int audio_set_format(struct audio_info_struct *ai)
|
||||
{
|
||||
audio_info_t ainfo;
|
||||
|
||||
AUDIO_INITINFO(&ainfo);
|
||||
audio_set_format_helper(ai,&ainfo);
|
||||
if(ioctl(ai->fn, AUDIO_SETINFO, &ainfo) == -1)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int audio_get_formats(struct audio_info_struct *ai)
|
||||
{
|
||||
|
||||
@@ -108,31 +108,6 @@ int audio_open(struct audio_info_struct *ai)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int audio_reset_parameters(struct audio_info_struct *ai)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int audio_rate_best_match(struct audio_info_struct *ai)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int audio_set_rate(struct audio_info_struct *ai)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int audio_set_channels(struct audio_info_struct *ai)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int audio_set_format(struct audio_info_struct *ai)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int audio_get_formats(struct audio_info_struct *ai)
|
||||
{
|
||||
return AUDIO_FORMAT_SIGNED_16;
|
||||
@@ -224,3 +199,8 @@ int audio_close(struct audio_info_struct *ai)
|
||||
nBlocks = 0;
|
||||
return(0);
|
||||
}
|
||||
|
||||
void audio_queueflush(struct audio_info_struct *ai)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -4,9 +4,8 @@
|
||||
*
|
||||
* -funroll-loops (for gcc) will remove the loops for better performance
|
||||
* using loops in the source-code enhances readabillity
|
||||
*/
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
* TODO: write an optimized version for the down-sampling modes
|
||||
* (in these modes the bands 16-31 (2:1) or 8-31 (4:1) are zero
|
||||
*/
|
||||
|
||||
@@ -41,6 +41,7 @@ for .... no flag) */
|
||||
* else
|
||||
* loptarg = &arg
|
||||
* return ((value != 0) ? value : sname)
|
||||
*
|
||||
* bit 1 = 1 - var is a pointer to a char (or string),
|
||||
* and value is interpreted as char
|
||||
* bit 2 = 1 - var is a pointer to int
|
||||
|
||||
@@ -21,10 +21,7 @@
|
||||
#include <errno.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "mpg123.h"
|
||||
|
||||
#ifndef INADDR_NONE
|
||||
|
||||
@@ -7,9 +7,7 @@
|
||||
*/
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
@@ -1221,10 +1219,11 @@ tc_hack:
|
||||
|
||||
static void print_title(void)
|
||||
{
|
||||
fprintf(stderr,"High Performance MPEG 1.0/2.0 Audio Player for Layer 1, 2 and 3.\n");
|
||||
fprintf(stderr,"High Performance MPEG 1.0/2.0 Audio Player for Layers 1, 2 and 3.\n");
|
||||
fprintf(stderr,"Version %s. Initially written and copyright by Michael Hipp.\n", PACKAGE_VERSION);
|
||||
fprintf(stderr,"Uses code from various people. See 'README' for more!\n");
|
||||
fprintf(stderr,"THIS SOFTWARE COMES WITH ABSOLUTELY NO WARRANTY! USE AT YOUR OWN RISK!\n");
|
||||
fprintf(stderr,"Uses code from various people, see 'AUTHORS' for full list.\n");
|
||||
fprintf(stderr,"This software comes with ABSOLUTELY NO WARRANTY. For details, see \n");
|
||||
fprintf(stderr,"the enclosed file COPYING for license information (GPL).\n");
|
||||
}
|
||||
|
||||
static void usage(char *dummy) /* print syntax & exit */
|
||||
|
||||
@@ -100,7 +100,6 @@ static int system_raw_read_head(int f,unsigned long *head)
|
||||
static int system_raw_read_word(int f,int *word)
|
||||
{
|
||||
unsigned char buf[2];
|
||||
int ret;
|
||||
|
||||
if(my_read(f,buf,2) != 2) {
|
||||
perror("read_word");
|
||||
@@ -488,5 +487,6 @@ void main(void)
|
||||
filept = 0;
|
||||
ret = system_init(&rd1);
|
||||
fprintf(stderr,"ret: %d\n",ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_TERMIOS
|
||||
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_TERMIOS
|
||||
|
||||
|
||||
#define LOOP_CYCLES 0.500000 /* Loop time in sec */
|
||||
|
||||
/*
|
||||
|
||||
@@ -7,6 +7,10 @@
|
||||
* See xfermem.h for documentation/description.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#ifndef NOXFERMEM
|
||||
|
||||
#include <stdio.h>
|
||||
@@ -27,12 +31,12 @@
|
||||
|
||||
#include "mpg123.h"
|
||||
|
||||
#ifndef USE_MMAP
|
||||
#ifndef HAVE_MMAP
|
||||
#include <sys/ipc.h>
|
||||
#include <sys/shm.h>
|
||||
#endif
|
||||
|
||||
#if defined (USE_MMAP) && defined(MAP_ANONYMOUS) && !defined(MAP_ANON)
|
||||
#if defined (HAVE_MMAP) && defined(MAP_ANONYMOUS) && !defined(MAP_ANON)
|
||||
#define MAP_ANON MAP_ANONYMOUS
|
||||
#endif
|
||||
|
||||
@@ -40,7 +44,7 @@ void xfermem_init (txfermem **xf, int bufsize, int msize, int skipbuf)
|
||||
{
|
||||
int regsize = bufsize + msize + skipbuf + sizeof(txfermem);
|
||||
|
||||
#ifdef USE_MMAP
|
||||
#ifdef HAVE_MMAP
|
||||
# ifdef MAP_ANON
|
||||
if ((*xf = (txfermem *) mmap(0, regsize, PROT_READ | PROT_WRITE,
|
||||
MAP_ANON | MAP_SHARED, -1, 0)) == (txfermem *) -1) {
|
||||
@@ -95,7 +99,7 @@ void xfermem_done (txfermem *xf)
|
||||
{
|
||||
if(!xf)
|
||||
return;
|
||||
#ifdef USE_MMAP
|
||||
#ifdef HAVE_MMAP
|
||||
munmap ((caddr_t) xf, xf->size + xf->metasize + sizeof(txfermem));
|
||||
#else
|
||||
if (shmdt((void *) xf) == -1) {
|
||||
|
||||
Reference in New Issue
Block a user