1
0
mirror of http://mpg123.de/trunk/.git synced 2025-10-25 04:37:34 +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
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],
[ HAVE_PORTAUDIO="yes" ],
[ AC_MSG_WARN([Found PortAudio library but NOT header files on your system]) ] )
]
)
;;
esac
# Check for ALSA
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
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
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
AC_CHECK_HEADERS([AudioUnit/AudioUnit.h CoreServices/CoreServices.h AudioToolbox/AudioToolbox.h],
@@ -205,7 +222,8 @@ if test "$debugging" = "enabled"; then
CFLAGS="$CFLAGS -g"
# gcc specific...
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
@@ -268,10 +286,30 @@ case $target in
*-pc-cygwin*)
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])
cpu_type="generic_fpu"
CFLAGS="$CFLAGS -DGENERIC"
CFLAGS="-DGENERIC $CFLAGS"
;;
esac
@@ -393,36 +431,28 @@ AC_DEFINE_UNQUOTED(INDEX_SIZE, $seektable, [size of the frame index seek table])
dnl ############## Audio Sub-system Settings
# Choose audio subsystem based on Operating System
case $target in
*-*-linux*)
# Choose audio subsystem based on what we have.
if test "x$HAVE_ALSA" = "xyes"; then
audio_system="alsa"
else
elif test "x$HAVE_OSS" = "xyes"; then
audio_system="oss"
fi
;;
*-*-freebsd*)
audio_system="oss"
;;
*-*-kfreebsd*)
audio_system="oss"
;;
*-apple-darwin*)
elif test "x$HAVE_MACOSXAUDIO" = "xyes"; then
audio_system="macosx"
;;
*-*-solaris*)
elif test "x$HAVE_SUNAUDIO" = "xyes"; then
audio_system="sun"
;;
# esd has been assumed to be the one for cygwin, but plain OSS does it
# can even make mpg123 run "natively" with a cygwin.dll
*-*-cygwin*)
audio_system="oss"
;;
*)
audio_system="dummy"
;;
esac
elif test "x$HAVE_JACK" = "xyes"; then
audio_system="jack"
elif test "x$HAVE_PORTAUDIO" = "xyes"; then
audio_system="portaudio"
elif test "x$HAVE_NAS" = "xyes"; then
audio_system="nas"
elif test "x$HAVE_SDL" = "xyes"; then
audio_system="sdl"
elif test "x$HAVE_ESOUND" = "xyes"; then
audio_system="esd"
fi
# Did user choose other audio type ?
if test "x$with_audio" != "x"; then
@@ -430,7 +460,6 @@ if test "x$with_audio" != "x"; then
fi
AUDIO_OBJ="audio_$audio_system.\$(OBJEXT)"
AUDIO_CFLAGS=""
AUDIO_LIBS=""
@@ -455,7 +484,7 @@ case $audio_system in
;;
esd)
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
AUDIO_CFLAGS=$ESOUND_CFLAGS
AUDIO_LIBS=$ESOUND_LIBS
@@ -508,10 +537,13 @@ case $audio_system in
fi
AUDIO_CFLAGS=""
AUDIO_LIBS="-lportaudio"
if test "x$HAVE_PORTAUDIO_WINMM" = "xyes"; then
AUDIO_LIBS="$AUDIO_LIBS -lwinmm"
fi
;;
sdl)
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
AUDIO_CFLAGS=$SDL_CFLAGS
AUDIO_LIBS=$SDL_LIBS

View File

@@ -5,8 +5,8 @@
## initially written by Nicholas J. Humfrey
AM_CFLAGS = @AUDIO_CFLAGS@
AM_LDFLAGS = @AUDIO_LIBS@
mpg123_LDADD = @AUDIO_OBJ@ @CPU_TYPE_LIB@
#AM_LDFLAGS =
mpg123_LDADD = @AUDIO_OBJ@ @CPU_TYPE_LIB@ @AUDIO_LIBS@
mpg123_DEPENDENCIES = @AUDIO_OBJ@ @CPU_TYPE_LIB@
EXTRA_DIST = Makefile.legacy config.h.legacy
@@ -200,3 +200,8 @@ libcpu_x86_a_SOURCES = \
tabinit_mmx.S \
equalizer_3dnow.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 "debug.h"
#ifdef WIN32
#include <windows.h>
#endif
#define SAMPLE_SIZE (2)
#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 */
while (sfifo_space( &fifo ) < len ) {
#ifdef WIN32
Sleep( (FIFO_DURATION/2) * 1000);
#else
usleep( (FIFO_DURATION/2) * 1000000 );
#endif
}
/* Write the audio to the ring buffer */

View File

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

View File

@@ -16,11 +16,30 @@
#ifndef _MPG123_BUFFER_H_
#define _MPG123_BUFFER_H_
void buffer_ignore_lowmem(void);
void buffer_end(void);
void buffer_resync(void);
void buffer_reset(void);
void buffer_start(void);
void buffer_stop(void);
#ifndef NOXFERMEM
void real_buffer_ignore_lowmem(void);
void real_buffer_end(void);
void real_buffer_resync(void);
void real_plain_buffer_resync(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

View File

@@ -27,6 +27,10 @@
#include "common.h"
#include "debug.h"
#ifdef WIN32
#include <winsock.h>
#endif
/* bitrates for [mpeg1/2][layer] */
int tabsel_123[2][3][16] = {
{ {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 <sys/time.h>
#include <sys/types.h>
#ifndef WIN32
#include <sys/wait.h>
#include <sys/socket.h>
#else
#include <winsock.h>
#endif
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/socket.h>
#include "config.h"
#include "mpg123.h"
#include "common.h"
#include "buffer.h"
#include "icy.h"
#include "debug.h"
#ifdef GAPLESS
@@ -102,7 +107,11 @@ int control_generic (struct frame *fr)
else
outstream = stdout;
#ifndef WIN32
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 */
/* now also with version for command availability */
fprintf(outstream, "@R MPG123 (ThOr) v2\n");
@@ -221,17 +230,11 @@ int control_generic (struct frame *fr)
if (mode == MODE_PLAYING) {
mode = MODE_PAUSED;
audio_flush(param.outmode, &ai);
#ifndef NOXFERMEM
if (param.usebuffer)
kill(buffer_pid, SIGSTOP);
#endif
buffer_stop();
generic_sendmsg("P 1");
} else {
mode = MODE_PLAYING;
#ifndef NOXFERMEM
if (param.usebuffer)
kill(buffer_pid, SIGCONT);
#endif
buffer_start();
generic_sendmsg("P 2");
}
}

View File

@@ -33,7 +33,7 @@
#include "mangle.h"
#ifdef __CYGWIN__
#if defined(__CYGWIN__) || defined(__MINGW32__)
.comm buffs.40,4352
#else
.local buffs.40

View File

@@ -33,7 +33,7 @@
#include "mangle.h"
.bss
#ifdef __CYGWIN__
#if defined(__CYGWIN__) || defined(__MINGW32__)
.comm buffs,4352
#else
.comm buffs,4352,4

View File

@@ -30,7 +30,7 @@
#include "mangle.h"
.bss
#ifdef __CYGWIN__
#if defined(__CYGWIN__) || defined(__MINGW32__)
.comm buffs,4352
.comm ditherindex.1,4
#else

View File

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

View File

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

View File

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

View File

@@ -112,7 +112,7 @@ static int testEndian(void)
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 */
#endif
if(!strcmp("-",filename)) {