From c4b90c20727e7bd0c84a6f6ff2e910c4ab481527 Mon Sep 17 00:00:00 2001 From: Michael Gernoth Date: Sun, 17 Sep 2006 20:06:37 +0000 Subject: [PATCH] Recover missing 4 bytes in audio-stream thanks to a hint in an old email from Robert Sanders : I found a trick that seems to solve this. Basically, I copy the last 4 bytes of the RDPSND_WRITE command that precedes the sample data. It's not being used by anything else. I can't tell whether this is some trick to "pre-load" the sample buffer, or some error in rdesktop's interpretation of the RDP sound protocol. git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/trunk/rdesktop@1264 423420c4-83ab-492f-b58f-81f9feb106b5 --- rdpsnd.c | 6 ++++++ rdpsnd_dsp.c | 7 +++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/rdpsnd.c b/rdpsnd.c index d899043..73ecde5 100644 --- a/rdpsnd.c +++ b/rdpsnd.c @@ -194,6 +194,7 @@ rdpsnd_process(STREAM s) static uint16 tick, format; static uint8 packet_index; static BOOL awaiting_data_packet; + static unsigned char missing_bytes[4] = { 0, 0, 0, 0 }; #ifdef RDPSND_DEBUG printf("RDPSND recv:\n"); @@ -226,6 +227,9 @@ rdpsnd_process(STREAM s) current_format = format; } + /* Insert the 4 missing bytes retrieved from last RDPSND_WRITE */ + memcpy(s->data, missing_bytes, 4); + current_driver-> wave_out_write(rdpsnd_dsp_process (s, current_driver, &formats[current_format]), tick, @@ -244,6 +248,8 @@ rdpsnd_process(STREAM s) in_uint16_le(s, tick); in_uint16_le(s, format); in_uint8(s, packet_index); + /* Here are our lost bytes, but why? */ + memcpy(missing_bytes, s->end - 4, 4); awaiting_data_packet = True; break; case RDPSND_CLOSE: diff --git a/rdpsnd_dsp.c b/rdpsnd_dsp.c index e293931..88f8f4c 100644 --- a/rdpsnd_dsp.c +++ b/rdpsnd_dsp.c @@ -129,12 +129,11 @@ rdpsnd_dsp_process(STREAM s, struct audio_driver *current_driver, WAVEFORMATEX * rdpsnd_dsp_swapbytes(s->data, s->size, format); #endif - /* FIXME: where do we lose the 4 bytes referenced here? */ - out.data = xmalloc(s->size - 4); + out.data = xmalloc(s->size); - memcpy(out.data, s->data + 4, s->size - 4); + memcpy(out.data, s->data, s->size); - out.size = s->size - 4; + out.size = s->size; out.p = out.data; out.end = out.p + out.size;