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

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

revision 499 by astrand, Wed Oct 15 14:01:32 2003 UTC revision 559 by stargo, Thu Dec 11 12:25:38 2003 UTC
# Line 26  Line 26 
26  #include <errno.h>  #include <errno.h>
27  #include <sys/ioctl.h>  #include <sys/ioctl.h>
28  #include <sys/audioio.h>  #include <sys/audioio.h>
 #include <stropts.h>  
29    
30  #define MAX_QUEUE       10  #define MAX_QUEUE       10
31    
32  int g_dsp_fd;  int g_dsp_fd;
33  BOOL g_dsp_busy;  BOOL g_dsp_busy = False;
34  static BOOL reopened;  static BOOL g_reopened;
35  static BOOL swapaudio;  static BOOL g_swapaudio;
36  static short samplewidth;  static short g_samplewidth;
37    
38  static struct audio_packet  static struct audio_packet
39  {  {
# Line 64  wave_out_open(void) Line 63  wave_out_open(void)
63          fcntl(g_dsp_fd, F_SETFL, fcntl(g_dsp_fd, F_GETFL) | O_NONBLOCK);          fcntl(g_dsp_fd, F_SETFL, fcntl(g_dsp_fd, F_GETFL) | O_NONBLOCK);
64    
65          queue_lo = queue_hi = 0;          queue_lo = queue_hi = 0;
66          reopened = True;          g_reopened = True;
67    
68          return True;          return True;
69  }  }
# Line 80  wave_out_close(void) Line 79  wave_out_close(void)
79                  queue_lo = (queue_lo + 1) % MAX_QUEUE;                  queue_lo = (queue_lo + 1) % MAX_QUEUE;
80          }          }
81    
82    #if defined I_FLUSH && defined FLUSHW
83          /* Flush the audiobuffer */          /* Flush the audiobuffer */
84          ioctl(g_dsp_fd, I_FLUSH, FLUSHW);          ioctl(g_dsp_fd, I_FLUSH, FLUSHW);
85    #endif
86          close(g_dsp_fd);          close(g_dsp_fd);
87  }  }
88    
# Line 105  wave_out_set_format(WAVEFORMATEX * pwfx) Line 106  wave_out_set_format(WAVEFORMATEX * pwfx)
106          int test = 1;          int test = 1;
107    
108          ioctl(g_dsp_fd, AUDIO_DRAIN, 0);          ioctl(g_dsp_fd, AUDIO_DRAIN, 0);
109          swapaudio = False;          g_swapaudio = False;
110          AUDIO_INITINFO(&info);          AUDIO_INITINFO(&info);
111    
112    
# Line 117  wave_out_set_format(WAVEFORMATEX * pwfx) Line 118  wave_out_set_format(WAVEFORMATEX * pwfx)
118          {          {
119                  info.play.encoding = AUDIO_ENCODING_LINEAR;                  info.play.encoding = AUDIO_ENCODING_LINEAR;
120                  /* Do we need to swap the 16bit values? (Are we BigEndian) */                  /* Do we need to swap the 16bit values? (Are we BigEndian) */
121                  swapaudio = !(*(uint8 *) (&test));                  g_swapaudio = !(*(uint8 *) (&test));
122          }          }
123    
124          samplewidth = pwfx->wBitsPerSample / 8;          g_samplewidth = pwfx->wBitsPerSample / 8;
125    
126          if (pwfx->nChannels == 1)          if (pwfx->nChannels == 1)
127          {          {
128                  info.play.channels = AUDIO_CHANNELS_MONO;                  info.play.channels = 1;
129          }          }
130          else if (pwfx->nChannels == 2)          else if (pwfx->nChannels == 2)
131          {          {
132                  info.play.channels = AUDIO_CHANNELS_STEREO;                  info.play.channels = 2;
133                  samplewidth *= 2;                  g_samplewidth *= 2;
134          }          }
135    
136          info.play.sample_rate = pwfx->nSamplesPerSec;          info.play.sample_rate = pwfx->nSamplesPerSec;
# Line 137  wave_out_set_format(WAVEFORMATEX * pwfx) Line 138  wave_out_set_format(WAVEFORMATEX * pwfx)
138          info.play.samples = 0;          info.play.samples = 0;
139          info.play.eof = 0;          info.play.eof = 0;
140          info.play.error = 0;          info.play.error = 0;
141          reopened = True;          g_reopened = True;
142    
143          if (ioctl(g_dsp_fd, AUDIO_SETINFO, &info) == -1)          if (ioctl(g_dsp_fd, AUDIO_SETINFO, &info) == -1)
144          {          {
# Line 227  wave_out_play(void) Line 228  wave_out_play(void)
228    
229          while (1)          while (1)
230          {          {
231                  if (reopened)                  if (g_reopened)
232                  {                  {
233                          /* Device was just (re)openend */                          /* Device was just (re)openend */
234                          samplecnt = 0;                          samplecnt = 0;
235                          swapped = False;                          swapped = False;
236                          sentcompletion = True;                          sentcompletion = True;
237                          reopened = False;                          g_reopened = False;
238                  }                  }
239    
240                  if (queue_lo == queue_hi)                  if (queue_lo == queue_hi)
# Line 246  wave_out_play(void) Line 247  wave_out_play(void)
247                  out = &packet->s;                  out = &packet->s;
248    
249                  /* Swap the current packet, but only once */                  /* Swap the current packet, but only once */
250                  if (swapaudio && !swapped)                  if (g_swapaudio && !swapped)
251                  {                  {
252                          for (i = 0; i < out->end - out->p; i += 2)                          for (i = 0; i < out->end - out->p; i += 2)
253                          {                          {
# Line 260  wave_out_play(void) Line 261  wave_out_play(void)
261                  if (sentcompletion)                  if (sentcompletion)
262                  {                  {
263                          sentcompletion = False;                          sentcompletion = False;
264                          numsamples = (out->end - out->p) / samplewidth;                          numsamples = (out->end - out->p) / g_samplewidth;
265                  }                  }
266    
267                  len = 0;                  len = 0;

Legend:
Removed from v.499  
changed lines
  Added in v.559

  ViewVC Help
Powered by ViewVC 1.1.26