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 |
Sound Channel Process Functions |
4 |
Copyright 2006 Pierre Ossman <ossman@cendio.se> for Cendio AB |
Copyright 2006-2007 Pierre Ossman <ossman@cendio.se> for Cendio AB |
5 |
Copyright (C) Matthew Chapman 2003 |
Copyright (C) Matthew Chapman 2003-2007 |
6 |
Copyright (C) GuoJunBo guojunbo@ict.ac.cn 2003 |
Copyright (C) GuoJunBo guojunbo@ict.ac.cn 2003 |
7 |
|
|
8 |
This program is free software; you can redistribute it and/or modify |
This program is free software; you can redistribute it and/or modify |
50 |
static struct audio_driver *drivers = NULL; |
static struct audio_driver *drivers = NULL; |
51 |
struct audio_driver *current_driver = NULL; |
struct audio_driver *current_driver = NULL; |
52 |
|
|
53 |
static BOOL device_open; |
static RD_BOOL device_open; |
54 |
static BOOL rec_device_open; |
static RD_BOOL rec_device_open; |
55 |
|
|
56 |
static WAVEFORMATEX formats[MAX_FORMATS]; |
static RD_WAVEFORMATEX formats[MAX_FORMATS]; |
57 |
static unsigned int format_count; |
static unsigned int format_count; |
58 |
static unsigned int current_format; |
static unsigned int current_format; |
59 |
|
|
60 |
static WAVEFORMATEX rec_formats[MAX_FORMATS]; |
static RD_WAVEFORMATEX rec_formats[MAX_FORMATS]; |
61 |
static unsigned int rec_format_count; |
static unsigned int rec_format_count; |
62 |
|
|
63 |
unsigned int queue_hi, queue_lo, queue_pending; |
unsigned int queue_hi, queue_lo, queue_pending; |
64 |
struct audio_packet packet_queue[MAX_QUEUE]; |
struct audio_packet packet_queue[MAX_QUEUE]; |
65 |
|
|
66 |
static char record_buffer[8192]; |
static char record_buffer[8192]; |
67 |
static int record_buffer_size; |
static uint32 record_buffer_size; |
68 |
|
|
69 |
static uint8 packet_opcode; |
static uint8 packet_opcode; |
70 |
static struct stream packet; |
static struct stream packet; |
153 |
void |
void |
154 |
rdpsnd_record(const void *data, unsigned int size) |
rdpsnd_record(const void *data, unsigned int size) |
155 |
{ |
{ |
156 |
int remain; |
uint32 remain; |
157 |
|
|
158 |
assert(rec_device_open); |
assert(rec_device_open); |
159 |
|
|
178 |
} |
} |
179 |
} |
} |
180 |
|
|
181 |
static BOOL |
static RD_BOOL |
182 |
rdpsnd_auto_select(void) |
rdpsnd_auto_select(void) |
183 |
{ |
{ |
184 |
static BOOL failed = False; |
static RD_BOOL failed = False; |
185 |
|
|
186 |
if (!failed) |
if (!failed) |
187 |
{ |
{ |
212 |
uint16 in_format_count, i; |
uint16 in_format_count, i; |
213 |
uint8 pad; |
uint8 pad; |
214 |
uint16 version; |
uint16 version; |
215 |
WAVEFORMATEX *format; |
RD_WAVEFORMATEX *format; |
216 |
STREAM out; |
STREAM out; |
217 |
BOOL device_available = False; |
RD_BOOL device_available = False; |
218 |
int readcnt; |
int readcnt; |
219 |
int discardcnt; |
int discardcnt; |
220 |
|
|
263 |
in_uint8a(in, format->cb, readcnt); |
in_uint8a(in, format->cb, readcnt); |
264 |
in_uint8s(in, discardcnt); |
in_uint8s(in, discardcnt); |
265 |
|
|
266 |
if (device_available && current_driver->wave_out_format_supported(format)) |
if (current_driver && current_driver->wave_out_format_supported(format)) |
267 |
{ |
{ |
268 |
format_count++; |
format_count++; |
269 |
if (format_count == MAX_FORMATS) |
if (format_count == MAX_FORMATS) |
326 |
{ |
{ |
327 |
uint16 in_format_count, i; |
uint16 in_format_count, i; |
328 |
uint16 version; |
uint16 version; |
329 |
WAVEFORMATEX *format; |
RD_WAVEFORMATEX *format; |
330 |
STREAM out; |
STREAM out; |
331 |
BOOL device_available = False; |
RD_BOOL device_available = False; |
332 |
int readcnt; |
int readcnt; |
333 |
int discardcnt; |
int discardcnt; |
334 |
|
|
376 |
in_uint8a(in, format->cb, readcnt); |
in_uint8a(in, format->cb, readcnt); |
377 |
in_uint8s(in, discardcnt); |
in_uint8s(in, discardcnt); |
378 |
|
|
379 |
if (device_available && current_driver->wave_in_format_supported(format)) |
if (current_driver && current_driver->wave_in_format_supported(format)) |
380 |
{ |
{ |
381 |
rec_format_count++; |
rec_format_count++; |
382 |
if (rec_format_count == MAX_FORMATS) |
if (rec_format_count == MAX_FORMATS) |
592 |
} |
} |
593 |
} |
} |
594 |
|
|
595 |
static BOOL |
static RD_BOOL |
596 |
rdpsnddbg_line_handler(const char *line, void *data) |
rdpsnddbg_line_handler(const char *line, void *data) |
597 |
{ |
{ |
598 |
#ifdef WITH_DEBUG_SOUND |
#ifdef WITH_DEBUG_SOUND |
610 |
|
|
611 |
pkglen = s->end - s->p; |
pkglen = s->end - s->p; |
612 |
/* str_handle_lines requires null terminated strings */ |
/* str_handle_lines requires null terminated strings */ |
613 |
buf = xmalloc(pkglen + 1); |
buf = (char *) xmalloc(pkglen + 1); |
614 |
STRNCPY(buf, (char *) s->p, pkglen + 1); |
STRNCPY(buf, (char *) s->p, pkglen + 1); |
615 |
|
|
616 |
str_handle_lines(buf, &rest, rdpsnddbg_line_handler, NULL); |
str_handle_lines(buf, &rest, rdpsnddbg_line_handler, NULL); |
654 |
*reg = NULL; |
*reg = NULL; |
655 |
} |
} |
656 |
|
|
657 |
BOOL |
RD_BOOL |
658 |
rdpsnd_init(char *optarg) |
rdpsnd_init(char *optarg) |
659 |
{ |
{ |
660 |
struct audio_driver *pos; |
struct audio_driver *pos; |
662 |
|
|
663 |
drivers = NULL; |
drivers = NULL; |
664 |
|
|
665 |
packet.data = xmalloc(65536); |
packet.data = (uint8 *) xmalloc(65536); |
666 |
packet.p = packet.end = packet.data; |
packet.p = packet.end = packet.data; |
667 |
packet.size = 0; |
packet.size = 0; |
668 |
|
|
791 |
return &packet_queue[queue_lo]; |
return &packet_queue[queue_lo]; |
792 |
} |
} |
793 |
|
|
794 |
BOOL |
RD_BOOL |
795 |
rdpsnd_queue_empty(void) |
rdpsnd_queue_empty(void) |
796 |
{ |
{ |
797 |
return (queue_lo == queue_hi); |
return (queue_lo == queue_hi); |