--- sourceforge.net/trunk/rdesktop/rdpsnd_oss.c 2003/10/13 16:09:45 491 +++ sourceforge.net/trunk/rdesktop/rdpsnd_oss.c 2003/10/22 12:16:03 509 @@ -29,9 +29,10 @@ #define MAX_QUEUE 10 int g_dsp_fd; -BOOL g_dsp_busy; +BOOL g_dsp_busy = False; -static struct audio_packet { +static struct audio_packet +{ struct stream s; uint16 tick; uint8 index; @@ -43,14 +44,14 @@ { char *dsp_dev = "/dev/dsp"; - if ((g_dsp_fd = open(dsp_dev, O_WRONLY|O_NONBLOCK)) == -1) + if ((g_dsp_fd = open(dsp_dev, O_WRONLY | O_NONBLOCK)) == -1) { perror(dsp_dev); return False; } /* Non-blocking so that user interface is responsive */ - 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); return True; } @@ -61,7 +62,7 @@ } BOOL -wave_out_format_supported(WAVEFORMATEX *pwfx) +wave_out_format_supported(WAVEFORMATEX * pwfx) { if (pwfx->wFormatTag != WAVE_FORMAT_PCM) return False; @@ -74,7 +75,7 @@ } BOOL -wave_out_set_format(WAVEFORMATEX *pwfx) +wave_out_set_format(WAVEFORMATEX * pwfx) { int speed, channels, format; @@ -115,13 +116,34 @@ void wave_out_volume(uint16 left, uint16 right) { + static BOOL use_dev_mixer = False; uint32 volume; + int fd_mix = -1; + + volume = left / (65536 / 100); + volume |= right / (65536 / 100) << 8; + + if (use_dev_mixer) + { + if ((fd_mix = open( "/dev/mixer", O_RDWR|O_NONBLOCK )) == -1 ) + { + perror("open /dev/mixer"); + return; + } + + if (ioctl(fd_mix, MIXER_WRITE(SOUND_MIXER_PCM), &volume) == -1) + { + perror("MIXER_WRITE(SOUND_MIXER_PCM)"); + return; + } + + close(fd_mix); + } - volume = left/(65536/100); - volume |= right/(65536/100) << 8; if (ioctl(g_dsp_fd, MIXER_WRITE(SOUND_MIXER_PCM), &volume) == -1) { perror("MIXER_WRITE(SOUND_MIXER_PCM)"); + use_dev_mixer = True; return; } } @@ -170,7 +192,7 @@ packet = &packet_queue[queue_lo]; out = &packet->s; - len = write(g_dsp_fd, out->p, out->end-out->p); + len = write(g_dsp_fd, out->p, out->end - out->p); if (len == -1) { if (errno != EWOULDBLOCK)