36 |
static BOOL reopened; |
static BOOL reopened; |
37 |
static char *libao_device = NULL; |
static char *libao_device = NULL; |
38 |
|
|
39 |
|
void libao_play(void); |
40 |
|
|
41 |
|
void |
42 |
|
libao_add_fds(int *n, fd_set * rfds, fd_set * wfds, struct timeval *tv) |
43 |
|
{ |
44 |
|
/* We need to be called rather often... */ |
45 |
|
FD_SET(0, wfds); |
46 |
|
} |
47 |
|
|
48 |
|
void |
49 |
|
libao_check_fds(fd_set * rfds, fd_set * wfds) |
50 |
|
{ |
51 |
|
if (o_device == NULL) |
52 |
|
return; |
53 |
|
|
54 |
|
if (!rdpsnd_queue_empty()) |
55 |
|
libao_play(); |
56 |
|
} |
57 |
|
|
58 |
BOOL |
BOOL |
59 |
libao_open(void) |
libao_open(void) |
60 |
{ |
{ |
83 |
return False; |
return False; |
84 |
} |
} |
85 |
|
|
|
g_dsp_fd = 0; |
|
|
|
|
86 |
reopened = True; |
reopened = True; |
87 |
|
|
88 |
return True; |
return True; |
100 |
if (o_device != NULL) |
if (o_device != NULL) |
101 |
ao_close(o_device); |
ao_close(o_device); |
102 |
|
|
103 |
|
o_device = NULL; |
104 |
|
|
105 |
ao_shutdown(); |
ao_shutdown(); |
106 |
} |
} |
107 |
|
|
153 |
prev_us = tv.tv_usec; |
prev_us = tv.tv_usec; |
154 |
} |
} |
155 |
|
|
156 |
|
/* We shouldn't be called if the queue is empty, but still */ |
157 |
if (rdpsnd_queue_empty()) |
if (rdpsnd_queue_empty()) |
|
{ |
|
|
g_dsp_busy = 0; |
|
158 |
return; |
return; |
|
} |
|
159 |
|
|
160 |
packet = rdpsnd_queue_current_packet(); |
packet = rdpsnd_queue_current_packet(); |
161 |
out = &packet->s; |
out = &packet->s; |
175 |
|
|
176 |
if ((out->p == out->end) || duration > next_tick - packet->tick + 500) |
if ((out->p == out->end) || duration > next_tick - packet->tick + 500) |
177 |
{ |
{ |
178 |
|
unsigned int delay_us; |
179 |
|
|
180 |
prev_s = tv.tv_sec; |
prev_s = tv.tv_sec; |
181 |
prev_us = tv.tv_usec; |
prev_us = tv.tv_usec; |
182 |
|
|
187 |
(packet->tick + duration) % 65536, next_tick % 65536)); |
(packet->tick + duration) % 65536, next_tick % 65536)); |
188 |
} |
} |
189 |
|
|
190 |
rdpsnd_queue_next(duration); |
delay_us = ((out->size / 4) * (1000000 / 44100)); |
|
} |
|
191 |
|
|
192 |
g_dsp_busy = 1; |
rdpsnd_queue_next(delay_us); |
193 |
return; |
} |
194 |
} |
} |
195 |
|
|
|
static struct audio_driver libao_driver = { |
|
|
.name = "libao", |
|
|
.description = "libao output driver, default device: system dependent", |
|
|
|
|
|
.wave_out_open = libao_open, |
|
|
.wave_out_close = libao_close, |
|
|
.wave_out_format_supported = rdpsnd_dsp_resample_supported, |
|
|
.wave_out_set_format = libao_set_format, |
|
|
.wave_out_volume = rdpsnd_dsp_softvol_set, |
|
|
.wave_out_play = libao_play, |
|
|
|
|
|
.need_byteswap_on_be = 1, |
|
|
.need_resampling = 1, |
|
|
}; |
|
|
|
|
196 |
struct audio_driver * |
struct audio_driver * |
197 |
libao_register(char *options) |
libao_register(char *options) |
198 |
{ |
{ |
199 |
|
static struct audio_driver libao_driver; |
200 |
|
|
201 |
|
libao_driver.name = xstrdup("libao"); |
202 |
|
libao_driver.description = xstrdup("libao output driver, default device: system dependent"); |
203 |
|
|
204 |
|
libao_driver.add_fds = libao_add_fds; |
205 |
|
libao_driver.check_fds = libao_check_fds; |
206 |
|
|
207 |
|
libao_driver.wave_out_open = libao_open; |
208 |
|
libao_driver.wave_out_close = libao_close; |
209 |
|
libao_driver.wave_out_format_supported = rdpsnd_dsp_resample_supported; |
210 |
|
libao_driver.wave_out_set_format = libao_set_format; |
211 |
|
libao_driver.wave_out_volume = rdpsnd_dsp_softvol_set; |
212 |
|
|
213 |
|
libao_driver.need_byteswap_on_be = 1; |
214 |
|
libao_driver.need_resampling = 1; |
215 |
|
|
216 |
if (options) |
if (options) |
217 |
{ |
{ |
218 |
libao_device = xstrdup(options); |
libao_device = xstrdup(options); |