1
0
mirror of http://mpg123.de/trunk/.git synced 2025-10-26 15:31:15 +03:00

Hacking MinGW32 into cooperation, in dialog with Elia Blance.

This restores some work of Tony Million from ages ago... wrapping buffer code properly into #ifndef NOXFERMEM again (except in term.c, which is a different beast).
Hack Makefile for the preprocessed .S files (mingw doesn't run cpp by itself).

Got autoconf'ed x86 portaudio/mme build working for *-mingw32; Elia wants SDL ...;-)
Also configure now doesn't look at OS for choosing default audio output but at the available output systems instead.
Let's keep this hardcoding at a minimum.

Sound playback works, control_generic not (no stdin in windows terminal?).
Assembler opts work nicely (including --cpu choice).
WAV writing has distortion ... twisted endianess?



git-svn-id: svn://scm.orgis.org/mpg123/trunk@631 35dc7657-300d-0410-a2e5-dc2837fedb53
This commit is contained in:
thor
2007-05-02 22:48:23 +00:00
parent c7df68fe55
commit 1e56b91ceb
14 changed files with 164 additions and 98 deletions

View File

@@ -158,12 +158,29 @@ AC_CHECK_LIB( [audio], [AuOpenServer],
) )
# Check for PortAudio # Check for PortAudio
AC_CHECK_LIB( [portaudio], [Pa_Initialize], case $target in
*-*-mingw32)
# We tested portaudio with MME
if test "x$HAVE_PORTAUDIO" != "xyes"; then
AC_CHECK_LIB( [portaudio], [Pa_Initialize],
[ AC_CHECK_HEADER( [portaudio.h],
[ HAVE_PORTAUDIO_WINMM="yes" && HAVE_PORTAUDIO="yes" ],
[ AC_MSG_WARN([Found PortAudio library but NOT header files on your system]) ] )
],
[ HAVE_PORTAUDIO="no" ],
[ -lwinmm ]
)
fi
;;
*)
AC_CHECK_LIB( [portaudio], [Pa_Initialize],
[ AC_CHECK_HEADER( [portaudio.h], [ AC_CHECK_HEADER( [portaudio.h],
[ HAVE_PORTAUDIO="yes" ], [ HAVE_PORTAUDIO="yes" ],
[ AC_MSG_WARN([Found PortAudio library but NOT header files on your system]) ] ) [ AC_MSG_WARN([Found PortAudio library but NOT header files on your system]) ] )
] ]
) )
;;
esac
# Check for ALSA # Check for ALSA
AC_CHECK_LIB( [asound], [snd_pcm_open], AC_CHECK_LIB( [asound], [snd_pcm_open],
@@ -182,10 +199,10 @@ AC_CHECK_HEADERS([stdlib.h string.h unistd.h sched.h sys/ioctl.h stdint.h limits
# OSS Header files # OSS Header files
AC_CHECK_HEADERS([sys/soundcard.h linux/soundcard.h machine/soundcard.h]) AC_CHECK_HEADERS([sys/soundcard.h linux/soundcard.h machine/soundcard.h], HAVE_OSS=yes, HAVE_OSS=no)
# Sun Audio headers # Sun Audio headers
AC_CHECK_HEADERS([sun/audioio.h sys/audioio.h asm/audioio.h sys/audio.h]) AC_CHECK_HEADERS([sun/audioio.h sys/audioio.h asm/audioio.h sys/audio.h], HAVE_SUNAUDIO=yes, HAVE_SUNAUDIO=no)
# Mac OS X # Mac OS X
AC_CHECK_HEADERS([AudioUnit/AudioUnit.h CoreServices/CoreServices.h AudioToolbox/AudioToolbox.h], AC_CHECK_HEADERS([AudioUnit/AudioUnit.h CoreServices/CoreServices.h AudioToolbox/AudioToolbox.h],
@@ -205,7 +222,8 @@ if test "$debugging" = "enabled"; then
CFLAGS="$CFLAGS -g" CFLAGS="$CFLAGS -g"
# gcc specific... # gcc specific...
if test "$GCC" = "yes"; then if test "$GCC" = "yes"; then
CFLAGS="$CFLAGS -Wall -Werror -pedantic -fno-strict-aliasing" # no -Werror until I fixed that SSE long-long stuff...
CFLAGS="$CFLAGS -Wall -pedantic -fno-strict-aliasing"
fi fi
fi fi
@@ -268,10 +286,30 @@ case $target in
*-pc-cygwin*) *-pc-cygwin*)
cpu_type="generic_fpu" cpu_type="generic_fpu"
;; ;;
*-*-mingw32)
LIBS="-lwsock32 $LIBS"
CPPFLAGS="-DNOXFERMEM $CPPFLAGS"
cpu_type="x86"
;;
i386-*)
AC_MSG_WARN([Unknown target operating system])
cpu_type="i386"
CFLAGS="-DGENERIC $CFLAGS"
;;
i486-*)
AC_MSG_WARN([Unknown target operating system])
cpu_type="i486"
CFLAGS="-DGENERIC $CFLAGS"
;;
i586-*)
AC_MSG_WARN([Unknown target operating system])
cpu_type="i586"
CFLAGS="-DGENERIC $CFLAGS"
;;
*) *)
AC_MSG_WARN([Unknown target operating system]) AC_MSG_WARN([Unknown target operating system])
cpu_type="generic_fpu" cpu_type="generic_fpu"
CFLAGS="$CFLAGS -DGENERIC" CFLAGS="-DGENERIC $CFLAGS"
;; ;;
esac esac
@@ -393,36 +431,28 @@ AC_DEFINE_UNQUOTED(INDEX_SIZE, $seektable, [size of the frame index seek table])
dnl ############## Audio Sub-system Settings dnl ############## Audio Sub-system Settings
# Choose audio subsystem based on Operating System # Choose audio subsystem based on what we have.
case $target in
*-*-linux*) if test "x$HAVE_ALSA" = "xyes"; then
if test "x$HAVE_ALSA" = "xyes" ; then
audio_system="alsa" audio_system="alsa"
else elif test "x$HAVE_OSS" = "xyes"; then
audio_system="oss" audio_system="oss"
fi elif test "x$HAVE_MACOSXAUDIO" = "xyes"; then
;;
*-*-freebsd*)
audio_system="oss"
;;
*-*-kfreebsd*)
audio_system="oss"
;;
*-apple-darwin*)
audio_system="macosx" audio_system="macosx"
;; elif test "x$HAVE_SUNAUDIO" = "xyes"; then
*-*-solaris*)
audio_system="sun" audio_system="sun"
;; elif test "x$HAVE_JACK" = "xyes"; then
# esd has been assumed to be the one for cygwin, but plain OSS does it audio_system="jack"
# can even make mpg123 run "natively" with a cygwin.dll elif test "x$HAVE_PORTAUDIO" = "xyes"; then
*-*-cygwin*) audio_system="portaudio"
audio_system="oss" elif test "x$HAVE_NAS" = "xyes"; then
;; audio_system="nas"
*) elif test "x$HAVE_SDL" = "xyes"; then
audio_system="dummy" audio_system="sdl"
;; elif test "x$HAVE_ESOUND" = "xyes"; then
esac audio_system="esd"
fi
# Did user choose other audio type ? # Did user choose other audio type ?
if test "x$with_audio" != "x"; then if test "x$with_audio" != "x"; then
@@ -430,7 +460,6 @@ if test "x$with_audio" != "x"; then
fi fi
AUDIO_OBJ="audio_$audio_system.\$(OBJEXT)" AUDIO_OBJ="audio_$audio_system.\$(OBJEXT)"
AUDIO_CFLAGS="" AUDIO_CFLAGS=""
AUDIO_LIBS="" AUDIO_LIBS=""
@@ -455,7 +484,7 @@ case $audio_system in
;; ;;
esd) esd)
if test "x$HAVE_ESOUND" != "xyes" ; then if test "x$HAVE_ESOUND" != "xyes" ; then
AC_MSG_ERROR( ESounD is not available for audio output subsystem. ) AC_MSG_WARN( ESounD is not available for audio output subsystem. )
fi fi
AUDIO_CFLAGS=$ESOUND_CFLAGS AUDIO_CFLAGS=$ESOUND_CFLAGS
AUDIO_LIBS=$ESOUND_LIBS AUDIO_LIBS=$ESOUND_LIBS
@@ -508,10 +537,13 @@ case $audio_system in
fi fi
AUDIO_CFLAGS="" AUDIO_CFLAGS=""
AUDIO_LIBS="-lportaudio" AUDIO_LIBS="-lportaudio"
if test "x$HAVE_PORTAUDIO_WINMM" = "xyes"; then
AUDIO_LIBS="$AUDIO_LIBS -lwinmm"
fi
;; ;;
sdl) sdl)
if test "x$HAVE_SDL" != "xyes" ; then if test "x$HAVE_SDL" != "xyes" ; then
AC_MSG_ERROR( SDL is not available for audio output subsystem. ) AC_MSG_WARN( SDL not found via pkgconfig. )
fi fi
AUDIO_CFLAGS=$SDL_CFLAGS AUDIO_CFLAGS=$SDL_CFLAGS
AUDIO_LIBS=$SDL_LIBS AUDIO_LIBS=$SDL_LIBS

