--- sourceforge.net/trunk/rdesktop/rdpsnd_sun.c 2003/10/13 14:40:40 490 +++ sourceforge.net/trunk/rdesktop/rdpsnd_sun.c 2003/10/13 16:09:45 491 @@ -111,16 +111,16 @@ if (pwfx->wBitsPerSample == 8) { info.play.encoding = AUDIO_ENCODING_LINEAR8; - samplewidth = 1; } else if (pwfx->wBitsPerSample == 16) { info.play.encoding = AUDIO_ENCODING_LINEAR; - samplewidth = 2; /* Do we need to swap the 16bit values? (Are we BigEndian) */ swapaudio = !(*(uint8 *) (&test)); } + samplewidth = pwfx->wBitsPerSample/8; + if (pwfx->nChannels == 1 ) { info.play.channels = AUDIO_CHANNELS_MONO; @@ -136,6 +136,7 @@ info.play.samples = 0; info.play.eof = 0; info.play.error = 0; + reopened = True; if (ioctl(g_dsp_fd, AUDIO_SETINFO, &info) == -1) { @@ -148,6 +149,40 @@ } void +wave_out_volume(uint16 left, uint16 right) +{ + audio_info_t info; + uint balance; + uint volume; + + if (ioctl(g_dsp_fd, AUDIO_GETINFO, &info) == -1) + { + perror("AUDIO_GETINFO"); + return; + } + + volume = (left > right) ? left : right; + + if ( volume/AUDIO_MID_BALANCE != 0 ) + { + balance = AUDIO_MID_BALANCE - (left/(volume/AUDIO_MID_BALANCE)) + (right/(volume/AUDIO_MID_BALANCE)); + } + else + { + balance = AUDIO_MID_BALANCE; + } + + info.play.gain = volume/(65536/AUDIO_MAX_GAIN); + info.play.balance = balance; + + if (ioctl(g_dsp_fd, AUDIO_SETINFO, &info) == -1) + { + perror("AUDIO_SETINFO"); + return; + } +} + +void wave_out_write(STREAM s, uint16 tick, uint8 index) { struct audio_packet *packet = &packet_queue[queue_hi]; @@ -164,6 +199,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); @@ -209,13 +245,13 @@ /* Swap the current packet, but only once */ if ( swapaudio && ! swapped ) { - for ( i = 0; i < out->end - out->p; i+=2 ) + for ( i = 0; i < out->end - out->p; i += 2 ) { swap = *(out->p + i); - *(out->p + i ) = *(out->p + i + 1); + *(out->p + i) = *(out->p + i + 1); *(out->p + i + 1) = swap; - swapped = True; } + swapped = True; } if ( sentcompletion )