source: roaraudio/roard/driver_ao.c @ 425:57125d94a1b5

Last change on this file since 425:57125d94a1b5 was 425:57125d94a1b5, checked in by phi, 16 years ago

added #ifdef ROAR_HAVE_LIBAO to driver_ao.c

File size: 1.2 KB
Line 
1//driver_esd.c:
2
3#include "roard.h"
4#ifdef ROAR_HAVE_LIBAO
5
6int 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
39int driver_ao_close(DRIVER_USERDATA_T   inst) {
40
41 ao_close((ao_device*)inst);
42
43 ao_shutdown();
44
45 return -1;
46}
47
48int driver_ao_pause(DRIVER_USERDATA_T   inst, int newstate) {
49 return -1;
50}
51
52int driver_ao_write(DRIVER_USERDATA_T   inst, char * buf, int len) {
53 return ao_play((ao_device*)inst, buf, len);
54}
55
56int driver_ao_read(DRIVER_USERDATA_T   inst, char * buf, int len) {
57 return -1;
58}
59
60int 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.