/[rdesktop]/jpeg/rdesktop/trunk/rdpsnd_sun.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 /jpeg/rdesktop/trunk/rdpsnd_sun.c

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

sourceforge.net/trunk/rdesktop/rdpsnd_sun.c revision 1433 by ossman_, Fri Feb 8 10:40:56 2008 UTC jpeg/rdesktop/trunk/rdpsnd_sun.c revision 1507 by dpavlin, Mon Jul 20 16:45:11 2009 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 - Sun     Sound Channel Process Functions - Sun
4     Copyright (C) Matthew Chapman 2003-2007     Copyright (C) Matthew Chapman 2003-2008
5     Copyright (C) GuoJunBo guojunbo@ict.ac.cn 2003     Copyright (C) GuoJunBo guojunbo@ict.ac.cn 2003
6     Copyright (C) Michael Gernoth mike@zerfleddert.de 2003-2007     Copyright (C) Michael Gernoth mike@zerfleddert.de 2003-2008
7     Copyright 2007 Pierre Ossman <ossman@cendio.se> for Cendio AB     Copyright 2007-2008 Pierre Ossman <ossman@cendio.se> for Cendio AB
8    
9     This program is free software; you can redistribute it and/or modify     This program is free software; you can redistribute it and/or modify
10     it under the terms of the GNU General Public License as published by     it under the terms of the GNU General Public License as published by
# Line 28  Line 28 
28  #include <errno.h>  #include <errno.h>
29  #include <sys/ioctl.h>  #include <sys/ioctl.h>
30  #include <sys/audioio.h>  #include <sys/audioio.h>
31    #include <string.h>
32    
33  #if (defined(sun) && (defined(__svr4__) || defined(__SVR4)))  #if (defined(sun) && (defined(__svr4__) || defined(__SVR4)))
34  #include <stropts.h>  #include <stropts.h>
# Line 42  static int dsp_refs; Line 43  static int dsp_refs;
43    
44  static RD_BOOL dsp_configured;  static RD_BOOL dsp_configured;
45  static RD_BOOL dsp_broken;  static RD_BOOL dsp_broken;
46    static RD_BOOL broken_2_channel_record = False;
47    
48  static RD_BOOL dsp_out;  static RD_BOOL dsp_out;
49  static RD_BOOL dsp_in;  static RD_BOOL dsp_in;
# Line 240  sun_open_in(void) Line 242  sun_open_in(void)
242          if (!sun_open(O_RDONLY))          if (!sun_open(O_RDONLY))
243                  return False;                  return False;
244    
245            /* 2 channel recording is known to be broken on Solaris x86
246               Sun Ray systems */
247    #ifdef L_ENDIAN
248            if (strstr(dsp_dev, "/utaudio/"))
249                    broken_2_channel_record = True;
250    #endif
251    
252          /*          /*
253           * Unpause the stream now that we have someone using it.           * Unpause the stream now that we have someone using it.
254           */           */
# Line 313  sun_set_format(RD_WAVEFORMATEX * pwfx) Line 322  sun_set_format(RD_WAVEFORMATEX * pwfx)
322    
323          samplewidth = pwfx->wBitsPerSample / 8;          samplewidth = pwfx->wBitsPerSample / 8;
324    
325            info.play.channels = pwfx->nChannels;
326            info.record.channels = info.play.channels;
327    
328          if (pwfx->nChannels == 1)          if (pwfx->nChannels == 1)
329          {          {
                 info.play.channels = 1;  
330                  stereo = 0;                  stereo = 0;
331          }          }
332          else if (pwfx->nChannels == 2)          else if (pwfx->nChannels == 2)
333          {          {
                 info.play.channels = 2;  
334                  stereo = 1;                  stereo = 1;
335                  samplewidth *= 2;                  samplewidth *= 2;
336    
337                    if (broken_2_channel_record)
338                    {
339                            info.record.channels = 1;
340                    }
341          }          }
342    
343          snd_rate = pwfx->nSamplesPerSec;          snd_rate = pwfx->nSamplesPerSec;
# Line 335  sun_set_format(RD_WAVEFORMATEX * pwfx) Line 350  sun_set_format(RD_WAVEFORMATEX * pwfx)
350          info.play.error = 0;          info.play.error = 0;
351    
352          info.record.sample_rate = info.play.sample_rate;          info.record.sample_rate = info.play.sample_rate;
         info.record.channels = info.play.channels;  
353          info.record.precision = info.play.precision;          info.record.precision = info.play.precision;
354          info.record.encoding = info.play.encoding;          info.record.encoding = info.play.encoding;
355          info.record.samples = 0;          info.record.samples = 0;
# Line 445  sun_record(void) Line 459  sun_record(void)
459          char buffer[32768];          char buffer[32768];
460          int len;          int len;
461    
462          len = read(dsp_fd, buffer, sizeof(buffer));          len = read(dsp_fd, buffer, sizeof(buffer) / 2);
463          if (len == -1)          if (len == -1)
464          {          {
465                  if (errno != EWOULDBLOCK)                  if (errno != EWOULDBLOCK)
# Line 453  sun_record(void) Line 467  sun_record(void)
467                  return;                  return;
468          }          }
469    
470            if (broken_2_channel_record)
471            {
472                    unsigned int i;
473                    int rec_samplewidth = samplewidth / 2;
474                    /* Loop over each byte read backwards and put in place */
475                    i = len - 1;
476                    do
477                    {
478                            int samples_before = i / rec_samplewidth * 2;
479                            int sample_byte = i % rec_samplewidth;
480                            int ch1_offset = samples_before * rec_samplewidth + sample_byte;
481                            // Channel 1
482                            buffer[ch1_offset] = buffer[i];
483                            // Channel 2
484                            buffer[ch1_offset + rec_samplewidth] = buffer[i];
485    
486                            i--;
487                    }
488                    while (i);
489                    len *= 2;
490            }
491    
492          rdpsnd_record(buffer, len);          rdpsnd_record(buffer, len);
493  }  }
494    

Legend:
Removed from v.1433  
changed lines
  Added in v.1507

  ViewVC Help
Powered by ViewVC 1.1.26