[xmp] Add OpenBSD driver and change system detection

Signed-off-by: Claudio Matsuoka <cmatsuoka@gmail.com>
master
Claudio Matsuoka 14 years ago
parent f3cf3fc147
commit 62266f9633
  1. 3
      Makefile.in
  2. 1501
      config.guess
  3. 1705
      config.sub
  4. 90
      configure.ac
  5. 3
      src/Makefile
  6. 4
      src/sound.c
  7. 112
      src/sound_openbsd.c

@ -17,7 +17,8 @@ SYSCONFDIR = @sysconfdir@/xmp
SHELL = /bin/sh
DIST = xmp-$(VERSION)
DFILES = README INSTALL configure configure.ac Makefile.in install-sh
DFILES = README INSTALL configure config.sub config.guess install-sh \
configure.ac Makefile.in
DDIRS = src
V = 0
DRIVERS = @DRIVERS@

1501
config.guess vendored

File diff suppressed because it is too large Load Diff

1705
config.sub vendored

File diff suppressed because it is too large Load Diff

@ -5,6 +5,7 @@ AC_INIT
AC_ARG_WITH(libxmp, [ --with-libxmp=<path> libxmp prefix (optional)],
libxmp_path="$withval")
AC_CANONICAL_HOST
AC_PROG_CC
AC_C_BIGENDIAN(AC_DEFINE(ENDIAN_BIG))
@ -29,18 +30,6 @@ AC_DEFUN([AC_CHECK_DEFINED],[
AC_CHECK_HEADERS(xmp.h getopt.h signal.h termios.h)
system=unknown
AC_CHECK_DEFINED(_WIN32,[system=win32])
AC_CHECK_DEFINED(__BEOS__,[system=beos])
AC_CHECK_DEFINED(__HAIKU__,[system=beos])
if test "$system" = "unknown"; then
AC_CHECK_HEADER(CoreAudio/CoreAudio.h,,[
AC_CHECK_HEADERS(sys/soundcard.h alsa/asoundlib.h sndio.h sys/audioio.h)
])
fi
if test "${ac_cv_header_xmp_h}" = "yes"; then
AC_CHECK_LIB(xmp,xmp_player_start,,
AC_MSG_ERROR(Can't find libxmp))
@ -48,45 +37,62 @@ else
AC_MSG_ERROR(Can't find libxmp header files)
fi
case "$system" in
beos)
AC_DEFINE(SOUND_BEOS)
DRIVERS="${DRIVERS} sound_beos.o"
LIBS="${LIBS} -lmedia -lbe"
case "$host_cpu" in
powerpc64)
CFLAGS="${CFLAGS} -m64"
LDFLAGS="${LDFLAGS} -m64"
;;
win32)
AC_DEFINE(SOUND_WIN32)
DRIVERS="${DRIVERS} sound_win32.o"
LIBS="${LIBS} -lwinmm"
;;
*)
esac
AC_CHECK_HEADERS(sys/soundcard.h machine/soundcard.h alsa/asoundlib.h sys/audioio.h)
if test "${ac_cv_header_sys_soundcard_h}" = "yes" -o "${ac_cv_header_machine_soundcard_h}" = "yes"; then
AC_DEFINE(SOUND_OSS)
DRIVERS="${DRIVERS} sound_oss.o"
fi
if test "${ac_cv_header_alsa_asoundlib_h}" = "yes"; then
AC_DEFINE(SOUND_ALSA)
DRIVERS="${DRIVERS} sound_alsa.o"
LIBS="${LIBS} -lasound"
fi
case "${host_os}" in
darwin*)
AC_CHECK_HEADER(CoreAudio/CoreAudio.h)
if test "${ac_cv_header_CoreAudio_CoreAudio_h}" = "yes"; then
AC_DEFINE(SOUND_COREAUDIO)
DRIVERS="${DRIVERS} sound_coreaudio.o"
LIBS="${LIBS} -framework AudioToolbox -framework AudioUnit -framework CoreServices"
else
if test "${ac_cv_header_sndio_h}" = "yes"; then
AC_DEFINE(SOUND_SNDIO)
DRIVERS="${DRIVERS} sound_sndio.o"
LIBS="${LIBS} -lsndio"
fi
if test "${ac_cv_header_sys_audioio_h}" = "yes"; then
AC_DEFINE(SOUND_BSD)
DRIVERS="${DRIVERS} sound_bsd.o"
fi
if test "${ac_cv_header_sys_soundcard_h}" = "yes"; then
AC_DEFINE(SOUND_OSS)
DRIVERS="${DRIVERS} sound_oss.o"
fi
if test "${ac_cv_header_alsa_asoundlib_h}" = "yes"; then
AC_DEFINE(SOUND_ALSA)
DRIVERS="${DRIVERS} sound_alsa.o"
LIBS="${LIBS} -lasound"
fi
fi
;;
openbsd*)
AC_CHECK_HEADER(sndio.h)
if test "${ac_cv_header_sndio_h}" = "yes"; then
AC_DEFINE(SOUND_SNDIO)
DRIVERS="${DRIVERS} sound_sndio.o"
LIBS="${LIBS} -lsndio"
fi
if test "${ac_cv_header_sys_audioio_h}" = "yes"; then
AC_DEFINE(SOUND_OPENBSD)
DRIVERS="${DRIVERS} sound_openbsd.o"
fi
;;
cygwin*|mingw*)
AC_DEFINE(SOUND_WIN32)
DRIVERS="${DRIVERS} sound_win32.o"
LIBS="${LIBS} -lwinmm"
;;
beos*|haiku*)
AC_DEFINE(SOUND_BEOS)
DRIVERS="${DRIVERS} sound_beos.o"
LIBS="${LIBS} -lmedia -lbe"
;;
esac
if test -z "${DRIVERS}" -a "${ac_cv_header_sys_audioio_h}" = "yes"; then
AC_DEFINE(SOUND_BSD)
DRIVERS="${DRIVERS} sound_bsd.o"
fi
dnl XMP_TRY_COMPILE(<message>,<cache-var>,<flags>,<program>,<ifyes>,<ifno>)
define(XMP_TRY_COMPILE,[
AC_CACHE_CHECK([$1],[$2],[

@ -3,7 +3,8 @@ SRC_OBJS = sound.o sound_null.o terminal.o info.o commands.o \
options.o getopt.o getopt1.o main.o sound_wav.o
SRC_DFILES = Makefile xmp.1 $(SRC_OBJS:.o=.c) common.h getopt.h list.h \
sound.h sound_alsa.c sound_coreaudio.c sound_oss.c \
sound_sndio.c sound_bsd.c sound_solaris.c sound_beos.cpp
sound_sndio.c sound_openbsd.c sound_bsd.c sound_solaris.c \
sound_beos.cpp
SRC_PATH = src
SRC_OBJS += $(DRIVERS)

@ -8,6 +8,7 @@ extern struct sound_driver sound_alsa;
extern struct sound_driver sound_win32;
extern struct sound_driver sound_coreaudio;
extern struct sound_driver sound_sndio;
extern struct sound_driver sound_openbsd;
extern struct sound_driver sound_bsd;
extern struct sound_driver sound_beos;
@ -26,6 +27,9 @@ void init_sound_drivers()
#ifdef SOUND_SNDIO
register_sound_driver(&sound_sndio);
#endif
#ifdef SOUND_OPENBSD
register_sound_driver(&sound_openbsd);
#endif
#ifdef SOUND_BSD
register_sound_driver(&sound_bsd);
#endif

@ -17,52 +17,27 @@
#include <sys/audioio.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "common.h"
#include "driver.h"
#include "mixer.h"
#include "sound.h"
static int audio_fd;
static int init(struct context_data *);
static int setaudio(struct xmp_options *);
static void bufdump(struct context_data *, void *, int);
static void shutdown(struct context_data *);
static void dummy()
{
}
static char *help[] = {
"gain=val", "Audio output gain (0 to 255)",
"buffer=val", "Audio buffer size (default is 32768)",
NULL
};
struct xmp_drv_info drv_openbsd = {
"openbsd", /* driver ID */
"OpenBSD PCM audio", /* driver description */
help, /* help */
init, /* init */
shutdown, /* shutdown */
dummy, /* starttimer */
dummy, /* flush */
bufdump, /* bufdump */
};
struct sound_driver sound_openbsd;
static int setaudio(struct xmp_options *o)
static int init(struct options *options)
{
char **parm = options->driver_parm;
audio_info_t ainfo;
int gain = 128;
int bsize = 32 * 1024;
char *token, **parm;
parm_init();
if ((audio_fd = open("/dev/sound", O_WRONLY)) == -1)
return -1;
parm_init(parm);
chkparm1("gain", gain = strtoul(token, NULL, 0));
chkparm1("buffer", bsize = strtoul(token, NULL, 0));
parm_end();
@ -74,39 +49,33 @@ static int setaudio(struct xmp_options *o)
AUDIO_INITINFO(&ainfo);
ainfo.play.sample_rate = o->freq;
ainfo.play.channels = o->outfmt & XMP_FORMAT_MONO ? 1 : 2;
ainfo.play.precision = o->resol;
ainfo.play.encoding = o->resol > 8 ?
AUDIO_ENCODING_SLINEAR : AUDIO_ENCODING_ULINEAR;
ainfo.play.sample_rate = options->rate;
ainfo.play.channels = options->format & XMP_FORMAT_MONO ? 1 : 2;
if (options->format & XMP_FORMAT_8BIT) {
ainfo.play.precision = 8;
ainfo.play.encoding = AUDIO_ENCODING_ULINEAR;
options->format |= XMP_FORMAT_UNSIGNED;
} else {
ainfo.play.precision = 16;
ainfo.play.encoding = AUDIO_ENCODING_SLINEAR;
options->format &= ~XMP_FORMAT_UNSIGNED;
}
ainfo.play.gain = gain;
ainfo.play.buffer_size = bsize;
if (ioctl(audio_fd, AUDIO_SETINFO, &ainfo) == -1) {
close(audio_fd);
return XMP_ERR_DINIT;
return -1;
}
drv_openbsd.description = "OpenBSD PCM audio";
sound_openbsd.description = "OpenBSD PCM audio";
return 0;
}
static int init(struct context_data *ctx)
{
if ((audio_fd = open("/dev/sound", O_WRONLY)) == -1)
return XMP_ERR_DINIT;
if (setaudio(&ctx->o) != 0)
return XMP_ERR_DINIT;
return 0;
}
/* Build and write one tick (one PAL frame or 1/50 s in standard vblank
* timed mods) of audio data to the output device.
*/
static void bufdump(struct context_data *ctx, void *b, int i)
static void play(void *b, int i)
{
int j;
@ -119,7 +88,38 @@ static void bufdump(struct context_data *ctx, void *b, int i)
}
}
static void shutdown(struct context_data *ctx)
static void deinit()
{
close(audio_fd);
}
static void flush()
{
}
static void onpause()
{
}
static void onresume()
{
}
static char *help[] = {
"gain=val", "Audio output gain (0 to 255)",
"buffer=val", "Audio buffer size (default is 32768)",
NULL
};
struct sound_driver sound_openbsd = {
"openbsd",
"OpenBSD PCM audio",
help,
init,
deinit,
play,
flush,
onpause,
onresume
};
Loading…
Cancel
Save