forked from notaz/libpicofe
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsndout.c
84 lines (70 loc) · 1.42 KB
/
sndout.c
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
/*
* (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 <stdio.h>
#include <string.h>
#include "linux/sndout_oss.h"
#include "linux/sndout_alsa.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_ALSA
SNDOUT_DRIVER(alsa),
#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);
}