29 |
#include <ao/ao.h> |
#include <ao/ao.h> |
30 |
#include <sys/time.h> |
#include <sys/time.h> |
31 |
|
|
32 |
#define WAVEOUTBUF 16 |
#define WAVEOUTLEN 16 |
33 |
|
|
34 |
static ao_device *o_device = NULL; |
static ao_device *o_device = NULL; |
35 |
static int default_driver; |
static int default_driver; |
55 |
format.bits = 16; |
format.bits = 16; |
56 |
format.channels = 2; |
format.channels = 2; |
57 |
format.rate = 44100; |
format.rate = 44100; |
58 |
format.byte_format = AO_FMT_LITTLE; |
format.byte_format = AO_FMT_NATIVE; |
59 |
|
|
60 |
|
|
61 |
o_device = ao_open_live(default_driver, &format, NULL); |
o_device = ao_open_live(default_driver, &format, NULL); |
62 |
if (o_device == NULL) |
if (o_device == NULL) |
65 |
} |
} |
66 |
|
|
67 |
g_dsp_fd = 0; |
g_dsp_fd = 0; |
|
rdpsnd_queue_init(); |
|
68 |
|
|
69 |
reopened = True; |
reopened = True; |
70 |
|
|
77 |
/* Ack all remaining packets */ |
/* Ack all remaining packets */ |
78 |
while (!rdpsnd_queue_empty()) |
while (!rdpsnd_queue_empty()) |
79 |
{ |
{ |
80 |
rdpsnd_send_completion(rdpsnd_queue_current_packet()->tick, |
rdpsnd_queue_next(0); |
|
rdpsnd_queue_current_packet()->index); |
|
|
rdpsnd_queue_next(); |
|
81 |
} |
} |
82 |
|
|
83 |
if (o_device != NULL) |
if (o_device != NULL) |
94 |
format.bits = pwfx->wBitsPerSample; |
format.bits = pwfx->wBitsPerSample; |
95 |
format.channels = pwfx->nChannels; |
format.channels = pwfx->nChannels; |
96 |
format.rate = 44100; |
format.rate = 44100; |
97 |
format.byte_format = AO_FMT_LITTLE; |
format.byte_format = AO_FMT_NATIVE; |
98 |
|
|
99 |
if (o_device != NULL) |
if (o_device != NULL) |
100 |
ao_close(o_device); |
ao_close(o_device); |
145 |
|
|
146 |
next_tick = rdpsnd_queue_next_tick(); |
next_tick = rdpsnd_queue_next_tick(); |
147 |
|
|
148 |
len = (WAVEOUTBUF > (out->end - out->p)) ? (out->end - out->p) : WAVEOUTBUF; |
len = (WAVEOUTLEN > (out->end - out->p)) ? (out->end - out->p) : WAVEOUTLEN; |
149 |
ao_play(o_device, (char *) out->p, len); |
ao_play(o_device, (char *) out->p, len); |
150 |
out->p += len; |
out->p += len; |
151 |
|
|
168 |
(packet->tick + duration) % 65536, next_tick % 65536)); |
(packet->tick + duration) % 65536, next_tick % 65536)); |
169 |
} |
} |
170 |
|
|
171 |
rdpsnd_send_completion(((packet->tick + duration) % 65536), packet->index); |
rdpsnd_queue_next(duration); |
|
rdpsnd_queue_next(); |
|
172 |
} |
} |
173 |
|
|
174 |
g_dsp_busy = 1; |
g_dsp_busy = 1; |
175 |
return; |
return; |
176 |
} |
} |
177 |
|
|
178 |
|
static struct audio_driver libao_driver = { |
179 |
|
.name = "libao", |
180 |
|
.description = "libao output driver, default device: system dependent", |
181 |
|
|
182 |
|
.wave_out_open = libao_open, |
183 |
|
.wave_out_close = libao_close, |
184 |
|
.wave_out_format_supported = rdpsnd_dsp_resample_supported, |
185 |
|
.wave_out_set_format = libao_set_format, |
186 |
|
.wave_out_volume = rdpsnd_dsp_softvol_set, |
187 |
|
.wave_out_play = libao_play, |
188 |
|
|
189 |
|
.need_byteswap_on_be = 1, |
190 |
|
.need_resampling = 1, |
191 |
|
}; |
192 |
|
|
193 |
struct audio_driver * |
struct audio_driver * |
194 |
libao_register(char *options) |
libao_register(char *options) |
195 |
{ |
{ |
|
static struct audio_driver libao_driver; |
|
|
struct ao_info *libao_info; |
|
|
static char description[101]; |
|
|
|
|
|
libao_driver.wave_out_write = rdpsnd_queue_write; |
|
|
libao_driver.wave_out_open = libao_open; |
|
|
libao_driver.wave_out_close = libao_close; |
|
|
libao_driver.wave_out_format_supported = rdpsnd_dsp_resample_supported; |
|
|
libao_driver.wave_out_set_format = libao_set_format; |
|
|
libao_driver.wave_out_volume = rdpsnd_dsp_softvol_set; |
|
|
libao_driver.wave_out_play = libao_play; |
|
|
libao_driver.name = xstrdup("libao"); |
|
|
libao_driver.description = description; |
|
|
libao_driver.need_byteswap_on_be = 0; |
|
|
libao_driver.need_resampling = 1; |
|
|
libao_driver.next = NULL; |
|
|
|
|
|
ao_initialize(); |
|
|
|
|
|
libao_info = ao_driver_info(ao_default_driver_id()); |
|
|
|
|
|
if (libao_info) |
|
|
{ |
|
|
snprintf(description, 100, "libao output driver, default device: %s", |
|
|
libao_info->short_name); |
|
|
} |
|
|
else |
|
|
{ |
|
|
snprintf(description, 100, "libao output driver, default device: none"); |
|
|
} |
|
|
|
|
|
ao_shutdown(); |
|
|
|
|
196 |
if (options) |
if (options) |
197 |
{ |
{ |
198 |
libao_device = xstrdup(options); |
libao_device = xstrdup(options); |