1 | #include "esd.h" |
---|
2 | #include "config.h" |
---|
3 | |
---|
4 | #include <stdio.h> |
---|
5 | #include <stdlib.h> |
---|
6 | #include <unistd.h> |
---|
7 | #include <fcntl.h> |
---|
8 | #include <sys/ioctl.h> |
---|
9 | #include <math.h> |
---|
10 | |
---|
11 | /*******************************************************************/ |
---|
12 | /* globals */ |
---|
13 | esd_format_t esd_audio_format = ESD_BITS16 | ESD_STEREO; |
---|
14 | int esd_audio_rate = ESD_DEFAULT_RATE; |
---|
15 | char *esd_audio_device = NULL; /* aux device spec: /dev/dsp2, lineout, etc. */ |
---|
16 | |
---|
17 | /* the audio device, /dev/dsp, file descriptor */ |
---|
18 | static int esd_audio_fd = -1; |
---|
19 | |
---|
20 | /*******************************************************************/ |
---|
21 | /* returns audio_fd for use by main prog - platform dependent */ |
---|
22 | |
---|
23 | /* ALSA before OSS as ALSA is OSS compatible */ |
---|
24 | #if defined(DRIVER_ALSA) || defined(DRIVER_NEWALSA) |
---|
25 | # include "audio_alsa.c" |
---|
26 | #elif defined(DRIVER_ALSA_09) |
---|
27 | #include "audio_alsa09.c" |
---|
28 | #elif defined(DRIVER_OSS) |
---|
29 | # include "audio_oss.c" |
---|
30 | #elif defined(DRIVER_AIX) |
---|
31 | # include "audio_aix.c" |
---|
32 | #elif defined(DRIVER_IRIX) |
---|
33 | # include "audio_irix.c" |
---|
34 | #elif defined(DRIVER_HPUX) |
---|
35 | # include "audio_hpux.c" |
---|
36 | #elif defined(DRIVER_OSF) |
---|
37 | # include "audio_osf.c" |
---|
38 | #elif defined(DRIVER_SOLARIS) |
---|
39 | # include "audio_solaris.c" |
---|
40 | #elif defined(DRIVER_MKLINUX) |
---|
41 | # include "audio_mklinux.c" |
---|
42 | #elif defined(DRIVER_DART) |
---|
43 | # include "audio_dart.c" |
---|
44 | #else |
---|
45 | # include "audio_none.c" |
---|
46 | #endif |
---|
47 | |
---|
48 | /*******************************************************************/ |
---|
49 | /* display available devices */ |
---|
50 | #ifndef ARCH_esd_audio_devices |
---|
51 | const char * esd_audio_devices() |
---|
52 | { |
---|
53 | return "(default audio device)"; |
---|
54 | } |
---|
55 | #endif |
---|
56 | |
---|
57 | /*******************************************************************/ |
---|
58 | /* close the audio device */ |
---|
59 | #ifndef ARCH_esd_audio_close |
---|
60 | void esd_audio_close() |
---|
61 | { |
---|
62 | close( esd_audio_fd ); |
---|
63 | esd_audio_fd = -1; |
---|
64 | return; |
---|
65 | } |
---|
66 | #endif |
---|
67 | |
---|
68 | /*******************************************************************/ |
---|
69 | /* make the sound device quiet for a while */ |
---|
70 | #ifndef ARCH_esd_audio_pause |
---|
71 | void esd_audio_pause() |
---|
72 | { |
---|
73 | return; |
---|
74 | } |
---|
75 | #endif |
---|
76 | |
---|
77 | #ifndef ARCH_esd_audio_write |
---|
78 | /*******************************************************************/ |
---|
79 | /* dump a buffer to the sound device */ |
---|
80 | int esd_audio_write( void *buffer, int buf_size ) |
---|
81 | { |
---|
82 | return write( esd_audio_fd, buffer, buf_size ); |
---|
83 | } |
---|
84 | #endif |
---|
85 | |
---|
86 | #ifndef ARCH_esd_audio_read |
---|
87 | /*******************************************************************/ |
---|
88 | /* read a chunk from the sound device */ |
---|
89 | int esd_audio_read( void *buffer, int buf_size ) |
---|
90 | { |
---|
91 | return read( esd_audio_fd, buffer, buf_size ); |
---|
92 | } |
---|
93 | #endif |
---|
94 | |
---|
95 | #ifndef ARCH_esd_audio_flush |
---|
96 | /*******************************************************************/ |
---|
97 | /* flush the audio buffer */ |
---|
98 | void esd_audio_flush() |
---|
99 | { |
---|
100 | fsync( esd_audio_fd ); |
---|
101 | return; |
---|
102 | } |
---|
103 | #endif |
---|