[xmp] Add Amiga AHI driver

Signed-off-by: Claudio Matsuoka <cmatsuoka@gmail.com>
master
Claudio Matsuoka 14 years ago
parent 5bd1ed9d9a
commit 333f9c8d3e
  1. 4
      configure.ac
  2. 90
      src/drivers/amiga.c
  3. 4
      src/sound.c
  4. 88
      src/sound_ahi.c

@ -56,6 +56,10 @@ if test "${ac_cv_header_alsa_asoundlib_h}" = "yes"; then
fi
case "${host_os}" in
amigaos*|aros)
DRIVERS="${DRIVERS} sound_ahi.o"
AC_DEFINE(DRIVER_AHI)
;;
darwin*)
AC_CHECK_HEADER(CoreAudio/CoreAudio.h)
if test "${ac_cv_header_CoreAudio_CoreAudio_h}" = "yes"; then

@ -1,90 +0,0 @@
/* Amiga AHI driver for Extended Module Player
* Copyright (C) 2007 Lorence Lombardo
*
* This file is part of the Extended Module Player and is distributed
* under the terms of the GNU General Public License. See doc/COPYING
* for more information.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include "common.h"
#include "driver.h"
#include "mixer.h"
#include "convert.h"
static int fd;
static int init(struct context_data *);
static void bufdump(struct context_data *, void *, int);
static void shutdown(struct context_data *);
static void dummy()
{
}
static char *help[] = {
"buffer=val", "Audio buffer size",
NULL
};
struct xmp_drv_info drv_amiga = {
"ahi", /* driver ID */
"Amiga AHI audio", /* driver description */
help, /* help */
init, /* init */
shutdown, /* shutdown */
dummy, /* starttimer */
dummy, /* stoptimer */
dummy, /* resetvoices */
bufdump, /* bufdump */
NULL
};
static int init(struct context_data *ctx)
{
struct xmp_options *o = &ctx->o;
char outfile[256];
int nch = o->outfmt & XMP_FORMAT_MONO ? 1 : 2;
int bsize = o->freq * nch * o->resol / 4;
char *token, **parm;
parm_init();
chkparm1("buffer", bsize = strtoul(token, NULL, 0));
parm_end();
sprintf(outfile, "AUDIO:B/%d/F/%d/C/%d/BUFFER/%d",
o->resol, o->freq, nch, bsize);
fd = open(outfile, O_WRONLY);
return 0;
}
static void bufdump(struct context_data *ctx, void *b, int i)
{
int j;
while (i) {
if ((j = write(fd, b, i)) > 0) {
i -= j;
b = (char *)b + j;
} else
break;
}
}
static void shutdown(struct context_data *ctx)
{
if (fd)
close(fd);
}

@ -11,6 +11,7 @@ extern struct sound_driver sound_sndio;
extern struct sound_driver sound_solaris;
extern struct sound_driver sound_bsd;
extern struct sound_driver sound_beos;
extern struct sound_driver sound_amiga;
LIST_HEAD(sound_driver_list);
@ -21,6 +22,9 @@ static void register_sound_driver(struct sound_driver *sd)
void init_sound_drivers()
{
#ifdef SOUND_AHI
register_sound_driver(&sound_ahi);
#endif
#ifdef SOUND_BEOS
register_sound_driver(&sound_beos);
#endif

@ -0,0 +1,88 @@
/* Amiga AHI driver for Extended Module Player
* Copyright (C) 2007 Lorence Lombardo
*
* This file is part of the Extended Module Player and is distributed
* under the terms of the GNU General Public License. See doc/COPYING
* for more information.
*/
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include "sound.h"
static int fd;
static int init(struct options *options)
{
char **parm = options->driver_parm;
char outfile[256];
int nch = options->format & XMP_FORMAT_MONO ? 1 : 2;
int res = options->format & XMP_FORMAT_8BIT ? 8 : 16;
int bsize = options->rate * nch * res / 4;
parm_init(parm);
chkparm1("buffer", bsize = strtoul(token, NULL, 0));
parm_end();
sprintf(outfile, "AUDIO:B/%d/F/%d/C/%d/BUFFER/%d",
res, options->rate, nch, bsize);
fd = open(outfile, O_WRONLY);
if (fd < 0)
return -1;
return 0;
}
static void play(void *b, int i)
{
int j;
while (i) {
if ((j = write(fd, b, i)) > 0) {
i -= j;
b = (char *)b + j;
} else
break;
}
}
static void deinit()
{
close(fd);
}
static void flush()
{
}
static void onpause()
{
}
static void onresume()
{
}
static char *help[] = {
"buffer=val", "Audio buffer size",
NULL
};
struct sound_driver sound_ahi = {
"ahi",
"Amiga AHI audio",
help,
init,
deinit,
play,
flush,
onpause,
onresume
};
Loading…
Cancel
Save