/[rdesktop]/sourceforge.net/trunk/rdesktop/rdpsnd_alsa.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_alsa.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 1279 by stargo, Sun Oct 1 14:03:43 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 snd_pcm_stream_t stream = SND_PCM Line 37  static snd_pcm_stream_t stream = SND_PCM
37  static BOOL reopened;  static BOOL reopened;
38  static short samplewidth;  static short samplewidth;
39  static int audiochannels;  static int audiochannels;
40    static char *pcm_name;
41    
42  BOOL  BOOL
43  wave_out_open(void)  alsa_open(void)
44  {  {
         char *pcm_name;  
45          int err;          int err;
46    
         pcm_name = xstrdup(DEFAULTDEVICE);  
   
47          if ((err = snd_pcm_open(&pcm_handle, pcm_name, stream, 0)) < 0)          if ((err = snd_pcm_open(&pcm_handle, pcm_name, stream, 0)) < 0)
48          {          {
49                  error("snd_pcm_open: %s\n", snd_strerror(err));                  error("snd_pcm_open: %s\n", snd_strerror(err));
# Line 60  wave_out_open(void) Line 59  wave_out_open(void)
59  }  }
60    
61  void  void
62  wave_out_close(void)  alsa_close(void)
63  {  {
64          /* Ack all remaining packets */          /* Ack all remaining packets */
65          while (!rdpsnd_queue_empty())          while (!rdpsnd_queue_empty())
# Line 70  wave_out_close(void) Line 69  wave_out_close(void)
69                  rdpsnd_queue_next();                  rdpsnd_queue_next();
70          }          }
71    
   
72          if (pcm_handle)          if (pcm_handle)
73          {          {
74                  snd_pcm_drop(pcm_handle);                  snd_pcm_drop(pcm_handle);
# Line 79  wave_out_close(void) Line 77  wave_out_close(void)
77  }  }
78    
79  BOOL  BOOL
80  wave_out_format_supported(WAVEFORMATEX * pwfx)  alsa_format_supported(WAVEFORMATEX * pwfx)
81  {  {
82  #if 0  #if 0
83          int err;          int err;
# Line 112  wave_out_format_supported(WAVEFORMATEX * Line 110  wave_out_format_supported(WAVEFORMATEX *
110  }  }
111    
112  BOOL  BOOL
113  wave_out_set_format(WAVEFORMATEX * pwfx)  alsa_set_format(WAVEFORMATEX * pwfx)
114  {  {
115          snd_pcm_hw_params_t *hwparams = NULL;          snd_pcm_hw_params_t *hwparams = NULL;
116          unsigned int rate, exact_rate;          unsigned int rate, exact_rate;
# Line 210  wave_out_set_format(WAVEFORMATEX * pwfx) Line 208  wave_out_set_format(WAVEFORMATEX * pwfx)
208  }  }
209    
210  void  void
211  wave_out_volume(uint16 left, uint16 right)  alsa_play(void)
 {  
         static int warned = 0;  
   
         if (!warned)  
         {  
                 warning("volume changes currently not supported with experimental alsa-output\n");  
                 warned = 1;  
         }  
 }  
   
 void  
 wave_out_play(void)  
212  {  {
213          struct audio_packet *packet;          struct audio_packet *packet;
214          STREAM out;          STREAM out;
# Line 285  wave_out_play(void) Line 271  wave_out_play(void)
271          g_dsp_busy = 1;          g_dsp_busy = 1;
272          return;          return;
273  }  }
274    
275    struct audio_driver *
276    alsa_register(char *options)
277    {
278            static struct audio_driver alsa_driver;
279    
280            alsa_driver.wave_out_write = rdpsnd_queue_write;
281            alsa_driver.wave_out_open = alsa_open;
282            alsa_driver.wave_out_close = alsa_close;
283            alsa_driver.wave_out_format_supported = alsa_format_supported;
284            alsa_driver.wave_out_set_format = alsa_set_format;
285            alsa_driver.wave_out_volume = rdpsnd_dsp_softvol_set;
286            alsa_driver.wave_out_play = alsa_play;
287            alsa_driver.name = xstrdup("alsa");
288            alsa_driver.description = xstrdup("ALSA output driver, default device: " DEFAULTDEVICE);
289            alsa_driver.need_byteswap_on_be = 0;
290            alsa_driver.need_resampling = 0;
291            alsa_driver.next = NULL;
292    
293            if (options)
294            {
295                    pcm_name = xstrdup(options);
296            }
297            else
298            {
299                    pcm_name = xstrdup(DEFAULTDEVICE);
300            }
301    
302            return &alsa_driver;
303    }

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

  ViewVC Help
Powered by ViewVC 1.1.26