[xmp] Fixes for mingw32 build

Signed-off-by: Claudio Matsuoka <cmatsuoka@gmail.com>
master
Claudio Matsuoka 14 years ago
parent 4325121556
commit 2d642f015c
  1. 2
      Makefile.in
  2. 22
      configure.ac
  3. 2
      src/Makefile
  4. 5
      src/commands.c
  5. 22
      src/main.c
  6. 80
      src/sound_win32.c
  7. 9
      src/terminal.c

@ -1,7 +1,7 @@
VERSION = 3.9.0
CC = @CC@
CFLAGS = -c -Wall @CFLAGS@ @DEFS@ @CPPFLAGS@
CFLAGS = -c -Wall @CFLAGS@ @DEFS@ @CPPFLAGS@ -DSOUND_DRIVER=$(DRIVER)
LD = @CC@
LDFLAGS = @LDFLAGS@
LIBS = @LIBS@

@ -12,7 +12,12 @@ if test "$libxmp_path" != ""; then
LIBS="${LIBS} -L${libxmp_path}/lib"
fi
AC_CHECK_HEADERS(xmp.h getopt.h signal.h termios.h alsa/asoundlib.h CoreAudio/CoreAudio.h)
AC_CHECK_HEADERS(xmp.h getopt.h signal.h termios.h)
AC_CHECK_HEADER(windows.h,,[
AC_CHECK_HEADER(CoreAudio/CoreAudio.h,,[
AC_CHECK_HEADER(alsa/asoundlib.h)
])
])
if test "${ac_cv_header_xmp_h}" = "yes"; then
AC_CHECK_LIB(xmp,xmp_player_start,,
@ -21,18 +26,19 @@ else
AC_MSG_ERROR(Can't find libxmp header files)
fi
if test "${ac_cv_header_alsa_asoundlib_h}" = "yes"; then
if test "${ac_cv_header_windows_h}" = "yes"; then
AC_SUBST(SOUND_DRIVER,sound_win32)
LIBS="${LIBS} -lwinmm"
elif test "${ac_cv_header_CoreAudio_CoreAudio_h}" = "yes"; then
AC_SUBST(SOUND_DRIVER,sound_coreaudio)
LIBS="${LIBS} -framework AudioToolbox -framework AudioUnit -framework CoreServices"
elif test "${ac_cv_header_alsa_asoundlib_h}" = "yes"; then
AC_SUBST(SOUND_DRIVER,sound_alsa)
AC_CHECK_LIB(asound,snd_pcm_open,,
AC_MSG_ERROR(Can't find libasound))
fi
if test "${ac_cv_header_CoreAudio_CoreAudio_h}" = "yes"; then
AC_SUBST(SOUND_DRIVER,sound_coreaudio)
LIBS="${LIBS} -framework AudioToolbox -framework AudioUnit -framework CoreServices"
fi
AC_CHECK_FUNCS(getopt_long)
AC_CHECK_FUNCS(kill getopt_long)
AC_PROG_INSTALL
AC_CONFIG_FILES([Makefile])

@ -12,7 +12,7 @@ dist-src:
cp -RPp $(addprefix $(SRC_PATH)/,$(SRC_DFILES)) $(DIST)/$(SRC_PATH)
$(SRC_PATH)/xmp: $(OBJS) $(SRC_PATH)/$(DRIVER).o
@CMD='$(LD) -o $@ $(LDFLAGS) $(OBJS) $(SRC_PATH)/$(DRIVER).o $(LIBS) -lasound'; \
@CMD='$(LD) -o $@ $(LDFLAGS) $(OBJS) $(SRC_PATH)/$(DRIVER).o $(LIBS)'; \
if [ "$(V)" -gt 0 ]; then echo $$CMD; else echo LD $@ ; fi; \
eval $$CMD

@ -1,4 +1,7 @@
#include <unistd.h>
#ifdef WIN32
#include <conio.h>
#endif
#include <xmp.h>
#include "common.h"
@ -56,7 +59,7 @@ static int read_key()
ret = read(0, &key, 1);
#elif defined WIN32
if (kbhit()) {
cmd = getch();
key = getch();
ret = 1;
}
#elif defined __AMIGA__

@ -11,11 +11,15 @@
#include "sound.h"
#include "common.h"
#ifdef WIN32
#include <windows.h>
#endif
extern int optind;
extern struct sound_driver sound_alsa;
extern struct sound_driver SOUND_DRIVER;
extern struct sound_driver sound_null;
struct sound_driver *sound = &sound_alsa;
struct sound_driver *sound = &SOUND_DRIVER;
static int background = 0;
static int refresh_status;
@ -25,7 +29,9 @@ static void cleanup(int sig)
{
signal(SIGTERM, SIG_DFL);
signal(SIGINT, SIG_DFL);
#ifdef SIGQUIT
signal(SIGQUIT, SIG_DFL);
#endif
signal(SIGFPE, SIG_DFL);
signal(SIGSEGV, SIG_DFL);
@ -33,7 +39,9 @@ static void cleanup(int sig)
reset_tty();
signal(sig, SIG_DFL);
#ifdef HAVE_KILL
kill(getpid(), sig);
#endif
}
#endif
@ -42,18 +50,20 @@ static void sigtstp_handler(int n)
{
fprintf(stderr, "\n");
signal(SIGTSTP, SIG_DFL);
#ifdef HAVE_KILL
kill(getpid(), SIGTSTP);
#endif
}
static void sigcont_handler(int sig)
{
#ifndef __AMIGA__
#ifdef HAVE_TERMIOS_H
background = (tcgetpgrp(0) == getppid());
#endif
if (!background) {
set_tty();
}
#endif
refresh_status = 1;
@ -179,18 +189,22 @@ int main(int argc, char **argv)
signal(SIGINT, cleanup);
signal(SIGFPE, cleanup);
signal(SIGSEGV, cleanup);
#ifdef SIGQUIT
signal(SIGQUIT, cleanup);
#endif
#ifdef SIGTSTP
signal(SIGCONT, sigcont_handler);
signal(SIGTSTP, sigtstp_handler);
#endif
#endif
#ifdef HAVE_TERMIOS_H
background = (tcgetpgrp (0) == getppid ());
if (!background) {
set_tty();
}
#endif
handle = xmp_create_context();

@ -14,13 +14,16 @@
#endif
#include <windows.h>
#include "common.h"
#include "driver.h"
#include "mixer.h"
#include <stdio.h>
#include "sound.h"
#define MAXBUFFERS 32 /* max number of buffers */
#define BUFFERSIZE 120 /* buffer size in ms */
/* frame rate = (50 * bpm / 125) Hz */
/* frame size = (sampling rate * channels * size) / frame rate */
#define OUT_MAXLEN 0x8000
static HWAVEOUT hwaveout;
static WAVEHDR header[MAXBUFFERS];
static LPSTR buffer[MAXBUFFERS]; /* pointers to buffers */
@ -28,30 +31,11 @@ static WORD freebuffer; /* */
static WORD nextbuffer; /* next buffer to be mixed */
static int num_buffers;
static int init(struct context_data *);
static void bufdump(struct context_data *, void *, int);
static void deinit(struct context_data *);
static void dummy()
{
}
static char *help[] = {
"buffers=val", "Number of buffers (default 10)",
NULL
};
struct xmp_drv_info drv_win32 = {
"win32", /* driver ID */
"Windows WinMM driver", /* driver description */
help, /* help */
init, /* init */
deinit, /* shutdown */
dummy, /* starttimer */
dummy, /* flush */
bufdump, /* bufdump */
};
static void show_error(int res)
{
char *msg;
@ -91,30 +75,29 @@ static void CALLBACK wave_callback(HWAVEOUT hwo, UINT uMsg, DWORD dwInstance,
}
}
static int init(struct context_data *ctx)
static int init(int *sampling_rate, int *format)
{
struct xmp_options *o = &ctx->o;
MMRESULT res;
WAVEFORMATEX wfe;
int i;
char *token, **parm;
//char *token, **parm;
num_buffers = 10;
parm_init();
chkparm1("buffers", num_buffers = strtoul(token, NULL, 0));
parm_end();
//parm_init();
//chkparm1("buffers", num_buffers = strtoul(token, NULL, 0));
//parm_end();
if (num_buffers > MAXBUFFERS)
num_buffers = MAXBUFFERS;
if (!waveOutGetNumDevs())
return XMP_ERR_DINIT;
return -1;
wfe.wFormatTag = WAVE_FORMAT_PCM;
wfe.wBitsPerSample = o->resol;
wfe.nChannels = o->flags & XMP_FORMAT_MONO ? 1 : 2;
wfe.nSamplesPerSec = o->freq;
wfe.wBitsPerSample = *format & XMP_FORMAT_8BIT ? 8 : 16;
wfe.nChannels = *format & XMP_FORMAT_MONO ? 1 : 2;
wfe.nSamplesPerSec = *sampling_rate;
wfe.nAvgBytesPerSec = wfe.nSamplesPerSec * wfe.nChannels *
wfe.wBitsPerSample / 8;
wfe.nBlockAlign = wfe.nChannels * wfe.wBitsPerSample / 8;
@ -124,7 +107,7 @@ static int init(struct context_data *ctx)
if (res != MMSYSERR_NOERROR) {
show_error(res);
return XMP_ERR_DINIT;
return -1;
}
waveOutReset(hwaveout);
@ -135,7 +118,7 @@ static int init(struct context_data *ctx)
if (!buffer[i] || res != MMSYSERR_NOERROR) {
show_error(res);
return XMP_ERR_DINIT;
return -1;
}
}
@ -144,7 +127,7 @@ static int init(struct context_data *ctx)
return 0;
}
static void bufdump(struct context_data *ctx, void *b, int len)
static void play(void *b, int len)
{
memcpy(buffer[nextbuffer], b, len);
@ -159,7 +142,7 @@ static void bufdump(struct context_data *ctx, void *b, int len)
nextbuffer %= num_buffers;
}
static void deinit(struct context_data *ctx)
static void deinit()
{
int i;
@ -175,3 +158,28 @@ static void deinit(struct context_data *ctx)
hwaveout = NULL;
}
}
static void flush()
{
}
static void onpause()
{
}
static void onresume()
{
}
struct sound_driver sound_win32 = {
"win32",
"Windows WinMM",
help,
init,
deinit,
play,
flush,
onpause,
onresume
};

@ -1,12 +1,16 @@
#include <stdio.h>
#include <termios.h>
#include <xmp.h>
#include "common.h"
#ifdef HAVE_TERMIOS_H
#include <termios.h>
static struct termios term;
#endif
int set_tty()
{
#ifdef HAVE_TERMIOS_H
struct termios t;
if (tcgetattr(0, &term) < 0)
@ -18,16 +22,19 @@ int set_tty()
if (tcsetattr(0, TCSAFLUSH, &t) < 0)
return -1;
#endif
return 0;
}
int reset_tty()
{
#ifdef HAVE_TERMIOS_H
if (tcsetattr(0, TCSAFLUSH, &term) < 0) {
fprintf(stderr, "can't reset terminal!\n");
return -1;
}
#endif
return 0;
}

Loading…
Cancel
Save