Skip to content

Commit

Permalink
change sound_driver description into a driver specific function call (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
sezero authored Sep 6, 2024
1 parent 041ee9f commit bd7676c
Show file tree
Hide file tree
Showing 25 changed files with 148 additions and 35 deletions.
2 changes: 1 addition & 1 deletion src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ int main(int argc, char **argv)
report("Extended Module Player " VERSION "\n"
"Copyright (C) 1996-2016 Claudio Matsuoka and Hipolito Carraro Jr\n");

report("Using %s\n", sound->description);
report("Using %s\n", sound->description());

report("Mixer set to %d Hz, %dbit, %s%s%s\n", opt.rate,
opt.format & XMP_FORMAT_8BIT ? 8 : 16,
Expand Down
4 changes: 2 additions & 2 deletions src/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ static void usage(char *s, struct options *options)

for (i = 0; sound_driver_list[i] != NULL; i++) {
sd = sound_driver_list[i];
printf(" %s (%s)\n", sd->id, sd->description);
printf(" %s (%s)\n", sd->id, sd->description());
}

for (i = 0; sound_driver_list[i] != NULL; i++) {
sd = sound_driver_list[i];
if (sd->help)
printf("\n%s options:\n", sd->description);
printf("\n%s options:\n", sd->description());
for (hlp = sd->help; hlp && *hlp; hlp += 2)
printf(" -D%-20.20s %s\n", hlp[0], hlp[1]);
}
Expand Down
4 changes: 2 additions & 2 deletions src/sound.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

struct sound_driver {
const char *id;
const char *description;
const char *const *help;
const char * (*description)(void);
int (*init)(struct options *);
void (*deinit)(void);
void (*play)(void *, int);
Expand All @@ -23,7 +23,7 @@ extern const struct sound_driver sound_aiff;
extern const struct sound_driver sound_file;
extern const struct sound_driver sound_qnx;
extern const struct sound_driver sound_alsa05;
extern struct sound_driver sound_oss;
extern const struct sound_driver sound_oss;
extern const struct sound_driver sound_alsa;
extern const struct sound_driver sound_os2dart;
extern const struct sound_driver sound_win32;
Expand Down
7 changes: 5 additions & 2 deletions src/sound_ahi.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,15 +137,18 @@ static void onpause(void) {
static void onresume(void) {
}

static const char *description(void) {
return "Amiga AHI audio";
}

const struct sound_driver sound_ahi = {
"ahi",
"Amiga AHI audio",
NULL,
description,
init,
deinit,
play,
flush,
onpause,
onresume
};

7 changes: 6 additions & 1 deletion src/sound_aiff.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,15 @@ static void onresume(void)
{
}

static const char *description(void)
{
return "AIFF writer";
}

const struct sound_driver sound_aiff = {
"aiff",
"AIFF writer",
NULL,
description,
init,
deinit,
play,
Expand Down
7 changes: 6 additions & 1 deletion src/sound_aix.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@ static void onresume(void)
{
}

static const char *description(void)
{
return "AIX PCM audio";
}

static const char *const help[] = {
"gain=val", "Audio output gain (0 to 255)",
/* "buffer=val", "Audio buffer size (default is 32768)", */
Expand All @@ -126,8 +131,8 @@ static const char *const help[] = {

const struct sound_driver sound_bsd = {
"aix",
"AIX PCM audio",
help,
description,
init,
deinit,
play,
Expand Down
8 changes: 7 additions & 1 deletion src/sound_alsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,11 @@ static void onresume(void)
{
}

static const char *description(void)
{
return "ALSA PCM audio";
}

static const char *const help[] = {
"buffer=num", "Set the ALSA buffer time in milliseconds",
"period=num", "Set the ALSA period time in milliseconds",
Expand All @@ -118,12 +123,13 @@ static const char *const help[] = {

const struct sound_driver sound_alsa = {
"alsa",
"ALSA PCM audio",
help,
description,
init,
deinit,
play,
flush,
onpause,
onresume
};

7 changes: 6 additions & 1 deletion src/sound_alsa05.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,11 @@ static void flush(void)
prepare_driver();
}

static const char *description(void)
{
return "ALSA 0.5 PCM audio";
}

static const char *const help[] = {
"frag=num,size", "Set the number and size (bytes) of fragments",
"card <name>", "Select sound card to use",
Expand All @@ -202,8 +207,8 @@ static const char *const help[] = {

const struct sound_driver sound_alsa05 = {
"alsa05", /* driver ID */
"ALSA 0.5 PCM audio", /* driver description */
help, /* help */
description, /* driver description */
init, /* init */
dshutdown, /* shutdown */
dummy, /* starttimer */
Expand Down
8 changes: 7 additions & 1 deletion src/sound_beos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ static const char *const help[] = {
NULL
};

static const char *description(void);
static int init(struct options *options);
static void deinit(void);
static void play(void *b, int i);
Expand All @@ -44,8 +45,8 @@ static void onresume(void);

const struct sound_driver sound_beos = {
"beos",
"BeOS PCM audio",
help,
description,
init,
deinit,
play,
Expand Down Expand Up @@ -205,3 +206,8 @@ static void onpause(void)
static void onresume(void)
{
}

static const char *description(void)
{
return "BeOS PCM audio";
}
7 changes: 6 additions & 1 deletion src/sound_bsd.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ static void onresume(void)
{
}

static const char *description(void)
{
return "BSD PCM audio";
}

static const char *const help[] = {
"gain=val", "Audio output gain (0 to 255)",
"buffer=val", "Audio buffer size (default is 32768)",
Expand All @@ -102,8 +107,8 @@ static const char *const help[] = {

const struct sound_driver sound_bsd = {
"bsd",
"BSD PCM audio",
help,
description,
init,
deinit,
play,
Expand Down
7 changes: 6 additions & 1 deletion src/sound_coreaudio.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,10 +267,15 @@ static void onresume(void)
AudioOutputUnitStart(au);
}

static const char *description(void)
{
return "CoreAudio sound output";
}

const struct sound_driver sound_coreaudio = {
"coreaudio",
"CoreAudio sound output",
NULL,
description,
init,
deinit,
play,
Expand Down
7 changes: 6 additions & 1 deletion src/sound_dart.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,11 @@ static void onresume(void)
{
}

static const char *description(void)
{
return "OS/2 Direct Audio Realtime";
}

static const char *const help[] = {
"sharing={Y,N}", "Device Sharing (default is N)",
"device=val", "OS/2 Audio Device (default is 0 auto-detect)",
Expand All @@ -221,8 +226,8 @@ static const char *const help[] = {

const struct sound_driver sound_os2dart = {
"dart",
"OS/2 Direct Audio Realtime",
help,
description,
init,
deinit,
play,
Expand Down
7 changes: 6 additions & 1 deletion src/sound_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ static void onresume(void)
{
}

static const char *description(void)
{
return "Raw file writer";
}

static const char * const help[] = {
"endian=big", "Force big-endian 16-bit samples",
"endian=little", "Force little-endian 16-bit samples",
Expand All @@ -80,8 +85,8 @@ static const char * const help[] = {

const struct sound_driver sound_file = {
"file",
"Raw file writer",
help,
description,
init,
deinit,
play,
Expand Down
8 changes: 7 additions & 1 deletion src/sound_hpux.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,11 @@ static void onresume(void)
{
}

static const char *description(void)
{
return "HP-UX PCM audio";
}

static const char *const help[] = {
"gain=val", "Audio output gain (0 to 255)",
"port={s|h|l}", "Audio port (s[peaker], h[eadphones], l[ineout])",
Expand All @@ -148,12 +153,13 @@ static const char *const help[] = {

const struct sound_driver sound_hpux = {
"hpux",
"HP-UX PCM audio",
help,
description,
init,
deinit,
play,
flush,
onpause,
onresume
};

7 changes: 6 additions & 1 deletion src/sound_netbsd.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@ static void onresume(void)
{
}

static const char *description(void)
{
return "NetBSD PCM audio";
}

static const char *const help[] = {
"gain=val", "Audio output gain (0 to 255)",
"buffer=val", "Audio buffer size (default is 32768)",
Expand All @@ -132,8 +137,8 @@ static const char *const help[] = {

const struct sound_driver sound_netbsd = {
"netbsd",
"NetBSD PCM audio",
help,
description,
init,
deinit,
play,
Expand Down
7 changes: 6 additions & 1 deletion src/sound_null.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,20 @@ static void onresume(void)
{
}

static const char *description(void)
{
return "null output";
}

const struct sound_driver sound_null = {
"null",
"null output",
NULL,
description,
init,
deinit,
play,
flush,
onpause,
onresume
};

Loading

0 comments on commit bd7676c

Please sign in to comment.