/[rdesktop]/sourceforge.net/rdesktop/trunk/rdpsnd.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /sourceforge.net/rdesktop/trunk/rdpsnd.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1342 by ossman_, Wed Dec 6 13:29:42 2006 UTC revision 1343 by ossman_, Wed Dec 6 13:55:34 2006 UTC
# Line 1  Line 1 
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
5     Copyright (C) Matthew Chapman 2003     Copyright (C) Matthew Chapman 2003
6     Copyright (C) GuoJunBo guojunbo@ict.ac.cn 2003     Copyright (C) GuoJunBo guojunbo@ict.ac.cn 2003
7    
# Line 74  rdpsnd_init_packet(uint16 type, uint16 s Line 75  rdpsnd_init_packet(uint16 type, uint16 s
75  static void  static void
76  rdpsnd_send(STREAM s)  rdpsnd_send(STREAM s)
77  {  {
 #ifdef RDPSND_DEBUG  
         printf("RDPSND send:\n");  
         hexdump(s->channel_hdr + 8, s->end - s->channel_hdr - 8);  
 #endif  
   
78          channel_send(s, rdpsnd_channel);          channel_send(s, rdpsnd_channel);
79  }  }
80    
# Line 93  rdpsnd_send_completion(uint16 tick, uint Line 89  rdpsnd_send_completion(uint16 tick, uint
89          out_uint8(s, 0);          out_uint8(s, 0);
90          s_mark_end(s);          s_mark_end(s);
91          rdpsnd_send(s);          rdpsnd_send(s);
92    
93            DEBUG_SOUND(("RDPSND: -> RDPSND_COMPLETION(tick: %u, index: %u)\n",
94                         (unsigned) tick, (unsigned) packet_index));
95  }  }
96    
97  static void  static void
# Line 113  rdpsnd_process_negotiate(STREAM in) Line 112  rdpsnd_process_negotiate(STREAM in)
112          in_uint16_le(in, version);          in_uint16_le(in, version);
113          in_uint8s(in, 1);       /* padding */          in_uint8s(in, 1);       /* padding */
114    
115            DEBUG_SOUND(("RDPSND: RDPSND_NEGOTIATE(formats: %d, pad1: 0x%02x, version: %x)\n",
116                         (int) in_format_count, (unsigned) pad1, (unsigned) version));
117    
118          if (current_driver->wave_out_open())          if (current_driver->wave_out_open())
119          {          {
120                  current_driver->wave_out_close();                  current_driver->wave_out_close();
# Line 179  rdpsnd_process_negotiate(STREAM in) Line 181  rdpsnd_process_negotiate(STREAM in)
181          }          }
182    
183          s_mark_end(out);          s_mark_end(out);
184    
185            DEBUG_SOUND(("RDPSND: -> RDPSND_NEGOTIATE(formats: %d)\n", (int) format_count));
186    
187          rdpsnd_send(out);          rdpsnd_send(out);
188  }  }
189    
# Line 190  rdpsnd_process_ping(STREAM in) Line 195  rdpsnd_process_ping(STREAM in)
195    
196          in_uint16_le(in, tick);          in_uint16_le(in, tick);
197    
198            DEBUG_SOUND(("RDPSND: RDPSND_PING(tick: 0x%04x)\n", (unsigned) tick));
199    
200          out = rdpsnd_init_packet(RDPSND_PING | 0x2300, 4);          out = rdpsnd_init_packet(RDPSND_PING | 0x2300, 4);
201          out_uint16_le(out, tick);          out_uint16_le(out, tick);
202          out_uint16_le(out, 0);          out_uint16_le(out, 0);
203          s_mark_end(out);          s_mark_end(out);
204          rdpsnd_send(out);          rdpsnd_send(out);
205    
206            DEBUG_SOUND(("RDPSND: -> (tick: 0x%04x)\n", (unsigned) tick));
207  }  }
208    
209  static void  static void
# Line 204  rdpsnd_process_packet(uint8 opcode, STRE Line 213  rdpsnd_process_packet(uint8 opcode, STRE
213          static uint16 tick, format;          static uint16 tick, format;
214          static uint8 packet_index;          static uint8 packet_index;
215    
 #ifdef RDPSND_DEBUG  
         printf("RDPSND recv:\n");  
         hexdump(s->p, s->end - s->p);  
 #endif  
   
