X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=sndout.c;fp=sndout.c;h=ba34f3c7f81792f5273bf7f9a8aab4c5cfb5e8f1;hb=26d3ca0d29e87a14943d29fcafc93da753df60cd;hp=0000000000000000000000000000000000000000;hpb=20b143089cc395dbcd51cac516a9e36f4ab6f5ac;p=libpicofe.git diff --git a/sndout.c b/sndout.c new file mode 100644 index 0000000..ba34f3c --- /dev/null +++ b/sndout.c @@ -0,0 +1,80 @@ +/* + * (C) notaz, 2013 + * + * This work is licensed under the terms of any of these licenses + * (at your option): + * - GNU GPL, version 2 or later. + * - GNU LGPL, version 2.1 or later. + * - MAME license. + * See the COPYING file in the top-level directory. + */ + +#include +#include + +#include "linux/sndout_oss.h" +#include "sndout_sdl.h" +#include "sndout.h" + +static int sndout_null_init(void) +{ + return 0; +} + +static void sndout_null_exit(void) +{ +} + +static int sndout_null_start(int rate, int stereo) +{ + return 0; +} + +static void sndout_null_stop(void) +{ +} + +static void sndout_null_wait(void) +{ +} + +static int sndout_null_write_nb(const void *data, int bytes) +{ + return bytes; +} + +#define SNDOUT_DRIVER(name) { \ + #name, \ + sndout_##name##_init, \ + sndout_##name##_exit, \ + sndout_##name##_start, \ + sndout_##name##_stop, \ + sndout_##name##_wait, \ + sndout_##name##_write_nb, \ +} + +static struct sndout_driver sndout_avail[] = +{ +#ifdef HAVE_SDL + SNDOUT_DRIVER(sdl), +#endif +#ifdef HAVE_OSS + SNDOUT_DRIVER(oss), +#endif + SNDOUT_DRIVER(null) +}; + +struct sndout_driver sndout_current; + +void sndout_init(void) +{ + int i; + + for (i = 0; i < sizeof(sndout_avail) / sizeof(sndout_avail[0]); i++) { + if (sndout_avail[i].init() == 0) + break; + } + + memcpy(&sndout_current, &sndout_avail[i], sizeof(sndout_current)); + printf("using %s audio output driver\n", sndout_current.name); +}