Skip to content

Commit 78e2b9c

Browse files
committed
Warn when a PSG filter inadvertently replaces a previous one
Multiple filters using the --psg-mix, --psg-balance, or --psg-volume options cannot be combined. The last option given replaces any previous ones.
1 parent 633f1ab commit 78e2b9c

1 file changed

Lines changed: 15 additions & 4 deletions

File tree

system/unix/option.c

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,15 @@ void *psg_mix_arg(void)
280280
return NULL;
281281
}
282282

283+
static void set_psg_mix(const char *psg_mix)
284+
{
285+
if (option.psg_mix && strcmp(option.psg_mix, psg_mix) != 0)
286+
pr_warn("PSG filter \"%s\" replaces \"%s\"\n",
287+
psg_mix, option.psg_mix);
288+
289+
option.psg_mix = psg_mix;
290+
}
291+
283292
struct options *parse_options(int argc, char **argv)
284293
{
285294
static const struct option options[] = {
@@ -320,7 +329,7 @@ struct options *parse_options(int argc, char **argv)
320329

321330
option.track = -1;
322331
option.frequency = 44100;
323-
option.psg_mix = "empiric";
332+
option.psg_mix = NULL;
324333

325334
for (;;) {
326335
int index = 0;
@@ -362,14 +371,14 @@ struct options *parse_options(int argc, char **argv)
362371
else if (OPT("frequency"))
363372
goto opt_f;
364373
else if (OPT("psg-mix"))
365-
option.psg_mix = optarg;
374+
set_psg_mix(optarg);
366375
else if (OPT("psg-balance")) {
367376
option.psg_balance = psg_balance_option(optarg);
368-
option.psg_mix = "balance";
377+
set_psg_mix("balance");
369378
}
370379
else if (OPT("psg-volume")) {
371380
option.psg_volume = psg_volume_option(optarg);
372-
option.psg_mix = "volume";
381+
set_psg_mix("volume");
373382
}
374383

375384
else if (OPT("trace"))
@@ -418,6 +427,8 @@ opt_f: option.frequency = atoi(optarg);
418427

419428
#undef OPT
420429
out:
430+
if (!option.psg_mix)
431+
set_psg_mix("empiric");
421432

422433
if (optind == argc)
423434
pr_fatal_error("missing input SNDH file\n");

0 commit comments

Comments
 (0)