CVS: rdesktop proto.h, 1.102, 1.103 rdpsnd.c, 1.32, 1.33 rdpsnd.h, 1.8, 1.9 rdpsnd_alsa.c, 1.11, 1.12 rdpsnd_libao.c, 1.30, 1.31 rdpsnd_oss.c, 1.31, 1.32 rdpsnd_sgi.c, 1.17, 1.18 rdpsnd_sun.c, 1.24, 1.25 xwin.c, 1.216, 1.217
Pierre Ossman <[email protected]> Thu, 07 Dec 2006 07:23:47 -0800
| Newsgroups | gmane.network.rdesktop.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/rdesktop/rdesktop
In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv12460
Modified Files:
proto.h rdpsnd.c rdpsnd.h rdpsnd_alsa.c rdpsnd_libao.c
rdpsnd_oss.c rdpsnd_sgi.c rdpsnd_sun.c xwin.c
Log Message:
Abstract select() handling in rdpsnd so that backends can do their thing
more correctly.
Index: proto.h
===================================================================
RCS file: /cvsroot/rdesktop/rdesktop/proto.h,v
retrieving revision 1.102
retrieving revision 1.103
diff -C2 -d -r1.102 -r1.103
*** proto.h 3 Nov 2006 23:51:35 -0000 1.102
--- proto.h 7 Dec 2006 15:23:45 -0000 1.103
***************
*** 169,173 ****
BOOL rdpsnd_init(char *optarg);
void rdpsnd_show_help(void);
- void rdpsnd_play(void);
void rdpsnd_add_fds(int *n, fd_set * rfds, fd_set * wfds, struct timeval *tv);
void rdpsnd_check_fds(fd_set * rfds, fd_set * wfds);
--- 169,172 ----
Index: rdpsnd.c
===================================================================
RCS file: /cvsroot/rdesktop/rdesktop/rdpsnd.c,v
retrieving revision 1.32
retrieving revision 1.33
diff -C2 -d -r1.32 -r1.33
*** rdpsnd.c 6 Dec 2006 13:59:43 -0000 1.32
--- rdpsnd.c 7 Dec 2006 15:23:45 -0000 1.33
***************
*** 38,44 ****
#define MAX_QUEUE 10
- BOOL g_dsp_busy = False;
- int g_dsp_fd;
-
static VCHANNEL *rdpsnd_channel;
static struct audio_driver *drivers = NULL;
--- 38,41 ----
***************
*** 95,98 ****
--- 92,123 ----
}
+
+ static BOOL
+ rdpsnd_auto_select(void)
+ {
+ static BOOL failed = False;
+
+ if (!failed)
+ {
+ current_driver = drivers;
+ while (current_driver != NULL)
+ {
+ DEBUG(("trying %s...\n", current_driver->name));
+ if (current_driver->wave_out_open())
+ {
+ DEBUG(("selected %s\n", current_driver->name));
+ return True;
+ }
+ current_driver = current_driver->next;
+ }
+
+ warning("no working audio-driver found\n");
+ failed = True;
+ current_driver = NULL;
+ }
+
+ return False;
+ }
+
static void
rdpsnd_process_negotiate(STREAM in)
***************
*** 116,120 ****
(int) in_format_count, (unsigned) pad, (unsigned) version));
! if (current_driver->wave_out_open())
{
current_driver->wave_out_close();
--- 141,148 ----
(int) in_format_count, (unsigned) pad, (unsigned) version));
! if (!current_driver)
! rdpsnd_auto_select();
!
! if (current_driver && current_driver->wave_out_open())
{
current_driver->wave_out_close();
***************
*** 231,234 ****
--- 259,272 ----
if (!device_open || (format != current_format))
{
+ /*
+ * If we haven't selected a device by now, then either
+ * we've failed to find a working device, or the server
+ * is sending bogus RDPSND_WRITE.
+ */
+ if (!current_driver)
+ {
+ rdpsnd_send_completion(tick, packet_index);
+ break;
+ }
if (!device_open && !current_driver->wave_out_open())
{
***************
*** 254,258 ****
case RDPSND_CLOSE:
DEBUG_SOUND(("RDPSND: RDPSND_CLOSE()\n"));
! current_driver->wave_out_close();
device_open = False;
break;
--- 292,297 ----
case RDPSND_CLOSE:
DEBUG_SOUND(("RDPSND: RDPSND_CLOSE()\n"));
! if (device_open)
! current_driver->wave_out_close();
device_open = False;
break;
***************
*** 334,367 ****
}
- static BOOL
- rdpsnd_auto_open(void)
- {
- static BOOL failed = False;
-
- if (!failed)
- {
- struct audio_driver *auto_driver = current_driver;
-
- current_driver = drivers;
- while (current_driver != NULL)
- {
- DEBUG(("trying %s...\n", current_driver->name));
- if (current_driver->wave_out_open())
- {
- DEBUG(("selected %s\n", current_driver->name));
- return True;
- }
- g_dsp_fd = 0;
- current_driver = current_driver->next;
- }
-
- warning("no working audio-driver found\n");
- failed = True;
- current_driver = auto_driver;
- }
-
- return False;
- }
-
static void
rdpsnd_register_drivers(char *options)
--- 373,376 ----
***************
*** 403,407 ****
rdpsnd_init(char *optarg)
{
- static struct audio_driver auto_driver;
struct audio_driver *pos;
char *driver = NULL, *options = NULL;
--- 412,415 ----
***************
*** 445,453 ****
if (!driver)
- {
- auto_driver.wave_out_open = &rdpsnd_auto_open;
- current_driver = &auto_driver;
return True;
- }
pos = drivers;
--- 453,457 ----
***************
*** 481,499 ****
void
- rdpsnd_play(void)
- {
- current_driver->wave_out_play();
- }
-
- void
rdpsnd_add_fds(int *n, fd_set * rfds, fd_set * wfds, struct timeval *tv)
{
long next_pending;
! if (g_dsp_busy)
! {
! FD_SET(g_dsp_fd, wfds);
! *n = (g_dsp_fd > *n) ? g_dsp_fd : *n;
! }
next_pending = rdpsnd_queue_next_completion();
--- 485,494 ----
void
rdpsnd_add_fds(int *n, fd_set * rfds, fd_set * wfds, struct timeval *tv)
{
long next_pending;
! if (device_open)
! current_driver->add_fds(n, rfds, wfds, tv);
next_pending = rdpsnd_queue_next_completion();
***************
*** 516,521 ****
rdpsnd_queue_complete_pending();
! if (g_dsp_busy && FD_ISSET(g_dsp_fd, wfds))
! rdpsnd_play();
}
--- 511,516 ----
rdpsnd_queue_complete_pending();
! if (device_open)
! current_driver->check_fds(rfds, wfds);
}
***************
*** 539,545 ****
gettimeofday(&packet->arrive_tv, NULL);
-
- if (!g_dsp_busy)
- current_driver->wave_out_play();
}
--- 534,537 ----
Index: rdpsnd.h
===================================================================
RCS file: /cvsroot/rdesktop/rdesktop/rdpsnd.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** rdpsnd.h 26 Oct 2006 09:47:17 -0000 1.8
--- rdpsnd.h 7 Dec 2006 15:23:45 -0000 1.9
***************
*** 31,40 ****
struct audio_driver
{
! BOOL(*wave_out_open) (void);
void (*wave_out_close) (void);
BOOL(*wave_out_format_supported) (WAVEFORMATEX * pwfx);
BOOL(*wave_out_set_format) (WAVEFORMATEX * pwfx);
void (*wave_out_volume) (uint16 left, uint16 right);
! void (*wave_out_play) (void);
char *name;
char *description;
--- 31,43 ----
struct audio_driver
{
! void (*add_fds) (int *n, fd_set * rfds, fd_set * wfds, struct timeval * tv);
! void (*check_fds) (fd_set * rfds, fd_set * wfds);
!
! BOOL(*wave_out_open) (void);
void (*wave_out_close) (void);
BOOL(*wave_out_format_supported) (WAVEFORMATEX * pwfx);
BOOL(*wave_out_set_format) (WAVEFORMATEX * pwfx);
void (*wave_out_volume) (uint16 left, uint16 right);
!
char *name;
char *description;
***************
*** 44,50 ****
};
- extern BOOL g_dsp_busy;
- extern int g_dsp_fd;
-
/* Driver register functions */
struct audio_driver *alsa_register(char *options);
--- 47,50 ----
Index: rdpsnd_alsa.c
===================================================================
RCS file: /cvsroot/rdesktop/rdesktop/rdpsnd_alsa.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** rdpsnd_alsa.c 7 Dec 2006 11:54:29 -0000 1.11
--- rdpsnd_alsa.c 7 Dec 2006 15:23:45 -0000 1.12
***************
*** 33,36 ****
--- 33,39 ----
#define MAX_FRAMES 32
+ static struct pollfd pfds[32];
+ static int num_fds;
+
static snd_pcm_t *pcm_handle = NULL;
static snd_pcm_stream_t stream = SND_PCM_STREAM_PLAYBACK;
***************
*** 41,44 ****
--- 44,112 ----
static char *pcm_name;
+ void alsa_play(void);
+
+ void
+ alsa_add_fds(int *n, fd_set * rfds, fd_set * wfds, struct timeval *tv)
+ {
+ int err;
+ struct pollfd *f;
+
+ if (!pcm_handle)
+ return;
+
+ if (rdpsnd_queue_empty())
+ return;
+
+ num_fds = snd_pcm_poll_descriptors_count(pcm_handle);
+
+ if (num_fds > sizeof(pfds) / sizeof(*pfds))
+ return;
+
+ err = snd_pcm_poll_descriptors(pcm_handle, pfds, num_fds);
+ if (err < 0)
+ return;
+
+ for (f = pfds; f < &pfds[num_fds]; f++)
+ {
+ if (f->events & POLLIN)
+ FD_SET(f->fd, rfds);
+ if (f->events & POLLOUT)
+ FD_SET(f->fd, wfds);
+ if (f->fd > *n && (f->events & (POLLIN | POLLOUT)))
+ *n = f->fd;
+ }
+ }
+
+ void
+ alsa_check_fds(fd_set * rfds, fd_set * wfds)
+ {
+ struct pollfd *f;
+ int err;
+ unsigned short revents;
+
+ if (!pcm_handle)
+ return;
+
+ for (f = pfds; f < &pfds[num_fds]; f++)
+ {
+ f->revents = 0;
+ if (f->fd != -1)
+ {
+ /* Fixme: This doesn't properly deal with things like POLLHUP */
+ if (FD_ISSET(f->fd, rfds))
+ f->revents |= POLLIN;
+ if (FD_ISSET(f->fd, wfds))
+ f->revents |= POLLOUT;
+ }
+ }
+
+ err = snd_pcm_poll_descriptors_revents(pcm_handle, pfds, num_fds, &revents);
+ if (err < 0)
+ return;
+
+ if (revents & POLLOUT)
+ alsa_play();
+ }
+
BOOL
alsa_open(void)
***************
*** 52,57 ****
}
- g_dsp_fd = 0;
-
reopened = True;
--- 120,123 ----
***************
*** 222,230 ****
}
if (rdpsnd_queue_empty())
- {
- g_dsp_busy = 0;
return;
- }
packet = rdpsnd_queue_current_packet();
--- 288,294 ----
}
+ /* We shouldn't be called if the queue is empty, but still */
if (rdpsnd_queue_empty())
return;
packet = rdpsnd_queue_current_packet();
***************
*** 272,278 ****
rdpsnd_queue_next(delay_us);
}
-
- g_dsp_busy = 1;
- return;
}
--- 336,339 ----
***************
*** 281,284 ****
--- 342,348 ----
.description = "ALSA output driver, default device: " DEFAULTDEVICE,
+ .add_fds = alsa_add_fds,
+ .check_fds = alsa_check_fds,
+
.wave_out_open = alsa_open,
.wave_out_close = alsa_close,
***************
*** 286,290 ****
.wave_out_set_format = alsa_set_format,
.wave_out_volume = rdpsnd_dsp_softvol_set,
- .wave_out_play = alsa_play,
.need_byteswap_on_be = 0,
--- 350,353 ----
Index: rdpsnd_libao.c
===================================================================
RCS file: /cvsroot/rdesktop/rdesktop/rdpsnd_libao.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -C2 -d -r1.30 -r1.31
*** rdpsnd_libao.c 7 Dec 2006 11:54:29 -0000 1.30
--- rdpsnd_libao.c 7 Dec 2006 15:23:45 -0000 1.31
***************
*** 37,40 ****
--- 37,57 ----
static char *libao_device = NULL;
+ void libao_play(void);
+
+ void
+ libao_add_fds(int *n, fd_set * rfds, fd_set * wfds, struct timeval *tv)
+ {
+ }
+
+ void
+ libao_check_fds(fd_set * rfds, fd_set * wfds)
+ {
+ if (o_device == NULL)
+ return;
+
+ if (!rdpsnd_queue_empty())
+ libao_play();
+ }
+
BOOL
libao_open(void)
***************
*** 65,70 ****
}
- g_dsp_fd = 0;
-
reopened = True;
--- 82,85 ----
***************
*** 84,87 ****
--- 99,104 ----
ao_close(o_device);
+ o_device = NULL;
+
ao_shutdown();
}
***************
*** 135,143 ****
}
if (rdpsnd_queue_empty())
- {
- g_dsp_busy = 0;
return;
- }
packet = rdpsnd_queue_current_packet();
--- 152,158 ----
}
+ /* We shouldn't be called if the queue is empty, but still */
if (rdpsnd_queue_empty())
return;
packet = rdpsnd_queue_current_packet();
***************
*** 171,177 ****
rdpsnd_queue_next(duration);
}
-
- g_dsp_busy = 1;
- return;
}
--- 186,189 ----
***************
*** 180,183 ****
--- 192,198 ----
.description = "libao output driver, default device: system dependent",
+ .add_fds = libao_add_fds,
+ .check_fds = libao_check_fds,
+
.wave_out_open = libao_open,
.wave_out_close = libao_close,
***************
*** 185,189 ****
.wave_out_set_format = libao_set_format,
.wave_out_volume = rdpsnd_dsp_softvol_set,
- .wave_out_play = libao_play,
.need_byteswap_on_be = 1,
--- 200,203 ----
Index: rdpsnd_oss.c
===================================================================
RCS file: /cvsroot/rdesktop/rdesktop/rdpsnd_oss.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -C2 -d -r1.31 -r1.32
*** rdpsnd_oss.c 7 Dec 2006 11:54:29 -0000 1.31
--- rdpsnd_oss.c 7 Dec 2006 15:23:45 -0000 1.32
***************
*** 44,47 ****
--- 44,50 ----
#define MAX_LEN 512
+ static int dsp_fd = -1;
+ static BOOL dsp_busy;
+
static int snd_rate;
static short samplewidth;
***************
*** 52,55 ****
--- 55,81 ----
static struct audio_driver oss_driver;
+ void oss_play(void);
+
+ void
+ oss_add_fds(int *n, fd_set * rfds, fd_set * wfds, struct timeval *tv)
+ {
+ if (dsp_fd == -1)
+ return;
+
+ if (rdpsnd_queue_empty())
+ return;
+
+ FD_SET(dsp_fd, wfds);
+ if (dsp_fd > *n)
+ *n = dsp_fd;
+ }
+
+ void
+ oss_check_fds(fd_set * rfds, fd_set * wfds)
+ {
+ if (FD_ISSET(dsp_fd, wfds))
+ oss_play();
+ }
+
static BOOL
detect_esddsp(void)
***************
*** 58,62 ****
char *preload;
! if (fstat(g_dsp_fd, &s) == -1)
return False;
--- 84,88 ----
char *preload;
! if (fstat(dsp_fd, &s) == -1)
return False;
***************
*** 77,81 ****
oss_open(void)
{
! if ((g_dsp_fd = open(dsp_dev, O_WRONLY)) == -1)
{
perror(dsp_dev);
--- 103,107 ----
oss_open(void)
{
! if ((dsp_fd = open(dsp_dev, O_WRONLY)) == -1)
{
perror(dsp_dev);
***************
*** 91,96 ****
oss_close(void)
{
! close(g_dsp_fd);
! g_dsp_busy = 0;
}
--- 117,123 ----
oss_close(void)
{
! close(dsp_fd);
! dsp_fd = -1;
! dsp_busy = False;
}
***************
*** 114,119 ****
static BOOL driver_broken = False;
! ioctl(g_dsp_fd, SNDCTL_DSP_RESET, NULL);
! ioctl(g_dsp_fd, SNDCTL_DSP_SYNC, NULL);
if (pwfx->wBitsPerSample == 8)
--- 141,146 ----
static BOOL driver_broken = False;
! ioctl(dsp_fd, SNDCTL_DSP_RESET, NULL);
! ioctl(dsp_fd, SNDCTL_DSP_SYNC, NULL);
if (pwfx->wBitsPerSample == 8)
***************
*** 124,128 ****
samplewidth = pwfx->wBitsPerSample / 8;
! if (ioctl(g_dsp_fd, SNDCTL_DSP_SETFMT, &format) == -1)
{
perror("SNDCTL_DSP_SETFMT");
--- 151,155 ----
samplewidth = pwfx->wBitsPerSample / 8;
! if (ioctl(dsp_fd, SNDCTL_DSP_SETFMT, &format) == -1)
{
perror("SNDCTL_DSP_SETFMT");
***************
*** 141,145 ****
}
! if (ioctl(g_dsp_fd, SNDCTL_DSP_STEREO, &stereo) == -1)
{
perror("SNDCTL_DSP_CHANNELS");
--- 168,172 ----
}
! if (ioctl(dsp_fd, SNDCTL_DSP_STEREO, &stereo) == -1)
{
perror("SNDCTL_DSP_CHANNELS");
***************
*** 150,154 ****
oss_driver.need_resampling = 0;
snd_rate = pwfx->nSamplesPerSec;
! if (ioctl(g_dsp_fd, SNDCTL_DSP_SPEED, &snd_rate) == -1)
{
int rates[] = { 44100, 48000, 0 };
--- 177,181 ----
oss_driver.need_resampling = 0;
snd_rate = pwfx->nSamplesPerSec;
! if (ioctl(dsp_fd, SNDCTL_DSP_SPEED, &snd_rate) == -1)
{
int rates[] = { 44100, 48000, 0 };
***************
*** 158,162 ****
{
if ((pwfx->nSamplesPerSec != *prates)
! && (ioctl(g_dsp_fd, SNDCTL_DSP_SPEED, prates) != -1))
{
oss_driver.need_resampling = 1;
--- 185,189 ----
{
if ((pwfx->nSamplesPerSec != *prates)
! && (ioctl(dsp_fd, SNDCTL_DSP_SPEED, prates) != -1))
{
oss_driver.need_resampling = 1;
***************
*** 185,189 ****
/* try to get 12 fragments of 2^12 bytes size */
fragments = (12 << 16) + 12;
! ioctl(g_dsp_fd, SNDCTL_DSP_SETFRAGMENT, &fragments);
if (!driver_broken)
--- 212,216 ----
/* try to get 12 fragments of 2^12 bytes size */
fragments = (12 << 16) + 12;
! ioctl(dsp_fd, SNDCTL_DSP_SETFRAGMENT, &fragments);
if (!driver_broken)
***************
*** 192,196 ****
memset(&info, 0, sizeof(info));
! if (ioctl(g_dsp_fd, SNDCTL_DSP_GETOSPACE, &info) == -1)
{
perror("SNDCTL_DSP_GETOSPACE");
--- 219,223 ----
memset(&info, 0, sizeof(info));
! if (ioctl(dsp_fd, SNDCTL_DSP_GETOSPACE, &info) == -1)
{
perror("SNDCTL_DSP_GETOSPACE");
***************
*** 219,223 ****
volume |= right / (65536 / 100) << 8;
! if (ioctl(g_dsp_fd, MIXER_WRITE(SOUND_MIXER_PCM), &volume) == -1)
{
warning("hardware volume control unavailable, falling back to software volume control!\n");
--- 246,250 ----
volume |= right / (65536 / 100) << 8;
! if (ioctl(dsp_fd, MIXER_WRITE(SOUND_MIXER_PCM), &volume) == -1)
{
warning("hardware volume control unavailable, falling back to software volume control!\n");
***************
*** 235,243 ****
STREAM out;
if (rdpsnd_queue_empty())
- {
- g_dsp_busy = 0;
return;
- }
packet = rdpsnd_queue_current_packet();
--- 262,268 ----
STREAM out;
+ /* We shouldn't be called if the queue is empty, but still */
if (rdpsnd_queue_empty())
return;
packet = rdpsnd_queue_current_packet();
***************
*** 246,255 ****
len = out->end - out->p;
! len = write(g_dsp_fd, out->p, (len > MAX_LEN) ? MAX_LEN : len);
if (len == -1)
{
if (errno != EWOULDBLOCK)
perror("write audio");
- g_dsp_busy = 1;
return;
}
--- 271,279 ----
len = out->end - out->p;
! len = write(dsp_fd, out->p, (len > MAX_LEN) ? MAX_LEN : len);
if (len == -1)
{
if (errno != EWOULDBLOCK)
perror("write audio");
return;
}
***************
*** 273,277 ****
#ifdef SNDCTL_DSP_GETODELAY
delay_bytes = 0;
! if (ioctl(g_dsp_fd, SNDCTL_DSP_GETODELAY, &delay_bytes) == -1)
delay_bytes = -1;
#else
--- 297,301 ----
#ifdef SNDCTL_DSP_GETODELAY
delay_bytes = 0;
! if (ioctl(dsp_fd, SNDCTL_DSP_GETODELAY, &delay_bytes) == -1)
delay_bytes = -1;
#else
***************
*** 281,285 ****
if (delay_bytes == -1)
{
! if (ioctl(g_dsp_fd, SNDCTL_DSP_GETOSPACE, &info) != -1)
delay_bytes = info.fragstotal * info.fragsize - info.bytes;
else
--- 305,309 ----
if (delay_bytes == -1)
{
! if (ioctl(dsp_fd, SNDCTL_DSP_GETOSPACE, &info) != -1)
delay_bytes = info.fragstotal * info.fragsize - info.bytes;
else
***************
*** 291,300 ****
rdpsnd_queue_next(delay_us);
}
- else
- {
- g_dsp_busy = 1;
- }
-
- return;
}
--- 315,318 ----
***************
*** 303,306 ****
--- 321,327 ----
.description = "OSS output driver, default device: " DEFAULTDEVICE " or $AUDIODEV",
+ .add_fds = oss_add_fds,
+ .check_fds = oss_check_fds,
+
.wave_out_open = oss_open,
.wave_out_close = oss_close,
***************
*** 308,312 ****
.wave_out_set_format = oss_set_format,
.wave_out_volume = oss_volume,
- .wave_out_play = oss_play,
.need_byteswap_on_be = 0,
--- 329,332 ----
Index: rdpsnd_sgi.c
===================================================================
RCS file: /cvsroot/rdesktop/rdesktop/rdpsnd_sgi.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** rdpsnd_sgi.c 7 Dec 2006 11:54:29 -0000 1.17
--- rdpsnd_sgi.c 7 Dec 2006 15:23:45 -0000 1.18
***************
*** 40,43 ****
--- 40,60 ----
int combinedFrameSize;
+ void sgi_play(void);
+
+ void
+ sgi_add_fds(int *n, fd_set * rfds, fd_set * wfds, struct timeval *tv)
+ {
+ }
+
+ void
+ sgi_check_fds(fd_set * rfds, fd_set * wfds)
+ {
+ if (output_port == (ALport) 0)
+ return;
+
+ if (!rdpsnd_queue_empty())
+ sgi_play();
+ }
+
BOOL
sgi_open(void)
***************
*** 102,105 ****
--- 119,123 ----
alClosePort(output_port);
+ output_port = (ALport) 0;
alFreeConfig(audioconfig);
#if (defined(IRIX_DEBUG))
***************
*** 241,248 ****
{
if (rdpsnd_queue_empty())
- {
- g_dsp_busy = False;
return;
- }
packet = rdpsnd_queue_current_packet();
--- 259,263 ----
***************
*** 266,270 ****
/* fprintf(stderr,"Busy playing...\n"); */
#endif
- g_dsp_busy = True;
usleep(10);
return;
--- 281,284 ----
***************
*** 278,281 ****
--- 292,298 ----
.description = "SGI output driver",
+ .add_fds = sgi_add_fds,
+ .check_fds = sgi_check_fds,
+
.wave_out_open = sgi_open,
.wave_out_close = sgi_close,
***************
*** 283,287 ****
.wave_out_set_format = sgi_set_format,
.wave_out_volume = sgi_volume,
- .wave_out_play = sgi_play,
.need_byteswap_on_be = 1,
--- 300,303 ----
Index: rdpsnd_sun.c
===================================================================
RCS file: /cvsroot/rdesktop/rdesktop/rdpsnd_sun.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -C2 -d -r1.24 -r1.25
*** rdpsnd_sun.c 7 Dec 2006 11:54:29 -0000 1.24
--- rdpsnd_sun.c 7 Dec 2006 15:23:45 -0000 1.25
***************
*** 35,46 ****
#define DEFAULTDEVICE "/dev/audio"
static BOOL g_reopened;
static short g_samplewidth;
static char *dsp_dev;
BOOL
sun_open(void)
{
! if ((g_dsp_fd = open(dsp_dev, O_WRONLY | O_NONBLOCK)) == -1)
{
perror(dsp_dev);
--- 35,72 ----
#define DEFAULTDEVICE "/dev/audio"
+ static int dsp_fd = -1;
+ static BOOL dsp_busy;
+
static BOOL g_reopened;
static short g_samplewidth;
static char *dsp_dev;
+ void oss_play(void);
+
+ void
+ sun_add_fds(int *n, fd_set * rfds, fd_set * wfds, struct timeval *tv)
+ {
+ if (dsp_fd == -1)
+ return;
+
+ if (rdpsnd_queue_empty())
+ return;
+
+ FD_SET(dsp_fd, wfds);
+ if (dsp_fd > *n)
+ *n = dsp_fd;
+ }
+
+ void
+ sun_check_fds(fd_set * rfds, fd_set * wfds)
+ {
+ if (FD_ISSET(dsp_fd, wfds))
+ sun_play();
+ }
+
BOOL
sun_open(void)
{
! if ((dsp_fd = open(dsp_dev, O_WRONLY | O_NONBLOCK)) == -1)
{
perror(dsp_dev);
***************
*** 49,53 ****
/* Non-blocking so that user interface is responsive */
! fcntl(g_dsp_fd, F_SETFL, fcntl(g_dsp_fd, F_GETFL) | O_NONBLOCK);
g_reopened = True;
--- 75,79 ----
/* Non-blocking so that user interface is responsive */
! fcntl(dsp_fd, F_SETFL, fcntl(dsp_fd, F_GETFL) | O_NONBLOCK);
g_reopened = True;
***************
*** 65,74 ****
#if defined I_FLUSH && defined FLUSHW
/* Flush the audiobuffer */
! ioctl(g_dsp_fd, I_FLUSH, FLUSHW);
#endif
#if defined AUDIO_FLUSH
! ioctl(g_dsp_fd, AUDIO_FLUSH, NULL);
#endif
! close(g_dsp_fd);
}
--- 91,101 ----
#if defined I_FLUSH && defined FLUSHW
/* Flush the audiobuffer */
! ioctl(dsp_fd, I_FLUSH, FLUSHW);
#endif
#if defined AUDIO_FLUSH
! ioctl(dsp_fd, AUDIO_FLUSH, NULL);
#endif
! close(dsp_fd);
! dsp_fd = -1;
}
***************
*** 91,95 ****
audio_info_t info;
! ioctl(g_dsp_fd, AUDIO_DRAIN, 0);
AUDIO_INITINFO(&info);
--- 118,122 ----
audio_info_t info;
! ioctl(dsp_fd, AUDIO_DRAIN, 0);
AUDIO_INITINFO(&info);
***************
*** 123,130 ****
g_reopened = True;
! if (ioctl(g_dsp_fd, AUDIO_SETINFO, &info) == -1)
{
perror("AUDIO_SETINFO");
! close(g_dsp_fd);
return False;
}
--- 150,157 ----
g_reopened = True;
! if (ioctl(dsp_fd, AUDIO_SETINFO, &info) == -1)
{
perror("AUDIO_SETINFO");
! sun_close();
return False;
}
***************
*** 158,162 ****
info.play.balance = balance;
! if (ioctl(g_dsp_fd, AUDIO_SETINFO, &info) == -1)
{
perror("AUDIO_SETINFO");
--- 185,189 ----
info.play.balance = balance;
! if (ioctl(dsp_fd, AUDIO_SETINFO, &info) == -1)
{
perror("AUDIO_SETINFO");
***************
*** 188,195 ****
if (rdpsnd_queue_empty())
- {
- g_dsp_busy = 0;
return;
- }
packet = rdpsnd_queue_current_packet();
--- 215,219 ----
***************
*** 206,215 ****
if (out->end != out->p)
{
! len = write(g_dsp_fd, out->p, out->end - out->p);
if (len == -1)
{
if (errno != EWOULDBLOCK)
perror("write audio");
- g_dsp_busy = 1;
return;
}
--- 230,238 ----
if (out->end != out->p)
{
! len = write(dsp_fd, out->p, out->end - out->p);
if (len == -1)
{
if (errno != EWOULDBLOCK)
perror("write audio");
return;
}
***************
*** 219,223 ****
if (out->p == out->end)
{
! if (ioctl(g_dsp_fd, AUDIO_GETINFO, &info) == -1)
{
perror("AUDIO_GETINFO");
--- 242,246 ----
if (out->p == out->end)
{
! if (ioctl(dsp_fd, AUDIO_GETINFO, &info) == -1)
{
perror("AUDIO_GETINFO");
***************
*** 236,240 ****
else
{
- g_dsp_busy = 1;
return;
}
--- 259,262 ----
***************
*** 247,250 ****
--- 269,275 ----
.description = "SUN/BSD output driver, default device: " DEFAULTDEVICE " or $AUDIODEV",
+ .add_fds = sun_add_fds,
+ .check_fds = sun_check_fds,
+
.wave_out_open = sun_open,
.wave_out_close = sun_close,
***************
*** 252,256 ****
.wave_out_set_format = sun_set_format,
.wave_out_volume = sun_volume,
- .wave_out_play = sun_play,
.need_byteswap_on_be = 1,
--- 277,280 ----
Index: xwin.c
===================================================================
RCS file: /cvsroot/rdesktop/rdesktop/xwin.c,v
retrieving revision 1.216
retrieving revision 1.217
diff -C2 -d -r1.216 -r1.217
*** xwin.c 27 Oct 2006 12:59:38 -0000 1.216
--- xwin.c 7 Dec 2006 15:23:45 -0000 1.217
***************
*** 148,153 ****
#ifdef WITH_RDPSND
- extern int g_dsp_fd;
- extern BOOL g_dsp_busy;
extern BOOL g_rdpsnd;
#endif
--- 148,151 ----
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV