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

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

revision 760 by stargo, Fri Sep 3 18:04:48 2004 UTC revision 761 by stargo, Fri Sep 3 22:35:08 2004 UTC
# Line 33  int g_dsp_fd; Line 33  int g_dsp_fd;
33  BOOL g_dsp_busy = False;  BOOL g_dsp_busy = False;
34  static int g_snd_rate;  static int g_snd_rate;
35  static short g_samplewidth;  static short g_samplewidth;
36    static BOOL g_driver_broken = False;
37    
38  static struct audio_packet  static struct audio_packet
39  {  {
# Line 85  wave_out_format_supported(WAVEFORMATEX * Line 86  wave_out_format_supported(WAVEFORMATEX *
86  BOOL  BOOL
87  wave_out_set_format(WAVEFORMATEX * pwfx)  wave_out_set_format(WAVEFORMATEX * pwfx)
88  {  {
89          int stereo, format;          int stereo, format, fragments;
90    
91          ioctl(g_dsp_fd, SNDCTL_DSP_RESET, NULL);          ioctl(g_dsp_fd, SNDCTL_DSP_RESET, NULL);
92          ioctl(g_dsp_fd, SNDCTL_DSP_SYNC, NULL);          ioctl(g_dsp_fd, SNDCTL_DSP_SYNC, NULL);
# Line 129  wave_out_set_format(WAVEFORMATEX * pwfx) Line 130  wave_out_set_format(WAVEFORMATEX * pwfx)
130                  return False;                  return False;
131          }          }
132    
133            /* try to get 7 fragments of 2^12 bytes size */
134            fragments = (7 << 16) + 12;
135            ioctl(g_dsp_fd, SNDCTL_DSP_SETFRAGMENT, &fragments);
136    
137            if (!g_driver_broken)
138            {
139                    audio_buf_info info;
140    
141                    if (ioctl(g_dsp_fd, SNDCTL_DSP_GETOSPACE, &info) == -1)
142                    {
143                            perror("SNDCTL_DSP_GETOSPACE");
144                            close(g_dsp_fd);
145                            return False;
146                    }
147    
148                    if (info.fragments == 0 || info.fragstotal == 0 || info.fragsize == 0)
149                    {
150                            fprintf(stderr,
151                                    "Broken OSS-driver detected: fragments: %d, fragstotal: %d, fragsize: %d\n",
152                                    info.fragments, info.fragstotal, info.fragsize);
153                            g_driver_broken = True;
154                    }
155            }
156    
157          return True;          return True;
158  }  }
159    
# Line 203  wave_out_play(void) Line 228  wave_out_play(void)
228          static long startedat_s;          static long startedat_s;
229          static BOOL started = False;          static BOOL started = False;
230          struct timeval tv;          struct timeval tv;
231            audio_buf_info info;
232    
233          while (1)          while (1)
234          {          {
# Line 223  wave_out_play(void) Line 249  wave_out_play(void)
249                          started = True;                          started = True;
250                  }                  }
251    
252                  len = write(g_dsp_fd, out->p, out->end - out->p);                  len = out->end - out->p;
253    
254                    if (!g_driver_broken)
255                    {
256                            if (ioctl(g_dsp_fd, SNDCTL_DSP_GETOSPACE, &info) == -1)
257                            {
258                                    perror("SNDCTL_DSP_GETOSPACE");
259                                    return;
260                            }
261    
262                            if (info.fragments == 0)
263                            {
264                                    g_dsp_busy = 1;
265                                    return;
266                            }
267    
268                            if (info.fragments * info.fragsize < len
269                                && info.fragments * info.fragsize > 0)
270                            {
271                                    len = info.fragments * info.fragsize;
272                            }
273                    }
274    
275    
276                    len = write(g_dsp_fd, out->p, len);
277                  if (len == -1)                  if (len == -1)
278                  {                  {
279                          if (errno != EWOULDBLOCK)                          if (errno != EWOULDBLOCK)

Legend:
Removed from v.760  
changed lines
  Added in v.761

  ViewVC Help
Powered by ViewVC 1.1.26