From 07c13dfd11cbd45e96a5c21cd88ccd44601678ea Mon Sep 17 00:00:00 2001 From: notaz Date: Mon, 30 Jul 2012 21:29:29 +0300 Subject: allow multiple sound drivers to be compiled --- plugins/dfsound/out.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 plugins/dfsound/out.c (limited to 'plugins/dfsound/out.c') diff --git a/plugins/dfsound/out.c b/plugins/dfsound/out.c new file mode 100644 index 0000000..150d718 --- /dev/null +++ b/plugins/dfsound/out.c @@ -0,0 +1,51 @@ +#include +#include +#include "out.h" + +#define MAX_OUT_DRIVERS 5 + +static struct out_driver out_drivers[MAX_OUT_DRIVERS]; +struct out_driver *out_current; +static int driver_count; + +#define REGISTER_DRIVER(d) { \ + extern void out_register_##d(struct out_driver *drv); \ + out_register_##d(&out_drivers[driver_count++]); \ +} + +void SetupSound(void) +{ + int i; + + if (driver_count == 0) { +#ifdef HAVE_OSS + REGISTER_DRIVER(oss); +#endif +#ifdef HAVE_ALSA + REGISTER_DRIVER(alsa); +#endif +#ifdef HAVE_SDL + REGISTER_DRIVER(sdl); +#endif +#ifdef HAVE_PULSE + REGISTER_DRIVER(pulse); +#endif +#ifdef HAVE_LIBRETRO + REGISTER_DRIVER(libretro); +#endif + REGISTER_DRIVER(none); + } + + for (i = 0; i < driver_count; i++) + if (out_drivers[i].init() == 0) + break; + + if (i < 0 || i >= driver_count) { + printf("the impossible happened\n"); + abort(); + } + + out_current = &out_drivers[i]; + printf("selected sound output driver: %s\n", out_current->name); +} + -- cgit v1.2.3