1 /*
2  * gbsplay is a Gameboy sound player
3  *
4  * 2003-2005,2013,2018 (C) by Tobias Diedrich <ranma+gbsplay@tdiedrich.de>
5  *                            Christian Garbs <mitch@cgarbs.de>
6  * Licensed under GNU GPL v1 or, at your option, any later version.
7  */
8 
9 #include "common.h"
10 
11 #include <stdio.h>
12 #include <stdlib.h>
13 #include <string.h>
14 
15 #include "plugout.h"
16 
17 #ifdef PLUGOUT_ALSA
18 extern const struct output_plugin plugout_alsa;
19 #endif
20 #ifdef PLUGOUT_DEVDSP
21 extern const struct output_plugin plugout_devdsp;
22 #endif
23 #ifdef PLUGOUT_DSOUND
24 extern const struct output_plugin plugout_dsound;
25 #endif
26 #ifdef PLUGOUT_IODUMPER
27 extern const struct output_plugin plugout_iodumper;
28 #endif
29 #ifdef PLUGOUT_MIDI
30 extern const struct output_plugin plugout_midi;
31 #endif
32 #ifdef PLUGOUT_ALTMIDI
33 extern const struct output_plugin plugout_altmidi;
34 #endif
35 #ifdef PLUGOUT_NAS
36 extern const struct output_plugin plugout_nas;
37 #endif
38 #ifdef PLUGOUT_PULSE
39 extern const struct output_plugin plugout_pulse;
40 #endif
41 #ifdef PLUGOUT_STDOUT
42 extern const struct output_plugin plugout_stdout;
43 #endif
44 
45 typedef /*@null@*/ const struct output_plugin* output_plugin_const_t;
46 
47 /* in order of preference, see also PLUGOUT_DEFAULT in plugout.h */
48 static output_plugin_const_t plugouts[] = {
49 #ifdef PLUGOUT_DSOUND
50 	&plugout_dsound,
51 #endif
52 #ifdef PLUGOUT_PULSE
53 	&plugout_pulse,
54 #endif
55 #ifdef PLUGOUT_ALSA
56 	&plugout_alsa,
57 #endif
58 #ifdef PLUGOUT_DEVDSP
59 	&plugout_devdsp,
60 #endif
61 #ifdef PLUGOUT_STDOUT
62 	&plugout_stdout,
63 #endif
64 #ifdef PLUGOUT_NAS
65 	&plugout_nas,
66 #endif
67 #ifdef PLUGOUT_MIDI
68 	&plugout_midi,
69 #endif
70 #ifdef PLUGOUT_ALTMIDI
71 	&plugout_altmidi,
72 #endif
73 #ifdef PLUGOUT_IODUMPER
74 	&plugout_iodumper,
75 #endif
76 	NULL
77 };
78 
plugout_list_plugins(void)79 regparm void plugout_list_plugins(void)
80 {
81 	long idx;
82 
83 	printf("%s", _("Available output plugins:\n\n"));
84 
85 	if (plugouts[0] == NULL) {
86 		printf("%s", _("No output plugins available.\n\n"));
87 		return;
88 	}
89 
90 	for (idx = 0; plugouts[idx] != NULL; idx++) {
91 		printf("%-8s - %s\n", plugouts[idx]->name, plugouts[idx]->description);
92 	}
93 	(void)puts("");
94 }
95 
plugout_select_by_name(const char * name)96 regparm const struct output_plugin* plugout_select_by_name(const char *name)
97 {
98 	long idx;
99 
100 	for (idx = 0; plugouts[idx] != NULL &&
101 	              strcmp(plugouts[idx]->name, name) != 0; idx++);
102 
103 	return plugouts[idx];
104 }
105