/[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

revision 1256 by stargo, Sun Sep 17 11:42:22 2006 UTC revision 1345 by ossman_, Thu Dec 7 11:54:29 2006 UTC
# Line 35  Line 35 
35  #define DEFAULTDEVICE   "/dev/audio"  #define DEFAULTDEVICE   "/dev/audio"
36    
37  static BOOL g_reopened;  static BOOL g_reopened;
 static BOOL g_swapaudio;  
38  static short g_samplewidth;  static short g_samplewidth;
39  static char *dsp_dev;  static char *dsp_dev;
40    
# Line 51  sun_open(void) Line 50  sun_open(void)
50          /* Non-blocking so that user interface is responsive */          /* Non-blocking so that user interface is responsive */
51          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);
52    
         rdpsnd_queue_init();  
53          g_reopened = True;          g_reopened = True;
54    
55          return True;          return True;
# Line 62  sun_close(void) Line 60  sun_close(void)
60  {  {
61          /* Ack all remaining packets */          /* Ack all remaining packets */
62          while (!rdpsnd_queue_empty())          while (!rdpsnd_queue_empty())
63          {                  rdpsnd_queue_next(0);
                 rdpsnd_send_completion(rdpsnd_queue_current_packet()->tick,  
                                        rdpsnd_queue_current_packet()->index);  
                 rdpsnd_queue_next();  
         }  
64    
65  #if defined I_FLUSH && defined FLUSHW  #if defined I_FLUSH && defined FLUSHW
66          /* Flush the audiobuffer */          /* Flush the audiobuffer */
# Line 97  sun_set_format(WAVEFORMATEX * pwfx) Line 91  sun_set_format(WAVEFORMATEX * pwfx)
91          audio_info_t info;          audio_info_t info;
92    
93          ioctl(g_dsp_fd, AUDIO_DRAIN, 0);          ioctl(g_dsp_fd, AUDIO_DRAIN, 0);
         g_swapaudio = False;  
94          AUDIO_INITINFO(&info);          AUDIO_INITINFO(&info);
95    
96    
# Line 108  sun_set_format(WAVEFORMATEX * pwfx) Line 101  sun_set_format(WAVEFORMATEX * pwfx)
101          else if (pwfx->wBitsPerSample == 16)          else if (pwfx->wBitsPerSample == 16)
102          {          {
103                  info.play.encoding = AUDIO_ENCODING_LINEAR;                  info.play.encoding = AUDIO_ENCODING_LINEAR;
                 /* Do we need to swap the 16bit values? (Are we BigEndian) */  
 #ifdef B_ENDIAN  
                 g_swapaudio = 1;  
 #else  
                 g_swapaudio = 0;  
 #endif  
104          }          }
105    
106          g_samplewidth = pwfx->wBitsPerSample / 8;          g_samplewidth = pwfx->wBitsPerSample / 8;
# Line 184  sun_play(void) Line 171  sun_play(void)
171          audio_info_t info;          audio_info_t info;
172          ssize_t len;          ssize_t len;
173          unsigned int i;          unsigned int i;
         uint8 swap;  
174          STREAM out;          STREAM out;
         static BOOL swapped = False;  
175          static BOOL sentcompletion = True;          static BOOL sentcompletion = True;
176          static uint32 samplecnt = 0;          static uint32 samplecnt = 0;
177          static uint32 numsamples;          static uint32 numsamples;
# Line 197  sun_play(void) Line 182  sun_play(void)
182                  {                  {
183                          /* Device was just (re)openend */                          /* Device was just (re)openend */
184                          samplecnt = 0;                          samplecnt = 0;
                         swapped = False;  
185                          sentcompletion = True;                          sentcompletion = True;
186                          g_reopened = False;                          g_reopened = False;
187                  }                  }
# Line 211  sun_play(void) Line 195  sun_play(void)
195                  packet = rdpsnd_queue_current_packet();                  packet = rdpsnd_queue_current_packet();
196                  out = &packet->s;                  out = &packet->s;
197    
                 /* Swap the current packet, but only once */  
                 if (g_swapaudio && !swapped)  
                 {  
                         for (i = 0; i < out->end - out->p; i += 2)  
                         {  
                                 swap = *(out->p + i);  
                                 *(out->p + i) = *(out->p + i + 1);  
                                 *(out->p + i + 1) = swap;  
                         }  
                         swapped = True;  
                 }  
   
198                  if (sentcompletion)                  if (sentcompletion)
199                  {                  {
200                          sentcompletion = False;                          sentcompletion = False;
# Line 258  sun_play(void) Line 230  sun_play(void)
230                                  samplecnt += numsamples;                                  samplecnt += numsamples;
231                                  /* We need to add 50 to tell windows that time has passed while                                  /* We need to add 50 to tell windows that time has passed while
232                                   * playing this packet */                                   * playing this packet */
233                                  rdpsnd_send_completion(packet->tick + 50, packet->index);                                  rdpsnd_queue_next(50);
                                 rdpsnd_queue_next();  
                                 swapped = False;  
234                                  sentcompletion = True;                                  sentcompletion = True;
235                          }                          }
236                          else                          else
# Line 272  sun_play(void) Line 242  sun_play(void)
242          }          }
243  }  }
244    
245    static struct audio_driver sun_driver = {
246            .name = "sun",
247            .description = "SUN/BSD output driver, default device: " DEFAULTDEVICE " or $AUDIODEV",
248    
249            .wave_out_open = sun_open,
250            .wave_out_close = sun_close,
251            .wave_out_format_supported = sun_format_supported,
252            .wave_out_set_format = sun_set_format,
253            .wave_out_volume = sun_volume,
254            .wave_out_play = sun_play,
255    
256            .need_byteswap_on_be = 1,
257            .need_resampling = 0,
258    };
259    
260  struct audio_driver *  struct audio_driver *
261  sun_register(char *options)  sun_register(char *options)
262  {  {
         static struct audio_driver sun_driver;  
   
         sun_driver.wave_out_write = rdpsnd_queue_write;  
         sun_driver.wave_out_open = sun_open;  
         sun_driver.wave_out_close = sun_close;  
         sun_driver.wave_out_format_supported = sun_format_supported;  
         sun_driver.wave_out_set_format = sun_set_format;  
         sun_driver.wave_out_volume = sun_volume;  
         sun_driver.wave_out_play = sun_play;  
         sun_driver.name = xstrdup("sun");  
         sun_driver.description =  
                 xstrdup("SUN/BSD output driver, default device: " DEFAULTDEVICE " or $AUDIODEV");  
         sun_driver.next = NULL;  
   
263          if (options)          if (options)
264          {          {
265                  dsp_dev = xstrdup(options);                  dsp_dev = xstrdup(options);

Legend:
Removed from v.1256  
changed lines
  Added in v.1345

  ViewVC Help
Powered by ViewVC 1.1.26