| 1 | #include <stdio.h> |
| 2 | #include <stdlib.h> |
| 3 | #include "out.h" |
| 4 | |
| 5 | #define MAX_OUT_DRIVERS 5 |
| 6 | |
| 7 | static struct out_driver out_drivers[MAX_OUT_DRIVERS]; |
| 8 | struct out_driver *out_current; |
| 9 | static int driver_count; |
| 10 | |
| 11 | #define REGISTER_DRIVER(d) { \ |
| 12 | extern void out_register_##d(struct out_driver *drv); \ |
| 13 | out_register_##d(&out_drivers[driver_count++]); \ |
| 14 | } |
| 15 | |
| 16 | void SetupSound(void) |
| 17 | { |
| 18 | int i; |
| 19 | |
| 20 | if (driver_count == 0) { |
| 21 | #ifdef HAVE_OSS |
| 22 | REGISTER_DRIVER(oss); |
| 23 | #endif |
| 24 | #ifdef HAVE_ALSA |
| 25 | REGISTER_DRIVER(alsa); |
| 26 | #endif |
| 27 | #ifdef HAVE_SDL |
| 28 | REGISTER_DRIVER(sdl); |
| 29 | #endif |
| 30 | #ifdef HAVE_PULSE |
| 31 | REGISTER_DRIVER(pulse); |
| 32 | #endif |
| 33 | #ifdef HAVE_LIBRETRO |
| 34 | REGISTER_DRIVER(libretro); |
| 35 | #endif |
| 36 | REGISTER_DRIVER(none); |
| 37 | } |
| 38 | |
| 39 | for (i = 0; i < driver_count; i++) |
| 40 | if (out_drivers[i].init() == 0) |
| 41 | break; |
| 42 | |
| 43 | if (i < 0 || i >= driver_count) { |
| 44 | printf("the impossible happened\n"); |
| 45 | abort(); |
| 46 | } |
| 47 | |
| 48 | out_current = &out_drivers[i]; |
| 49 | printf("selected sound output driver: %s\n", out_current->name); |
| 50 | } |
| 51 | |