/[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 1279 by stargo, Sun Oct 1 14:03:43 2006 UTC revision 1302 by ossman_, Thu Oct 26 09:47:17 2006 UTC
# Line 37  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 unsigned int rate;
41  static char *pcm_name;  static char *pcm_name;
42    
43  BOOL  BOOL
# Line 51  alsa_open(void) Line 52  alsa_open(void)
52          }          }
53    
54          g_dsp_fd = 0;          g_dsp_fd = 0;
         rdpsnd_queue_init();  
55    
56          reopened = True;          reopened = True;
57    
# Line 63  alsa_close(void) Line 63  alsa_close(void)
63  {  {
64          /* Ack all remaining packets */          /* Ack all remaining packets */
65          while (!rdpsnd_queue_empty())          while (!rdpsnd_queue_empty())
66          {                  rdpsnd_queue_next(0);
                 rdpsnd_send_completion(rdpsnd_queue_current_packet()->tick,  
                                        rdpsnd_queue_current_packet()->index);  
                 rdpsnd_queue_next();  
         }  
67    
68          if (pcm_handle)          if (pcm_handle)
69          {          {
# Line 113  BOOL Line 109  BOOL
109  alsa_set_format(WAVEFORMATEX * pwfx)  alsa_set_format(WAVEFORMATEX * pwfx)
110  {  {
111          snd_pcm_hw_params_t *hwparams = NULL;          snd_pcm_hw_params_t *hwparams = NULL;
         unsigned int rate, exact_rate;  
112          int err;          int err;
113          unsigned int buffertime;          unsigned int buffertime;
114    
# Line 165  alsa_set_format(WAVEFORMATEX * pwfx) Line 160  alsa_set_format(WAVEFORMATEX * pwfx)
160          }          }
161  #endif  #endif
162    
163          exact_rate = rate = pwfx->nSamplesPerSec;          rate = pwfx->nSamplesPerSec;
164          if ((err = snd_pcm_hw_params_set_rate_near(pcm_handle, hwparams, &exact_rate, 0)) < 0)          if ((err = snd_pcm_hw_params_set_rate_near(pcm_handle, hwparams, &rate, 0)) < 0)
165          {          {
166                  error("snd_pcm_hw_params_set_rate_near: %s\n", snd_strerror(err));                  error("snd_pcm_hw_params_set_rate_near: %s\n", snd_strerror(err));
167                  return False;                  return False;
# Line 254  alsa_play(void) Line 249  alsa_play(void)
249    
250          if ((out->p == out->end) || duration > next_tick - packet->tick + 500)          if ((out->p == out->end) || duration > next_tick - packet->tick + 500)
251          {          {
252                    snd_pcm_sframes_t delay_frames;
253                    unsigned long delay_us;
254    
255                  prev_s = tv.tv_sec;                  prev_s = tv.tv_sec;
256                  prev_us = tv.tv_usec;                  prev_us = tv.tv_usec;
257    
# Line 264  alsa_play(void) Line 262  alsa_play(void)
262                                 (packet->tick + duration) % 65536, next_tick % 65536));                                 (packet->tick + duration) % 65536, next_tick % 65536));
263                  }                  }
264    
265                  rdpsnd_send_completion(((packet->tick + duration) % 65536), packet->index);                  if (snd_pcm_delay(pcm_handle, &delay_frames) < 0)
266                  rdpsnd_queue_next();                          delay_frames = out->size / (samplewidth * audiochannels);
267                    if (delay_frames < 0)
268                            delay_frames = 0;
269    
270                    delay_us = delay_frames * (1000000 / rate);
271    
272                    rdpsnd_queue_next(delay_us);
273          }          }
274    
275          g_dsp_busy = 1;          g_dsp_busy = 1;
# Line 277  alsa_register(char *options) Line 281  alsa_register(char *options)
281  {  {
282          static struct audio_driver alsa_driver;          static struct audio_driver alsa_driver;
283    
         alsa_driver.wave_out_write = rdpsnd_queue_write;  
284          alsa_driver.wave_out_open = alsa_open;          alsa_driver.wave_out_open = alsa_open;
285          alsa_driver.wave_out_close = alsa_close;          alsa_driver.wave_out_close = alsa_close;
286          alsa_driver.wave_out_format_supported = alsa_format_supported;          alsa_driver.wave_out_format_supported = alsa_format_supported;

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

  ViewVC Help
Powered by ViewVC 1.1.26