1 |
/* -*- c-basic-offset: 8 -*- |
/* -*- c-basic-offset: 8 -*- |
2 |
rdesktop: A Remote Desktop Protocol client. |
rdesktop: A Remote Desktop Protocol client. |
3 |
Sound Channel Process Functions - SGI/IRIX |
Sound Channel Process Functions - SGI/IRIX |
4 |
Copyright (C) Matthew Chapman 2003 |
Copyright (C) Matthew Chapman 2003-2008 |
5 |
Copyright (C) GuoJunBo guojunbo@ict.ac.cn 2003 |
Copyright (C) GuoJunBo guojunbo@ict.ac.cn 2003 |
6 |
Copyright (C) Jeremy Meng void.foo@gmail.com 2004, 2005 |
Copyright (C) Jeremy Meng void.foo@gmail.com 2004, 2005 |
7 |
|
|
39 |
int resource, maxFillable; |
int resource, maxFillable; |
40 |
int combinedFrameSize; |
int combinedFrameSize; |
41 |
|
|
42 |
BOOL |
void sgi_play(void); |
43 |
|
|
44 |
|
void |
45 |
|
sgi_add_fds(int *n, fd_set * rfds, fd_set * wfds, struct timeval *tv) |
46 |
|
{ |
47 |
|
/* We need to be called rather often... */ |
48 |
|
if (output_port != (ALport) 0 && !rdpsnd_queue_empty()) |
49 |
|
FD_SET(0, wfds); |
50 |
|
} |
51 |
|
|
52 |
|
void |
53 |
|
sgi_check_fds(fd_set * rfds, fd_set * wfds) |
54 |
|
{ |
55 |
|
if (output_port == (ALport) 0) |
56 |
|
return; |
57 |
|
|
58 |
|
if (!rdpsnd_queue_empty()) |
59 |
|
sgi_play(); |
60 |
|
} |
61 |
|
|
62 |
|
RD_BOOL |
63 |
sgi_open(void) |
sgi_open(void) |
64 |
{ |
{ |
65 |
ALparamInfo pinfo; |
ALparamInfo pinfo; |
88 |
min_volume, max_volume, volume_range); |
min_volume, max_volume, volume_range); |
89 |
#endif |
#endif |
90 |
|
|
|
rdpsnd_queue_init(); |
|
|
|
|
91 |
audioconfig = alNewConfig(); |
audioconfig = alNewConfig(); |
92 |
if (audioconfig == (ALconfig) 0) |
if (audioconfig == (ALconfig) 0) |
93 |
{ |
{ |
117 |
#endif |
#endif |
118 |
|
|
119 |
while (!rdpsnd_queue_empty()) |
while (!rdpsnd_queue_empty()) |
120 |
{ |
rdpsnd_queue_next(0); |
|
/* We need to add 50 to tell windows that time has passed while |
|
|
* playing this packet */ |
|
|
rdpsnd_send_completion(rdpsnd_queue_current_packet()->tick + 50, |
|
|
rdpsnd_queue_current_packet()->index); |
|
|
rdpsnd_queue_next(); |
|
|
} |
|
121 |
alDiscardFrames(output_port, 0); |
alDiscardFrames(output_port, 0); |
122 |
|
|
123 |
alClosePort(output_port); |
alClosePort(output_port); |
124 |
|
output_port = (ALport) 0; |
125 |
alFreeConfig(audioconfig); |
alFreeConfig(audioconfig); |
126 |
#if (defined(IRIX_DEBUG)) |
#if (defined(IRIX_DEBUG)) |
127 |
fprintf(stderr, "sgi_close: returning\n"); |
fprintf(stderr, "sgi_close: returning\n"); |
128 |
#endif |
#endif |
129 |
} |
} |
130 |
|
|
131 |
BOOL |
RD_BOOL |
132 |
sgi_format_supported(WAVEFORMATEX * pwfx) |
sgi_format_supported(RD_WAVEFORMATEX * pwfx) |
133 |
{ |
{ |
134 |
if (pwfx->wFormatTag != WAVE_FORMAT_PCM) |
if (pwfx->wFormatTag != WAVE_FORMAT_PCM) |
135 |
return False; |
return False; |
141 |
return True; |
return True; |
142 |
} |
} |
143 |
|
|
144 |
BOOL |
RD_BOOL |
145 |
sgi_set_format(WAVEFORMATEX * pwfx) |
sgi_set_format(RD_WAVEFORMATEX * pwfx) |
146 |
{ |
{ |
147 |
int channels; |
int channels; |
148 |
int frameSize, channelCount; |
int frameSize, channelCount; |
261 |
while (1) |
while (1) |
262 |
{ |
{ |
263 |
if (rdpsnd_queue_empty()) |
if (rdpsnd_queue_empty()) |
|
{ |
|
|
g_dsp_busy = False; |
|
264 |
return; |
return; |
|
} |
|
265 |
|
|
266 |
packet = rdpsnd_queue_current_packet(); |
packet = rdpsnd_queue_current_packet(); |
267 |
out = &packet->s; |
out = &packet->s; |
276 |
gf = alGetFilled(output_port); |
gf = alGetFilled(output_port); |
277 |
if (gf < (4 * maxFillable / 10)) |
if (gf < (4 * maxFillable / 10)) |
278 |
{ |
{ |
279 |
rdpsnd_send_completion(packet->tick, packet->index); |
rdpsnd_queue_next(0); |
|
rdpsnd_queue_next(); |
|
280 |
} |
} |
281 |
else |
else |
282 |
{ |
{ |
283 |
#if (defined(IRIX_DEBUG)) |
#if (defined(IRIX_DEBUG)) |
284 |
/* fprintf(stderr,"Busy playing...\n"); */ |
/* fprintf(stderr,"Busy playing...\n"); */ |
285 |
#endif |
#endif |
|
g_dsp_busy = True; |
|
286 |
usleep(10); |
usleep(10); |
287 |
return; |
return; |
288 |
} |
} |
295 |
{ |
{ |
296 |
static struct audio_driver sgi_driver; |
static struct audio_driver sgi_driver; |
297 |
|
|
298 |
sgi_driver.wave_out_write = rdpsnd_queue_write; |
memset(&sgi_driver, 0, sizeof(sgi_driver)); |
299 |
|
|
300 |
|
sgi_driver.name = "sgi"; |
301 |
|
sgi_driver.description = "SGI output driver"; |
302 |
|
|
303 |
|
sgi_driver.add_fds = sgi_add_fds; |
304 |
|
sgi_driver.check_fds = sgi_check_fds; |
305 |
|
|
306 |
sgi_driver.wave_out_open = sgi_open; |
sgi_driver.wave_out_open = sgi_open; |
307 |
sgi_driver.wave_out_close = sgi_close; |
sgi_driver.wave_out_close = sgi_close; |
308 |
sgi_driver.wave_out_format_supported = sgi_format_supported; |
sgi_driver.wave_out_format_supported = sgi_format_supported; |
309 |
sgi_driver.wave_out_set_format = sgi_set_format; |
sgi_driver.wave_out_set_format = sgi_set_format; |
310 |
sgi_driver.wave_out_volume = sgi_volume; |
sgi_driver.wave_out_volume = sgi_volume; |
311 |
sgi_driver.wave_out_play = sgi_play; |
|
|
sgi_driver.name = xstrdup("sgi"); |
|
|
sgi_driver.description = xstrdup("SGI output driver"); |
|
312 |
sgi_driver.need_byteswap_on_be = 1; |
sgi_driver.need_byteswap_on_be = 1; |
313 |
sgi_driver.need_resampling = 0; |
sgi_driver.need_resampling = 0; |
|
sgi_driver.next = NULL; |
|
314 |
|
|
315 |
if (options) |
if (options) |
316 |
{ |
{ |