parent
5bd1ed9d9a
commit
333f9c8d3e
4 changed files with 96 additions and 90 deletions
@ -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); |
||||
} |
||||
@ -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…
Reference in new issue