Skip to content

Commit bd7676c

Browse files
authored
change sound_driver description into a driver specific function call (#66)
1 parent 041ee9f commit bd7676c

25 files changed

+148
-35
lines changed

src/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ int main(int argc, char **argv)
335335
report("Extended Module Player " VERSION "\n"
336336
"Copyright (C) 1996-2016 Claudio Matsuoka and Hipolito Carraro Jr\n");
337337

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

340340
report("Mixer set to %d Hz, %dbit, %s%s%s\n", opt.rate,
341341
opt.format & XMP_FORMAT_8BIT ? 8 : 16,

src/options.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,13 @@ static void usage(char *s, struct options *options)
5959

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

6565
for (i = 0; sound_driver_list[i] != NULL; i++) {
6666
sd = sound_driver_list[i];
6767
if (sd->help)
68-
printf("\n%s options:\n", sd->description);
68+
printf("\n%s options:\n", sd->description());
6969
for (hlp = sd->help; hlp && *hlp; hlp += 2)
7070
printf(" -D%-20.20s %s\n", hlp[0], hlp[1]);
7171
}

src/sound.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
struct sound_driver {
99
const char *id;
10-
const char *description;
1110
const char *const *help;
11+
const char * (*description)(void);
1212
int (*init)(struct options *);
1313
void (*deinit)(void);
1414
void (*play)(void *, int);
@@ -23,7 +23,7 @@ extern const struct sound_driver sound_aiff;
2323
extern const struct sound_driver sound_file;
2424
extern const struct sound_driver sound_qnx;
2525
extern const struct sound_driver sound_alsa05;
26-
extern struct sound_driver sound_oss;
26+
extern const struct sound_driver sound_oss;
2727
extern const struct sound_driver sound_alsa;
2828
extern const struct sound_driver sound_os2dart;
2929
extern const struct sound_driver sound_win32;

src/sound_ahi.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,15 +137,18 @@ static void onpause(void) {
137137
static void onresume(void) {
138138
}
139139

140+
static const char *description(void) {
141+
return "Amiga AHI audio";
142+
}
143+
140144
const struct sound_driver sound_ahi = {
141145
"ahi",
142-
"Amiga AHI audio",
143146
NULL,
147+
description,
144148
init,
145149
deinit,
146150
play,
147151
flush,
148152
onpause,
149153
onresume
150154
};
151-

src/sound_aiff.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,15 @@ static void onresume(void)
152152
{
153153
}
154154

155+
static const char *description(void)
156+
{
157+
return "AIFF writer";
158+
}
159+
155160
const struct sound_driver sound_aiff = {
156161
"aiff",
157-
"AIFF writer",
158162
NULL,
163+
description,
159164
init,
160165
deinit,
161166
play,

src/sound_aix.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,11 @@ static void onresume(void)
118118
{
119119
}
120120

121+
static const char *description(void)
122+
{
123+
return "AIX PCM audio";
124+
}
125+
121126
static const char *const help[] = {
122127
"gain=val", "Audio output gain (0 to 255)",
123128
/* "buffer=val", "Audio buffer size (default is 32768)", */
@@ -126,8 +131,8 @@ static const char *const help[] = {
126131

127132
const struct sound_driver sound_bsd = {
128133
"aix",
129-
"AIX PCM audio",
130134
help,
135+
description,
131136
init,
132137
deinit,
133138
play,

src/sound_alsa.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,11 @@ static void onresume(void)
109109
{
110110
}
111111

112+
static const char *description(void)
113+
{
114+
return "ALSA PCM audio";
115+
}
116+
112117
static const char *const help[] = {
113118
"buffer=num", "Set the ALSA buffer time in milliseconds",
114119
"period=num", "Set the ALSA period time in milliseconds",
@@ -118,12 +123,13 @@ static const char *const help[] = {
118123

119124
const struct sound_driver sound_alsa = {
120125
"alsa",
121-
"ALSA PCM audio",
122126
help,
127+
description,
123128
init,
124129
deinit,
125130
play,
126131
flush,
127132
onpause,
128133
onresume
129134
};
135+

src/sound_alsa05.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,11 @@ static void flush(void)
194194
prepare_driver();
195195
}
196196

197+
static const char *description(void)
198+
{
199+
return "ALSA 0.5 PCM audio";
200+
}
201+
197202
static const char *const help[] = {
198203
"frag=num,size", "Set the number and size (bytes) of fragments",
199204
"card <name>", "Select sound card to use",
@@ -202,8 +207,8 @@ static const char *const help[] = {
202207

203208
const struct sound_driver sound_alsa05 = {
204209
"alsa05", /* driver ID */
205-
"ALSA 0.5 PCM audio", /* driver description */
206210
help, /* help */
211+
description, /* driver description */
207212
init, /* init */
208213
dshutdown, /* shutdown */
209214
dummy, /* starttimer */

src/sound_beos.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ static const char *const help[] = {
3535
NULL
3636
};
3737

38+
static const char *description(void);
3839
static int init(struct options *options);
3940
static void deinit(void);
4041
static void play(void *b, int i);
@@ -44,8 +45,8 @@ static void onresume(void);
4445

4546
const struct sound_driver sound_beos = {
4647
"beos",
47-
"BeOS PCM audio",
4848
help,
49+
description,
4950
init,
5051
deinit,
5152
play,
@@ -205,3 +206,8 @@ static void onpause(void)
205206
static void onresume(void)
206207
{
207208
}
209+
210+
static const char *description(void)
211+
{
212+
return "BeOS PCM audio";
213+
}

src/sound_bsd.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,11 @@ static void onresume(void)
9494
{
9595
}
9696

97+
static const char *description(void)
98+
{
99+
return "BSD PCM audio";
100+
}
101+
97102
static const char *const help[] = {
98103
"gain=val", "Audio output gain (0 to 255)",
99104
"buffer=val", "Audio buffer size (default is 32768)",
@@ -102,8 +107,8 @@ static const char *const help[] = {
102107

103108
const struct sound_driver sound_bsd = {
104109
"bsd",
105-
"BSD PCM audio",
106110
help,
111+
description,
107112
init,
108113
deinit,
109114
play,

0 commit comments

Comments
 (0)