216          switch (opcode)          switch (opcode)
217          {          {
218                  case RDPSND_WRITE:                  case RDPSND_WRITE:
# Line 216  rdpsnd_process_packet(uint8 opcode, STRE Line 220  rdpsnd_process_packet(uint8 opcode, STRE
220                          in_uint16_le(s, format);                          in_uint16_le(s, format);
221                          in_uint8(s, packet_index);                          in_uint8(s, packet_index);
222                          in_uint8s(s, 3);                          in_uint8s(s, 3);
223                            DEBUG_SOUND(("RDPSND: RDPSND_WRITE(tick: %u, format: %u, index: %u, data: %u bytes)\n", (unsigned) tick, (unsigned) format, (unsigned) packet_index, (unsigned) s->size - 8));
224    
225                          if (format >= MAX_FORMATS)                          if (format >= MAX_FORMATS)
226                          {                          {
# Line 247  rdpsnd_process_packet(uint8 opcode, STRE Line 252  rdpsnd_process_packet(uint8 opcode, STRE
252                          return;                          return;
253                          break;                          break;
254                  case RDPSND_CLOSE:                  case RDPSND_CLOSE:
255                            DEBUG_SOUND(("RDPSND: RDPSND_CLOSE()\n"));
256                          current_driver->wave_out_close();                          current_driver->wave_out_close();
257                          device_open = False;                          device_open = False;
258                          break;                          break;
# Line 259  rdpsnd_process_packet(uint8 opcode, STRE Line 265  rdpsnd_process_packet(uint8 opcode, STRE
265                  case RDPSND_SET_VOLUME:                  case RDPSND_SET_VOLUME:
266                          in_uint16_le(s, vol_left);                          in_uint16_le(s, vol_left);
267                          in_uint16_le(s, vol_right);                          in_uint16_le(s, vol_right);
268                            DEBUG_SOUND(("RDPSND: RDPSND_VOLUME(left: 0x%04x (%u %%), right: 0x%04x (%u %%))\n", (unsigned) vol_left, (unsigned) vol_left / 655, (unsigned) vol_right, (unsigned) vol_right / 655));
269                          if (device_open)                          if (device_open)
270                                  current_driver->wave_out_volume(vol_left, vol_right);                                  current_driver->wave_out_volume(vol_left, vol_right);
271                          break;                          break;
# Line 287  rdpsnd_process(STREAM s) Line 294  rdpsnd_process(STREAM s)
294                          in_uint8s(s, 1);        /* Padding */                          in_uint8s(s, 1);        /* Padding */
295                          in_uint16_le(s, len);                          in_uint16_le(s, len);
296    
297                            DEBUG_SOUND(("RDPSND: == Opcode %x Length: %d ==\n",
298                                         (int) packet_opcode, (int) len));
299    
300                          packet.p = packet.data;                          packet.p = packet.data;
301                          packet.end = packet.data + len;                          packet.end = packet.data + len;
302                          packet.size = len;                          packet.size = len;
# Line 302  rdpsnd_process(STREAM s) Line 312  rdpsnd_process(STREAM s)
312                                          len = MIN(len, 12 - (packet.p - packet.data));                                          len = MIN(len, 12 - (packet.p - packet.data));
313                                  else if ((packet.p - packet.data) == 12)                                  else if ((packet.p - packet.data) == 12)
314                                  {                                  {
315                                            DEBUG_SOUND(("RDPSND: Eating 4 bytes of %d bytes...\n",
316                                                         len));
317                                          in_uint8s(s, 4);                                          in_uint8s(s, 4);
318                                          len -= 4;                                          len -= 4;
319                                  }                                  }

Legend:
Removed from v.1342  
changed lines
  Added in v.1343

  ViewVC Help
Powered by ViewVC 1.1.26