30 |
#define RDPSND_SET_VOLUME 3 |
#define RDPSND_SET_VOLUME 3 |
31 |
#define RDPSND_UNKNOWN4 4 |
#define RDPSND_UNKNOWN4 4 |
32 |
#define RDPSND_COMPLETION 5 |
#define RDPSND_COMPLETION 5 |
33 |
#define RDPSND_SERVERTICK 6 |
#define RDPSND_PING 6 |
34 |
#define RDPSND_NEGOTIATE 7 |
#define RDPSND_NEGOTIATE 7 |
35 |
|
|
36 |
#define MAX_FORMATS 10 |
#define MAX_FORMATS 10 |
95 |
static void |
static void |
96 |
rdpsnd_process_negotiate(STREAM in) |
rdpsnd_process_negotiate(STREAM in) |
97 |
{ |
{ |
98 |
unsigned int in_format_count, i; |
uint16 in_format_count, i; |
99 |
|
uint8 pad; |
100 |
|
uint16 version; |
101 |
WAVEFORMATEX *format; |
WAVEFORMATEX *format; |
102 |
STREAM out; |
STREAM out; |
103 |
BOOL device_available = False; |
BOOL device_available = False; |
104 |
int readcnt; |
int readcnt; |
105 |
int discardcnt; |
int discardcnt; |
106 |
|
|
107 |
in_uint8s(in, 14); /* flags, volume, pitch, UDP port */ |
in_uint8s(in, 14); /* initial bytes not valid from server */ |
108 |
in_uint16_le(in, in_format_count); |
in_uint16_le(in, in_format_count); |
109 |
in_uint8s(in, 4); /* pad, status, pad */ |
in_uint8(in, pad); |
110 |
|
in_uint16_le(in, version); |
111 |
|
in_uint8s(in, 1); /* padding */ |
112 |
|
|
113 |
if (current_driver->wave_out_open()) |
if (current_driver->wave_out_open()) |
114 |
{ |
{ |
159 |
out_uint16(out, 0); /* UDP port */ |
out_uint16(out, 0); /* UDP port */ |
160 |
|
|
161 |
out_uint16_le(out, format_count); |
out_uint16_le(out, format_count); |
162 |
out_uint8(out, 0x95); /* pad? */ |
out_uint8(out, 0); /* padding */ |
163 |
out_uint16_le(out, 2); /* status */ |
out_uint16_le(out, 2); /* version */ |
164 |
out_uint8(out, 0x77); /* pad? */ |
out_uint8(out, 0); /* padding */ |
165 |
|
|
166 |
for (i = 0; i < format_count; i++) |
for (i = 0; i < format_count; i++) |
167 |
{ |
{ |
180 |
} |
} |
181 |
|
|
182 |
static void |
static void |
183 |
rdpsnd_process_servertick(STREAM in) |
rdpsnd_process_ping(STREAM in) |
184 |
{ |
{ |
185 |
uint16 tick1, tick2; |
uint16 tick; |
186 |
STREAM out; |
STREAM out; |
187 |
|
|
188 |
/* in_uint8s(in, 4); unknown */ |
in_uint16_le(in, tick); |
189 |
in_uint16_le(in, tick1); |
|
190 |
in_uint16_le(in, tick2); |
out = rdpsnd_init_packet(RDPSND_PING | 0x2300, 4); |
191 |
|
out_uint16_le(out, tick); |
192 |
out = rdpsnd_init_packet(RDPSND_SERVERTICK | 0x2300, 4); |
out_uint16_le(out, 0); |
|
out_uint16_le(out, tick1); |
|
|
out_uint16_le(out, tick2); |
|
193 |
s_mark_end(out); |
s_mark_end(out); |
194 |
rdpsnd_send(out); |
rdpsnd_send(out); |
195 |
} |
} |
199 |
{ |
{ |
200 |
uint8 type; |
uint8 type; |
201 |
uint16 datalen; |
uint16 datalen; |
202 |
uint32 volume; |
uint16 vol_left, vol_right; |
203 |
static uint16 tick, format; |
static uint16 tick, format; |
204 |
static uint8 packet_index; |
static uint8 packet_index; |
205 |
static BOOL awaiting_data_packet; |
static BOOL awaiting_data_packet; |
267 |
case RDPSND_NEGOTIATE: |
case RDPSND_NEGOTIATE: |
268 |
rdpsnd_process_negotiate(s); |
rdpsnd_process_negotiate(s); |
269 |
break; |
break; |
270 |
case RDPSND_SERVERTICK: |
case RDPSND_PING: |
271 |
rdpsnd_process_servertick(s); |
rdpsnd_process_ping(s); |
272 |
break; |
break; |
273 |
case RDPSND_SET_VOLUME: |
case RDPSND_SET_VOLUME: |
274 |
in_uint32(s, volume); |
in_uint16_le(s, vol_left); |
275 |
|
in_uint16_le(s, vol_right); |
276 |
if (device_open) |
if (device_open) |
277 |
{ |
current_driver->wave_out_volume(vol_left, vol_right); |
|
current_driver->wave_out_volume((volume & 0xffff), |
|
|
(volume & 0xffff0000) >> 16); |
|
|
} |
|
278 |
break; |
break; |
279 |
default: |
default: |
280 |
unimpl("RDPSND packet type %d\n", type); |
unimpl("RDPSND packet type %d\n", type); |
561 |
|
|
562 |
elapsed = (packet->completion_tv.tv_sec - packet->arrive_tv.tv_sec) * 1000000 + |
elapsed = (packet->completion_tv.tv_sec - packet->arrive_tv.tv_sec) * 1000000 + |
563 |
(packet->completion_tv.tv_usec - packet->arrive_tv.tv_usec); |
(packet->completion_tv.tv_usec - packet->arrive_tv.tv_usec); |
564 |
|
elapsed /= 1000; |
565 |
|
|
566 |
xfree(packet->s.data); |
xfree(packet->s.data); |
567 |
rdpsnd_send_completion((packet->tick + elapsed) % 65536, packet->index); |
rdpsnd_send_completion((packet->tick + elapsed) % 65536, packet->index); |