Line | |
---|
1 | //driver_esd.c: |
---|
2 | |
---|
3 | #include "roard.h" |
---|
4 | #ifdef ROAR_HAVE_LIBAO |
---|
5 | |
---|
6 | int driver_ao_open(DRIVER_USERDATA_T * inst, char * device, struct roar_audio_info * info) { |
---|
7 | ao_device * aodevice; |
---|
8 | ao_sample_format format; |
---|
9 | int driver; |
---|
10 | |
---|
11 | ao_initialize(); |
---|
12 | |
---|
13 | if ( device == NULL ) { |
---|
14 | driver = ao_default_driver_id(); |
---|
15 | } else { |
---|
16 | if ( (driver = ao_driver_id(device)) == -1 ) { |
---|
17 | ROAR_ERR("Can not open audio device via libao's driver '%s'", device); |
---|
18 | return -1; |
---|
19 | } |
---|
20 | } |
---|
21 | |
---|
22 | format.bits = info->bits; |
---|
23 | format.channels = info->channels; |
---|
24 | format.rate = info->rate; |
---|
25 | format.byte_format = AO_FMT_NATIVE; |
---|
26 | |
---|
27 | aodevice = ao_open_live(driver, &format, NULL /* no options */); |
---|
28 | |
---|
29 | if ( aodevice == NULL ) { |
---|
30 | ROAR_ERR("Can not open audio device via libao."); |
---|
31 | return -1; |
---|
32 | } |
---|
33 | |
---|
34 | *((ao_device**)inst) = aodevice; |
---|
35 | |
---|
36 | return 0; |
---|
37 | } |
---|
38 | |
---|
39 | int driver_ao_close(DRIVER_USERDATA_T inst) { |
---|
40 | |
---|
41 | ao_close((ao_device*)inst); |
---|
42 | |
---|
43 | ao_shutdown(); |
---|
44 | |
---|
45 | return -1; |
---|
46 | } |
---|
47 | |
---|
48 | int driver_ao_pause(DRIVER_USERDATA_T inst, int newstate) { |
---|
49 | return -1; |
---|
50 | } |
---|
51 | |
---|
52 | int driver_ao_write(DRIVER_USERDATA_T inst, char * buf, int len) { |
---|
53 | return ao_play((ao_device*)inst, buf, len); |
---|
54 | } |
---|
55 | |
---|
56 | int driver_ao_read(DRIVER_USERDATA_T inst, char * buf, int len) { |
---|
57 | return -1; |
---|
58 | } |
---|
59 | |
---|
60 | int driver_ao_flush(DRIVER_USERDATA_T inst) { |
---|
61 | return 0; |
---|
62 | } |
---|
63 | |
---|
64 | #endif |
---|
65 | //ll |
---|
Note: See
TracBrowser
for help on using the repository browser.