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

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

revision 1254 by stargo, Sun Sep 17 10:32:18 2006 UTC revision 1268 by stargo, Mon Sep 18 09:34:34 2006 UTC
# Line 22  Line 22 
22    
23  #include "rdesktop.h"  #include "rdesktop.h"
24  #include "rdpsnd.h"  #include "rdpsnd.h"
25    #include "rdpsnd_dsp.h"
26  #include <unistd.h>  #include <unistd.h>
27  #include <fcntl.h>  #include <fcntl.h>
28  #include <errno.h>  #include <errno.h>
# Line 36  static int samplerate; Line 37  static int samplerate;
37  static int audiochannels;  static int audiochannels;
38  static BOOL reopened;  static BOOL reopened;
39  static short samplewidth;  static short samplewidth;
40    static char *libao_device = NULL;
41    
42  BOOL  BOOL
43  wave_out_open(void)  libao_open(void)
44  {  {
45          ao_sample_format format;          ao_sample_format format;
46    
47          ao_initialize();          ao_initialize();
48          default_driver = ao_default_driver_id();  
49            if (libao_device)
50            {
51                    default_driver = ao_driver_id(libao_device);
52            }
53            else
54            {
55                    default_driver = ao_default_driver_id();
56            }
57    
58          format.bits = 16;          format.bits = 16;
59          format.channels = 2;          format.channels = 2;
# Line 67  wave_out_open(void) Line 77  wave_out_open(void)
77  }  }
78    
79  void  void
80  wave_out_close(void)  libao_close(void)
81  {  {
82          /* Ack all remaining packets */          /* Ack all remaining packets */
83          while (!rdpsnd_queue_empty())          while (!rdpsnd_queue_empty())
# Line 84  wave_out_close(void) Line 94  wave_out_close(void)
94  }  }
95    
96  BOOL  BOOL
97  wave_out_format_supported(WAVEFORMATEX * pwfx)  libao_format_supported(WAVEFORMATEX * pwfx)
98  {  {
99          if (pwfx->wFormatTag != WAVE_FORMAT_PCM)          if (pwfx->wFormatTag != WAVE_FORMAT_PCM)
100                  return False;                  return False;
# Line 101  wave_out_format_supported(WAVEFORMATEX * Line 111  wave_out_format_supported(WAVEFORMATEX *
111  }  }
112    
113  BOOL  BOOL
114  wave_out_set_format(WAVEFORMATEX * pwfx)  libao_set_format(WAVEFORMATEX * pwfx)
115  {  {
116          ao_sample_format format;          ao_sample_format format;
117    
# Line 129  wave_out_set_format(WAVEFORMATEX * pwfx) Line 139  wave_out_set_format(WAVEFORMATEX * pwfx)
139  }  }
140    
141  void  void
142  wave_out_volume(uint16 left, uint16 right)  libao_play(void)
 {  
         warning("volume changes not supported with libao-output\n");  
 }  
   
 void  
 wave_out_play(void)  
143  {  {
144          struct audio_packet *packet;          struct audio_packet *packet;
145          STREAM out;          STREAM out;
# Line 225  wave_out_play(void) Line 229  wave_out_play(void)
229          g_dsp_busy = 1;          g_dsp_busy = 1;
230          return;          return;
231  }  }
232    
233    struct audio_driver *
234    libao_register(char *options)
235    {
236            static struct audio_driver libao_driver;
237            struct ao_info *libao_info;
238            static char description[101];
239    
240            libao_driver.wave_out_write = rdpsnd_queue_write;
241            libao_driver.wave_out_open = libao_open;
242            libao_driver.wave_out_close = libao_close;
243            libao_driver.wave_out_format_supported = libao_format_supported;
244            libao_driver.wave_out_set_format = libao_set_format;
245            libao_driver.wave_out_volume = rdpsnd_dsp_softvol_set;
246            libao_driver.wave_out_play = libao_play;
247            libao_driver.name = xstrdup("libao");
248            libao_driver.description = description;
249            libao_driver.need_byteswap_on_be = 0;
250            libao_driver.next = NULL;
251    
252            ao_initialize();
253    
254            libao_info = ao_driver_info(ao_default_driver_id());
255    
256            if (libao_info)
257            {
258                    snprintf(description, 100, "libao output driver, default device: %s",
259                                    libao_info->short_name);
260            }
261            else
262            {
263                    snprintf(description, 100, "libao output driver, default device: none");
264            }
265    
266            ao_shutdown();
267    
268            if (options)
269            {
270                    libao_device = xstrdup(options);
271            }
272    
273            return &libao_driver;
274    }

Legend:
Removed from v.1254  
changed lines
  Added in v.1268

  ViewVC Help
Powered by ViewVC 1.1.26