File: plugout.c

package info (click to toggle)
gbsplay 0.0.102-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 704 kB
  • sloc: ansic: 8,341; sh: 1,319; makefile: 543; xml: 13
file content (128 lines) | stat: -rw-r--r-- 2,670 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/*
 * gbsplay is a Gameboy sound player
 *
 * 2003-2021 (C) by Tobias Diedrich <ranma+gbsplay@tdiedrich.de>
 *                  Christian Garbs <mitch@cgarbs.de>
 *
 * Licensed under GNU GPL v1 or, at your option, any later version.
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "common.h"
#include "plugout.h"

#ifdef PLUGOUT_ALSA
extern const struct output_plugin plugout_alsa;
#endif
#ifdef PLUGOUT_DEVDSP
extern const struct output_plugin plugout_devdsp;
#endif
#ifdef PLUGOUT_DSOUND
extern const struct output_plugin plugout_dsound;
#endif
#ifdef PLUGOUT_IODUMPER
extern const struct output_plugin plugout_iodumper;
#endif
#ifdef PLUGOUT_MIDI
extern const struct output_plugin plugout_midi;
#endif
#ifdef PLUGOUT_ALTMIDI
extern const struct output_plugin plugout_altmidi;
#endif
#ifdef PLUGOUT_NAS
extern const struct output_plugin plugout_nas;
#endif
#ifdef PLUGOUT_PIPEWIRE
extern const struct output_plugin plugout_pipewire;
#endif
#ifdef PLUGOUT_PULSE
extern const struct output_plugin plugout_pulse;
#endif
#ifdef PLUGOUT_SDL
extern const struct output_plugin plugout_sdl;
#endif
#ifdef PLUGOUT_STDOUT
extern const struct output_plugin plugout_stdout;
#endif
#ifdef PLUGOUT_VGM
extern const struct output_plugin plugout_vgm;
#endif
#ifdef PLUGOUT_WAV
extern const struct output_plugin plugout_wav;
#endif

typedef const struct output_plugin* output_plugin_const_t;

/* in order of preference, see also PLUGOUT_DEFAULT in plugout.h */
static output_plugin_const_t plugouts[] = {
#ifdef PLUGOUT_DSOUND
	&plugout_dsound,
#endif
#ifdef PLUGOUT_PULSE
	&plugout_pulse,
#endif
#ifdef PLUGOUT_ALSA
	&plugout_alsa,
#endif
#ifdef PLUGOUT_DEVDSP
	&plugout_devdsp,
#endif
#ifdef PLUGOUT_STDOUT
	&plugout_stdout,
#endif
#ifdef PLUGOUT_PIPEWIRE
	&plugout_pipewire,
#endif
#ifdef PLUGOUT_NAS
	&plugout_nas,
#endif
#ifdef PLUGOUT_MIDI
	&plugout_midi,
#endif
#ifdef PLUGOUT_ALTMIDI
	&plugout_altmidi,
#endif
#ifdef PLUGOUT_IODUMPER
	&plugout_iodumper,
#endif
#ifdef PLUGOUT_SDL
	&plugout_sdl,
#endif
#ifdef PLUGOUT_VGM
	&plugout_vgm,
#endif
#ifdef PLUGOUT_WAV
	&plugout_wav,
#endif
	NULL
};

void plugout_list_plugins(void)
{
	long idx;

	printf("%s", _("Available output plugins:\n\n"));

	if (plugouts[0] == NULL) {
		printf("%s", _("No output plugins available.\n\n"));
		return;
	}

	for (idx = 0; plugouts[idx] != NULL; idx++) {
		printf("%-8s - %s\n", plugouts[idx]->name, plugouts[idx]->description);
	}
	(void)puts("");
}

const struct output_plugin* plugout_select_by_name(const char* const name)
{
	long idx;

	for (idx = 0; plugouts[idx] != NULL &&
	              strcmp(plugouts[idx]->name, name) != 0; idx++);

	return plugouts[idx];
}