View File

@@ -5,8 +5,8 @@
## initially written by Nicholas J. Humfrey ## initially written by Nicholas J. Humfrey
AM_CFLAGS = @AUDIO_CFLAGS@ AM_CFLAGS = @AUDIO_CFLAGS@
AM_LDFLAGS = @AUDIO_LIBS@ #AM_LDFLAGS =
mpg123_LDADD = @AUDIO_OBJ@ @CPU_TYPE_LIB@ mpg123_LDADD = @AUDIO_OBJ@ @CPU_TYPE_LIB@ @AUDIO_LIBS@
mpg123_DEPENDENCIES = @AUDIO_OBJ@ @CPU_TYPE_LIB@ mpg123_DEPENDENCIES = @AUDIO_OBJ@ @CPU_TYPE_LIB@
EXTRA_DIST = Makefile.legacy config.h.legacy EXTRA_DIST = Makefile.legacy config.h.legacy
@@ -200,3 +200,8 @@ libcpu_x86_a_SOURCES = \
tabinit_mmx.S \ tabinit_mmx.S \
equalizer_3dnow.S \ equalizer_3dnow.S \
getcpuflags.S getcpuflags.S
# explicit preprocessing since mingw32 does not honor the big .S
.S.o:
$(CPP) $(CPPFLAGS) $< > $<.s
$(CCAS) -c -o $@ $<.s && rm $<.s

