37 |
static BOOL reopened; |
static BOOL reopened; |
38 |
static short samplewidth; |
static short samplewidth; |
39 |
static int audiochannels; |
static int audiochannels; |
40 |
|
static unsigned int rate; |
41 |
static char *pcm_name; |
static char *pcm_name; |
42 |
|
|
43 |
BOOL |
BOOL |
52 |
} |
} |
53 |
|
|
54 |
g_dsp_fd = 0; |
g_dsp_fd = 0; |
|
rdpsnd_queue_init(); |
|
55 |
|
|
56 |
reopened = True; |
reopened = True; |
57 |
|
|
63 |
{ |
{ |
64 |
/* Ack all remaining packets */ |
/* Ack all remaining packets */ |
65 |
while (!rdpsnd_queue_empty()) |
while (!rdpsnd_queue_empty()) |
66 |
{ |
rdpsnd_queue_next(0); |
|
rdpsnd_send_completion(rdpsnd_queue_current_packet()->tick, |
|
|
rdpsnd_queue_current_packet()->index); |
|
|
rdpsnd_queue_next(); |
|
|
} |
|
67 |
|
|
68 |
if (pcm_handle) |
if (pcm_handle) |
69 |
{ |
{ |
109 |
alsa_set_format(WAVEFORMATEX * pwfx) |
alsa_set_format(WAVEFORMATEX * pwfx) |
110 |
{ |
{ |
111 |
snd_pcm_hw_params_t *hwparams = NULL; |
snd_pcm_hw_params_t *hwparams = NULL; |
|
unsigned int rate, exact_rate; |
|
112 |
int err; |
int err; |
113 |
unsigned int buffertime; |
unsigned int buffertime; |
114 |
|
|
160 |
} |
} |
161 |
#endif |
#endif |
162 |
|
|
163 |
exact_rate = rate = pwfx->nSamplesPerSec; |
rate = pwfx->nSamplesPerSec; |
164 |
if ((err = snd_pcm_hw_params_set_rate_near(pcm_handle, hwparams, &exact_rate, 0)) < 0) |
if ((err = snd_pcm_hw_params_set_rate_near(pcm_handle, hwparams, &rate, 0)) < 0) |
165 |
{ |
{ |
166 |
error("snd_pcm_hw_params_set_rate_near: %s\n", snd_strerror(err)); |
error("snd_pcm_hw_params_set_rate_near: %s\n", snd_strerror(err)); |
167 |
return False; |
return False; |
249 |
|
|
250 |
if ((out->p == out->end) || duration > next_tick - packet->tick + 500) |
if ((out->p == out->end) || duration > next_tick - packet->tick + 500) |
251 |
{ |
{ |
252 |
|
snd_pcm_sframes_t delay_frames; |
253 |
|
unsigned long delay_us; |
254 |
|
|
255 |
prev_s = tv.tv_sec; |
prev_s = tv.tv_sec; |
256 |
prev_us = tv.tv_usec; |
prev_us = tv.tv_usec; |
257 |
|
|
262 |
(packet->tick + duration) % 65536, next_tick % 65536)); |
(packet->tick + duration) % 65536, next_tick % 65536)); |
263 |
} |
} |
264 |
|
|
265 |
rdpsnd_send_completion(((packet->tick + duration) % 65536), packet->index); |
if (snd_pcm_delay(pcm_handle, &delay_frames) < 0) |
266 |
rdpsnd_queue_next(); |
delay_frames = out->size / (samplewidth * audiochannels); |
267 |
|
if (delay_frames < 0) |
268 |
|
delay_frames = 0; |
269 |
|
|
270 |
|
delay_us = delay_frames * (1000000 / rate); |
271 |
|
|
272 |
|
rdpsnd_queue_next(delay_us); |
273 |
} |
} |
274 |
|
|
275 |
g_dsp_busy = 1; |
g_dsp_busy = 1; |
281 |
{ |
{ |
282 |
static struct audio_driver alsa_driver; |
static struct audio_driver alsa_driver; |
283 |
|
|
|
alsa_driver.wave_out_write = rdpsnd_queue_write; |
|
284 |
alsa_driver.wave_out_open = alsa_open; |
alsa_driver.wave_out_open = alsa_open; |
285 |
alsa_driver.wave_out_close = alsa_close; |
alsa_driver.wave_out_close = alsa_close; |
286 |
alsa_driver.wave_out_format_supported = alsa_format_supported; |
alsa_driver.wave_out_format_supported = alsa_format_supported; |