support multiple sound drivers, add sdl
[libpicofe.git] / sndout.c
CommitLineData
26d3ca0d
GI
1/*
2 * (C) notaz, 2013
3 *
4 * This work is licensed under the terms of any of these licenses
5 * (at your option):
6 * - GNU GPL, version 2 or later.
7 * - GNU LGPL, version 2.1 or later.
8 * - MAME license.
9 * See the COPYING file in the top-level directory.
10 */
11
12#include <stdio.h>
13#include <string.h>
14
15#include "linux/sndout_oss.h"
16#include "sndout_sdl.h"
17#include "sndout.h"
18
19static int sndout_null_init(void)
20{
21 return 0;
22}
23
24static void sndout_null_exit(void)
25{
26}
27
28static int sndout_null_start(int rate, int stereo)
29{
30 return 0;
31}
32
33static void sndout_null_stop(void)
34{
35}
36
37static void sndout_null_wait(void)
38{
39}
40
41static int sndout_null_write_nb(const void *data, int bytes)
42{
43 return bytes;
44}
45
46#define SNDOUT_DRIVER(name) { \
47 #name, \
48 sndout_##name##_init, \
49 sndout_##name##_exit, \
50 sndout_##name##_start, \
51 sndout_##name##_stop, \
52 sndout_##name##_wait, \
53 sndout_##name##_write_nb, \
54}
55
56static struct sndout_driver sndout_avail[] =
57{
58#ifdef HAVE_SDL
59 SNDOUT_DRIVER(sdl),
60#endif
61#ifdef HAVE_OSS
62 SNDOUT_DRIVER(oss),
63#endif
64 SNDOUT_DRIVER(null)
65};
66
67struct sndout_driver sndout_current;
68
69void sndout_init(void)
70{
71 int i;
72
73 for (i = 0; i < sizeof(sndout_avail) / sizeof(sndout_avail[0]); i++) {
74 if (sndout_avail[i].init() == 0)
75 break;
76 }
77
78 memcpy(&sndout_current, &sndout_avail[i], sizeof(sndout_current));
79 printf("using %s audio output driver\n", sndout_current.name);
80}