View File

@@ -18,6 +18,9 @@
#include "mpg123.h" #include "mpg123.h"
#include "debug.h" #include "debug.h"
#ifdef WIN32
#include <windows.h>
#endif
#define SAMPLE_SIZE (2) #define SAMPLE_SIZE (2)
#define FRAMES_PER_BUFFER (256) #define FRAMES_PER_BUFFER (256)
@@ -107,7 +110,11 @@ int audio_play_samples(struct audio_info_struct *ai, unsigned char *buf, int len
/* Sleep for half the length of the FIFO */ /* Sleep for half the length of the FIFO */
while (sfifo_space( &fifo ) < len ) { while (sfifo_space( &fifo ) < len ) {
#ifdef WIN32
Sleep( (FIFO_DURATION/2) * 1000);
#else
usleep( (FIFO_DURATION/2) * 1000000 ); usleep( (FIFO_DURATION/2) * 1000000 );
#endif
} }
/* Write the audio to the ring buffer */ /* Write the audio to the ring buffer */

View File

@@ -10,6 +10,8 @@
- dammed night coders;-) - dammed night coders;-)
*/ */
#ifndef NOXFERMEM
#include <stdlib.h> #include <stdlib.h>
#include <errno.h> #include <errno.h>
@@ -35,41 +37,42 @@ static void catch_usr1 (void)
extern void buffer_sig(int signal, int block); extern void buffer_sig(int signal, int block);
void buffer_ignore_lowmem(void) void real_buffer_ignore_lowmem(void)
{ {
#ifndef NOXFERMEM
if (!buffermem) if (!buffermem)
return; return;
if(buffermem->wakeme[XF_READER]) if(buffermem->wakeme[XF_READER])
xfermem_putcmd(buffermem->fd[XF_WRITER], XF_CMD_WAKEUP); xfermem_putcmd(buffermem->fd[XF_WRITER], XF_CMD_WAKEUP);
#endif
} }
void buffer_end(void) void real_buffer_end(void)
{ {
#ifndef NOXFERMEM
if (!buffermem) if (!buffermem)
return; return;
xfermem_putcmd(buffermem->fd[XF_WRITER], XF_CMD_TERMINATE); xfermem_putcmd(buffermem->fd[XF_WRITER], XF_CMD_TERMINATE);
#endif
} }
void buffer_resync(void) void real_buffer_resync(void)
{ {
buffer_sig(SIGINT, TRUE); buffer_sig(SIGINT, TRUE);
} }
void buffer_reset(void) void real_plain_buffer_resync(void)
{
buffer_sig(SIGINT, FALSE);
}
void real_buffer_reset(void)
{ {
buffer_sig(SIGUSR1, TRUE); buffer_sig(SIGUSR1, TRUE);
} }
void buffer_start(void) void real_buffer_start(void)
{ {
buffer_sig(SIGCONT, FALSE); buffer_sig(SIGCONT, FALSE);
} }
void buffer_stop(void) void real_buffer_stop(void)
{ {
buffer_sig(SIGSTOP, FALSE); buffer_sig(SIGSTOP, FALSE);
} }
@@ -78,8 +81,6 @@ extern int buffer_pid;
void buffer_sig(int signal, int block) void buffer_sig(int signal, int block)
{ {
#ifndef NOXFERMEM
if (!buffermem) if (!buffermem)
return; return;
@@ -90,13 +91,9 @@ void buffer_sig(int signal, int block)
if(xfermem_block(XF_WRITER, buffermem) != XF_CMD_WAKEUP) if(xfermem_block(XF_WRITER, buffermem) != XF_CMD_WAKEUP)
perror("Could not resync/reset buffers"); perror("Could not resync/reset buffers");
#endif
return; return;
} }
#ifndef NOXFERMEM
void buffer_loop(struct audio_info_struct *ai, sigset_t *oldsigset) void buffer_loop(struct audio_info_struct *ai, sigset_t *oldsigset)
{ {
int bytes; int bytes;

View File

@@ -16,11 +16,30 @@
#ifndef _MPG123_BUFFER_H_ #ifndef _MPG123_BUFFER_H_
#define _MPG123_BUFFER_H_ #define _MPG123_BUFFER_H_
void buffer_ignore_lowmem(void); #ifndef NOXFERMEM
void buffer_end(void); void real_buffer_ignore_lowmem(void);
void buffer_resync(void); void real_buffer_end(void);
void buffer_reset(void); void real_buffer_resync(void);
void buffer_start(void); void real_plain_buffer_resync(void);
void buffer_stop(void); void real_buffer_reset(void);
void real_buffer_start(void);
void real_buffer_stop(void);
/* Hm, that's funny preprocessor weirdness. */
#define buffer_start() (param.usebuffer ? real_buffer_start(),0 : 0)
#define buffer_stop() (param.usebuffer ? real_buffer_stop(),0 : 0)
#define buffer_reset() (param.usebuffer ? real_buffer_reset(),0 : 0)
#define buffer_resync() (param.usebuffer ? real_buffer_resync(),0 : 0)
#define plain_buffer_resync() (param.usebuffer ? real_plain_buffer_resync(),0 : 0)
#define buffer_end() (param.usebuffer ? real_buffer_end(),0 : 0)
#define buffer_ignore_lowmem() (param.usebuffer ? real_buffer_ignore_lowmem(),0 : 0)
#else
#define buffer_start()
#define buffer_stop()
#define buffer_reset()
#define buffer_resync()
#define plain_buffer_resync()
#define buffer_end()
#define buffer_ignore_lowmem()
#endif
#endif #endif

View File

@@ -27,6 +27,10 @@
#include "common.h" #include "common.h"
#include "debug.h" #include "debug.h"
#ifdef WIN32
#include <winsock.h>
#endif
/* bitrates for [mpeg1/2][layer] */ /* bitrates for [mpeg1/2][layer] */
int tabsel_123[2][3][16] = { int tabsel_123[2][3][16] = {
{ {0,32,64,96,128,160,192,224,256,288,320,352,384,416,448,}, { {0,32,64,96,128,160,192,224,256,288,320,352,384,416,448,},

View File

@@ -12,16 +12,21 @@
#include <stdarg.h> #include <stdarg.h>
#include <sys/time.h> #include <sys/time.h>
#include <sys/types.h> #include <sys/types.h>
#ifndef WIN32
#include <sys/wait.h> #include <sys/wait.h>
#include <sys/socket.h>
#else
#include <winsock.h>
#endif
#include <unistd.h> #include <unistd.h>
#include <fcntl.h> #include <fcntl.h>
#include <errno.h> #include <errno.h>
#include <sys/socket.h>
#include "config.h" #include "config.h"
#include "mpg123.h" #include "mpg123.h"
#include "common.h" #include "common.h"
#include "buffer.h"
#include "icy.h" #include "icy.h"
#include "debug.h" #include "debug.h"
#ifdef GAPLESS #ifdef GAPLESS
@@ -102,7 +107,11 @@ int control_generic (struct frame *fr)
else else
outstream = stdout; outstream = stdout;
#ifndef WIN32
setlinebuf(outstream); setlinebuf(outstream);
#else /* perhaps just use setvbuf as it's C89 */
setvbuf(outstream, (char*)NULL, _IOLBF, 0);
#endif
/* the command behaviour is different, so is the ID */ /* the command behaviour is different, so is the ID */
/* now also with version for command availability */ /* now also with version for command availability */
fprintf(outstream, "@R MPG123 (ThOr) v2\n"); fprintf(outstream, "@R MPG123 (ThOr) v2\n");
@@ -221,17 +230,11 @@ int control_generic (struct frame *fr)
if (mode == MODE_PLAYING) { if (mode == MODE_PLAYING) {
mode = MODE_PAUSED; mode = MODE_PAUSED;
audio_flush(param.outmode, &ai); audio_flush(param.outmode, &ai);
#ifndef NOXFERMEM buffer_stop();
if (param.usebuffer)
kill(buffer_pid, SIGSTOP);
#endif
generic_sendmsg("P 1"); generic_sendmsg("P 1");
} else { } else {
mode = MODE_PLAYING; mode = MODE_PLAYING;
#ifndef NOXFERMEM buffer_start();
if (param.usebuffer)
kill(buffer_pid, SIGCONT);
#endif
generic_sendmsg("P 2"); generic_sendmsg("P 2");
} }
} }

View File

@@ -33,12 +33,12 @@
#include "mangle.h" #include "mangle.h"
#ifdef __CYGWIN__ #if defined(__CYGWIN__) || defined(__MINGW32__)
.comm buffs.40,4352 .comm buffs.40,4352
#else #else
.local buffs.40 .local buffs.40
.comm buffs.40,4352,32 .comm buffs.40,4352,32
#endif #endif
.data .data
.align 4 .align 4
/* .type bo.42,@object */ /* .type bo.42,@object */

View File

@@ -33,11 +33,11 @@
#include "mangle.h" #include "mangle.h"
.bss .bss
#ifdef __CYGWIN__ #if defined(__CYGWIN__) || defined(__MINGW32__)
.comm buffs,4352 .comm buffs,4352
#else #else
.comm buffs,4352,4 .comm buffs,4352,4
#endif #endif
.data .data
.align 4 .align 4
bo: bo:

View File

@@ -30,14 +30,14 @@
#include "mangle.h" #include "mangle.h"
.bss .bss
#ifdef __CYGWIN__ #if defined(__CYGWIN__) || defined(__MINGW32__)
.comm buffs,4352 .comm buffs,4352
.comm ditherindex.1,4 .comm ditherindex.1,4
#else #else
.comm buffs,4352,4 .comm buffs,4352,4
.local ditherindex.1 .local ditherindex.1
.comm ditherindex.1,4,4 .comm ditherindex.1,4,4
#endif #endif
.data .data
.align 4 .align 4
bo: bo:

View File

@@ -14,9 +14,11 @@
(defined(__OpenBSD__) && !defined(__ELF__)) || defined(__APPLE__) (defined(__OpenBSD__) && !defined(__ELF__)) || defined(__APPLE__)
#define MANGLE(a) "_" #a #define MANGLE(a) "_" #a
#define ASM_NAME(a) _##a #define ASM_NAME(a) _##a
#define ASM_VALUE(a) $_##a
#else #else
#define MANGLE(a) #a #define MANGLE(a) #a
#define ASM_NAME(a) a #define ASM_NAME(a) a
#define ASM_VALUE(a) "$" #a
#endif #endif
#endif /* !__MANGLE_H */ #endif /* !__MANGLE_H */

View File

@@ -10,17 +10,17 @@
.bss .bss
.align 32 .align 32
#ifdef __CYGWIN__ #if defined(__CYGWIN__) || defined(__MINGW32__)
.comm ASM_NAME(decwin_mmx),2176 .comm ASM_NAME(decwin_mmx),2176
#else #else
.comm ASM_NAME(decwin_mmx),2176,32 .comm ASM_NAME(decwin_mmx),2176,32
#endif #endif
.align 32 .align 32
#ifdef __CYGWIN__ #if defined(__CYGWIN__) || defined(__MINGW32__)
.comm ASM_NAME(decwins),2176 .comm ASM_NAME(decwins),2176
#else #else
.comm ASM_NAME(decwins),2176,32 .comm ASM_NAME(decwins),2176,32
#endif #endif
.data .data
.align 32 .align 32

View File

@@ -158,8 +158,7 @@ static long term_handle_input(struct frame *fr, int do_delay)
break; break;
case NEXT_KEY: case NEXT_KEY:
if(!param.usebuffer) audio_queueflush(&ai); if(!param.usebuffer) audio_queueflush(&ai);
if (buffer_pid) plain_buffer_resync();
kill(buffer_pid, SIGINT);
next_track(); next_track();
break; break;
case QUIT_KEY: case QUIT_KEY:
@@ -175,7 +174,6 @@ static long term_handle_input(struct frame *fr, int do_delay)
} }
if(stopped) { if(stopped) {
stopped=0; stopped=0;
if(param.usebuffer)
buffer_start(); buffer_start();
} }
fprintf(stderr, "%s", (paused) ? PAUSED_STRING : EMPTY_STRING); fprintf(stderr, "%s", (paused) ? PAUSED_STRING : EMPTY_STRING);
@@ -189,8 +187,7 @@ static long term_handle_input(struct frame *fr, int do_delay)
paused=0; paused=0;
offset -= pause_cycle; offset -= pause_cycle;
} }
if(param.usebuffer) if(stopped) buffer_stop(); else buffer_start();
(stopped) ? buffer_stop() : buffer_start();
fprintf(stderr, "%s", (stopped) ? STOPPED_STRING : EMPTY_STRING); fprintf(stderr, "%s", (stopped) ? STOPPED_STRING : EMPTY_STRING);
break; break;
case FINE_REWIND_KEY: case FINE_REWIND_KEY:

View File

@@ -112,7 +112,7 @@ static int testEndian(void)
static int open_file(char *filename) static int open_file(char *filename)
{ {
#ifndef GENERIC #if !defined(GENERIC) && !defined(__WIN32__)
setuid(getuid()); /* dunno whether this helps. I'm not a security expert */ setuid(getuid()); /* dunno whether this helps. I'm not a security expert */
#endif #endif
if(!strcmp("-",filename)) { if(!strcmp("-",filename)) {