/[rdesktop]/sourceforge.net/tags/RDESKTOP-1-3-1/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/tags/RDESKTOP-1-3-1/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 561 by stargo, Thu Dec 11 15:07:04 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>
29    
30    #if (defined(sun) && (defined(__svr4__) || defined(__SVR4)))
31  #include <stropts.h>  #include <stropts.h>
32    #endif
33    
34  #define MAX_QUEUE       10  #define MAX_QUEUE       10
35    
36  int g_dsp_fd;  int g_dsp_fd;
37  BOOL g_dsp_busy;  BOOL g_dsp_busy = False;
38  static BOOL reopened;  static BOOL g_reopened;
39  static BOOL swapaudio;  static BOOL g_swapaudio;
40  static short samplewidth;  static short g_samplewidth;
41    
42  static struct audio_packet  static struct audio_packet
43  {  {
# Line 64  wave_out_open(void) Line 67  wave_out_open(void)
67          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);
68    
69          queue_lo = queue_hi = 0;          queue_lo = queue_hi = 0;
70          reopened = True;          g_reopened = True;
71    
72          return True;          return True;
73  }  }
# Line 80  wave_out_close(void) Line 83  wave_out_close(void)
83                  queue_lo = (queue_lo + 1) % MAX_QUEUE;                  queue_lo = (queue_lo + 1) % MAX_QUEUE;
84          }          }
85    
86    #if defined I_FLUSH && defined FLUSHW
87          /* Flush the audiobuffer */          /* Flush the audiobuffer */
88          ioctl(g_dsp_fd, I_FLUSH, FLUSHW);          ioctl(g_dsp_fd, I_FLUSH, FLUSHW);
89    #endif
90    #if defined AUDIO_FLUSH
91            ioctl(g_dsp_fd, AUDIO_FLUSH, NULL);
92    #endif
93          close(g_dsp_fd);          close(g_dsp_fd);
94  }  }
95    
# Line 105  wave_out_set_format(WAVEFORMATEX * pwfx) Line 113  wave_out_set_format(WAVEFORMATEX * pwfx)
113          int test = 1;          int test = 1;
114    
115          ioctl(g_dsp_fd, AUDIO_DRAIN, 0);          ioctl(g_dsp_fd, AUDIO_DRAIN, 0);
116          swapaudio = False;          g_swapaudio = False;
117          AUDIO_INITINFO(&info);          AUDIO_INITINFO(&info);
118    
119    
# Line 117  wave_out_set_format(WAVEFORMATEX * pwfx) Line 125  wave_out_set_format(WAVEFORMATEX * pwfx)
125          {          {
126                  info.play.encoding = AUDIO_ENCODING_LINEAR;                  info.play.encoding = AUDIO_ENCODING_LINEAR;
127                  /* Do we need to swap the 16bit values? (Are we BigEndian) */                  /* Do we need to swap the 16bit values? (Are we BigEndian) */
128                  swapaudio = !(*(uint8 *) (&test));                  g_swapaudio = !(*(uint8 *) (&test));
129          }          }
130    
131          samplewidth = pwfx->wBitsPerSample / 8;          g_samplewidth = pwfx->wBitsPerSample / 8;
132    
133          if (pwfx->nChannels == 1)          if (pwfx->nChannels == 1)
134          {          {
135                  info.play.channels = AUDIO_CHANNELS_MONO;                  info.play.channels = 1;
136          }          }
137          else if (pwfx->nChannels == 2)          else if (pwfx->nChannels == 2)
138          {          {
139                  info.play.channels = AUDIO_CHANNELS_STEREO;                  info.play.channels = 2;
140                  samplewidth *= 2;                  g_samplewidth *= 2;
141          }          }
142    
143          info.play.sample_rate = pwfx->nSamplesPerSec;          info.play.sample_rate = pwfx->nSamplesPerSec;
# Line 137  wave_out_set_format(WAVEFORMATEX * pwfx) Line 145  wave_out_set_format(WAVEFORMATEX * pwfx)
145          info.play.samples = 0;          info.play.samples = 0;
146          info.play.eof = 0;          info.play.eof = 0;
147          info.play.error = 0;          info.play.error = 0;
148          reopened = True;          g_reopened = True;
149    
150          if (ioctl(g_dsp_fd, AUDIO_SETINFO, &info) == -1)          if (ioctl(g_dsp_fd, AUDIO_SETINFO, &info) == -1)
151          {          {
# Line 227  wave_out_play(void) Line 235  wave_out_play(void)
235    
236          while (1)          while (1)
237          {          {
238                  if (reopened)                  if (g_reopened)
239                  {                  {
240                          /* Device was just (re)openend */                          /* Device was just (re)openend */
241                          samplecnt = 0;                          samplecnt = 0;
242                          swapped = False;                          swapped = False;
243                          sentcompletion = True;                          sentcompletion = True;
244                          reopened = False;                          g_reopened = False;
245                  }                  }
246    
247                  if (queue_lo == queue_hi)                  if (queue_lo == queue_hi)
# Line 246  wave_out_play(void) Line 254  wave_out_play(void)
254                  out = &packet->s;                  out = &packet->s;
255    
256                  /* Swap the current packet, but only once */                  /* Swap the current packet, but only once */
257                  if (swapaudio && !swapped)                  if (g_swapaudio && !swapped)
258                  {                  {
259                          for (i = 0; i < out->end - out->p; i += 2)                          for (i = 0; i < out->end - out->p; i += 2)
260                          {                          {
# Line 260  wave_out_play(void) Line 268  wave_out_play(void)
268                  if (sentcompletion)                  if (sentcompletion)
269                  {                  {
270                          sentcompletion = False;                          sentcompletion = False;
271                          numsamples = (out->end - out->p) / samplewidth;                          numsamples = (out->end - out->p) / g_samplewidth;
272                  }                  }
273    
274                  len = 0;                  len = 0;

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

  ViewVC Help
Powered by ViewVC 1.1.26