/[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 1372 by jsorg71, Mon Jan 8 04:47:06 2007 UTC revision 1475 by jsorg71, Fri Jul 11 03:51:23 2008 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-2007 Pierre Ossman <ossman@cendio.se> for Cendio AB     Copyright 2006-2008 Pierre Ossman <ossman@cendio.se> for Cendio AB
5     Copyright (C) Matthew Chapman 2003-2007     Copyright (C) Matthew Chapman 2003-2008
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
# Line 59  static unsigned int current_format; Line 59  static unsigned int current_format;
59    
60  static RD_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    static unsigned int rec_current_format;
63    
64  unsigned int queue_hi, queue_lo, queue_pending;  unsigned int queue_hi, queue_lo, queue_pending;
65  struct audio_packet packet_queue[MAX_QUEUE];  struct audio_packet packet_queue[MAX_QUEUE];
66    
67  static char record_buffer[8192];  static char record_buffer[8192];
68  static int record_buffer_size;  static uint32 record_buffer_size;
69    
70  static uint8 packet_opcode;  static uint8 packet_opcode;
71  static struct stream packet;  static struct stream packet;
# Line 153  rdpsnd_flush_record(void) Line 154  rdpsnd_flush_record(void)
154  void  void
155  rdpsnd_record(const void *data, unsigned int size)  rdpsnd_record(const void *data, unsigned int size)
156  {  {
157          int remain;          uint32 remain, chunk;
158    
159          assert(rec_device_open);          assert(rec_device_open);
160    
# Line 162  rdpsnd_record(const void *data, unsigned Line 163  rdpsnd_record(const void *data, unsigned
163                  remain = sizeof(record_buffer) - record_buffer_size;                  remain = sizeof(record_buffer) - record_buffer_size;
164    
165                  if (size >= remain)                  if (size >= remain)
166                  {                          chunk = remain;
                         memcpy(record_buffer + record_buffer_size, data, remain);  
                         record_buffer_size += remain;  
                         rdpsnd_flush_record();  
                         data = (const char *) data + remain;  
                         size -= remain;  
                 }  
167                  else                  else
168                  {                          chunk = size;
169                          memcpy(record_buffer + record_buffer_size, data, size);  
170                          record_buffer_size += size;                  memcpy(record_buffer + record_buffer_size, data, chunk);
171                          size = 0;  
172                  }  #ifdef B_ENDIAN
173                    if (current_driver->need_byteswap_on_be)
174                            rdpsnd_dsp_swapbytes(record_buffer + record_buffer_size,
175                                                 chunk, &rec_formats[rec_current_format]);
176    #endif
177    
178                    record_buffer_size += chunk;
179    
180                    data = (const char *) data + chunk;
181                    size -= chunk;
182    
183                    if (record_buffer_size == sizeof(record_buffer))
184                            rdpsnd_flush_record();
185          }          }
186  }  }
187    
# Line 263  rdpsnd_process_negotiate(STREAM in) Line 270  rdpsnd_process_negotiate(STREAM in)
270                          in_uint8a(in, format->cb, readcnt);                          in_uint8a(in, format->cb, readcnt);
271                          in_uint8s(in, discardcnt);                          in_uint8s(in, discardcnt);
272    
273                          if (device_available && current_driver->wave_out_format_supported(format))                          if (current_driver && current_driver->wave_out_format_supported(format))
274                          {                          {
275                                  format_count++;                                  format_count++;
276                                  if (format_count == MAX_FORMATS)                                  if (format_count == MAX_FORMATS)
# Line 376  rdpsnd_process_rec_negotiate(STREAM in) Line 383  rdpsnd_process_rec_negotiate(STREAM in)
383                          in_uint8a(in, format->cb, readcnt);                          in_uint8a(in, format->cb, readcnt);
384                          in_uint8s(in, discardcnt);                          in_uint8s(in, discardcnt);
385    
386                          if (device_available && current_driver->wave_in_format_supported(format))                          if (current_driver && current_driver->wave_in_format_supported
387                                && current_driver->wave_in_format_supported(format))
388                          {                          {
389                                  rec_format_count++;                                  rec_format_count++;
390                                  if (rec_format_count == MAX_FORMATS)                                  if (rec_format_count == MAX_FORMATS)
# Line 512  rdpsnd_process_packet(uint8 opcode, STRE Line 520  rdpsnd_process_packet(uint8 opcode, STRE
520                                  current_driver->wave_in_close();                                  current_driver->wave_in_close();
521                                  break;                                  break;
522                          }                          }
523                            rec_current_format = format;
524                          rec_device_open = True;                          rec_device_open = True;
525                          break;                          break;
526                  case RDPSND_REC_STOP:                  case RDPSND_REC_STOP:
# Line 610  rdpsnddbg_process(STREAM s) Line 619  rdpsnddbg_process(STREAM s)
619    
620          pkglen = s->end - s->p;          pkglen = s->end - s->p;
621          /* str_handle_lines requires null terminated strings */          /* str_handle_lines requires null terminated strings */
622          buf = xmalloc(pkglen + 1);          buf = (char *) xmalloc(pkglen + 1);
623          STRNCPY(buf, (char *) s->p, pkglen + 1);          STRNCPY(buf, (char *) s->p, pkglen + 1);
624    
625          str_handle_lines(buf, &rest, rdpsnddbg_line_handler, NULL);          str_handle_lines(buf, &rest, rdpsnddbg_line_handler, NULL);
# Line 662  rdpsnd_init(char *optarg) Line 671  rdpsnd_init(char *optarg)
671    
672          drivers = NULL;          drivers = NULL;
673    
674          packet.data = xmalloc(65536);          packet.data = (uint8 *) xmalloc(65536);
675          packet.p = packet.end = packet.data;          packet.p = packet.end = packet.data;
676          packet.size = 0;          packet.size = 0;
677    

Legend:
Removed from v.1372  
changed lines
  Added in v.1475

  ViewVC Help
Powered by ViewVC 1.1.26