--- sourceforge.net/trunk/rdesktop/rdpsnd_oss.c 2003/10/04 00:03:24 476 +++ sourceforge.net/trunk/rdesktop/rdpsnd_oss.c 2003/10/19 11:59:41 504 @@ -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)) == -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; @@ -113,6 +114,20 @@ } void +wave_out_volume(uint16 left, uint16 right) +{ + uint32 volume; + + 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)"); + return; + } +} + +void wave_out_write(STREAM s, uint16 tick, uint8 index) { struct audio_packet *packet = &packet_queue[queue_hi]; @@ -129,6 +144,7 @@ packet->s = *s; packet->tick = tick; packet->index = index; + packet->s.p += 4; /* we steal the data buffer from s, give it a new one */ s->data = malloc(s->size); @@ -155,7 +171,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)