CVS: rdesktop configure.ac, 1.22, 1.23 proto.h, 1.93, 1.94 rdesktop.c, 1.149, 1.150 rdpsnd.c, 1.11, 1.12 rdpsnd.h, 1.1, 1.2 rdpsnd_alsa.c, 1.2, 1.3 rdpsnd_libao.c, 1.15, 1.16 rdpsnd_oss.c, 1.21, 1.22 rdpsnd_sgi.c, 1.10, 1.11 rdpsnd_sun.c, 1.17, 1.18 xwin.c, 1.213, 1.214

Michael Gernoth <[email protected]> Sun, 17 Sep 2006 04:04:55 -0700
Newsgroups gmane.network.rdesktop.cvs
Message-ID <[email protected]>
Update of /cvsroot/rdesktop/rdesktop
In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv5968

Modified Files:
	configure.ac proto.h rdesktop.c rdpsnd.c rdpsnd.h 
	rdpsnd_alsa.c rdpsnd_libao.c rdpsnd_oss.c rdpsnd_sgi.c 
	rdpsnd_sun.c xwin.c 
Log Message:
allow multiple sound-drivers to be compiled in simultaneously and
make the runtime selectable


Index: configure.ac
===================================================================
RCS file: /cvsroot/rdesktop/rdesktop/configure.ac,v
retrieving revision 1.22
retrieving revision 1.23
diff -C2 -d -r1.22 -r1.23
*** configure.ac	17 Sep 2006 10:00:55 -0000	1.22
--- configure.ac	17 Sep 2006 11:04:49 -0000	1.23
***************
*** 157,167 ****
      ])
  if test "$sound" = yes; then
!     AC_CHECK_HEADER(ao/ao.h, [sound=libao])
!     AC_CHECK_HEADER(sys/soundcard.h, [sound=oss])
!     AC_CHECK_HEADER(dmedia/audio.h, [sound=sgi])
!     AC_CHECK_HEADER(sys/audioio.h, [sound=sun])
  fi
  if test "$sound" = no; then
      break
  elif test "$sound" = oss; then
      SOUNDOBJ="rdpsnd.o rdpsnd_oss.o"
--- 157,200 ----
      ])
  if test "$sound" = yes; then
!     AC_CHECK_HEADER(ao/ao.h,
! 	[
! 	sound=auto
! 	SOUNDOBJ="$SOUNDOBJ rdpsnd_libao.o"
! 	LDFLAGS="$LDFLAGS -lao"
! 	AC_DEFINE(RDPSND_LIBAO)
! 	])
!     AC_CHECK_HEADER(sys/soundcard.h,
! 	[
! 	sound=auto
! 	SOUNDOBJ="$SOUNDOBJ rdpsnd_oss.o"
! 	AC_DEFINE(RDPSND_OSS)
! 	])
!     AC_CHECK_HEADER(dmedia/audio.h,
! 	[
! 	sound=auto
! 	SOUNDOBJ="$SOUNDOBJ rdpsnd_sgi.o"
! 	LDFLAGS="$LDFLAGS -laudio"
! 	AC_DEFINE(RDPSND_SGI)
! 	])
!     AC_CHECK_HEADER(sys/audioio.h,
! 	[
! 	sound=auto
! 	SOUNDOBJ="$SOUNDOBJ rdpsnd_sun.o"
! 	AC_DEFINE(RDPSND_SUN)
! 	])
!     AC_CHECK_HEADER(alsa/asoundlib.h,
! 	[
! 	sound=auto
! 	SOUNDOBJ="$SOUNDOBJ rdpsnd_alsa.o"
! 	LDFLAGS="$LDFLAGS -lasound"
! 	AC_DEFINE(RDPSND_ALSA)
! 	])
  fi
+ 
  if test "$sound" = no; then
      break
+ elif test "$sound" = auto; then
+     SOUNDOBJ="$SOUNDOBJ rdpsnd.o"
+     AC_DEFINE(WITH_RDPSND)
  elif test "$sound" = oss; then
      SOUNDOBJ="rdpsnd.o rdpsnd_oss.o"
***************
*** 170,173 ****
--- 203,208 ----
      SOUNDOBJ="rdpsnd.o rdpsnd_sgi.o"
      LDFLAGS="$LDFLAGS -laudio"
+ elif test "$sound" = yes; then
+     SOUNDOBJ="$SOUNDOBJ rdpsnd.o"
      AC_DEFINE(WITH_RDPSND)
  elif test "$sound" = sun; then
***************
*** 177,185 ****
      SOUNDOBJ="rdpsnd.o rdpsnd_libao.o"
      LDFLAGS="$LDFLAGS -lao"
!     AC_DEFINE(WITH_RDPSND)
  elif test "$sound" = alsa; then
      SOUNDOBJ="rdpsnd.o rdpsnd_alsa.o"
      LDFLAGS="$LDFLAGS -lasound"
      AC_DEFINE(WITH_RDPSND)
  else
     AC_MSG_WARN([sound support disabled])
--- 212,221 ----
      SOUNDOBJ="rdpsnd.o rdpsnd_libao.o"
      LDFLAGS="$LDFLAGS -lao"
!     AC_DEFINE(RDPSND_SUN)
  elif test "$sound" = alsa; then
      SOUNDOBJ="rdpsnd.o rdpsnd_alsa.o"
      LDFLAGS="$LDFLAGS -lasound"
      AC_DEFINE(WITH_RDPSND)
+     AC_DEFINE(RDPSND_ALSA)
  else
     AC_MSG_WARN([sound support disabled])

Index: proto.h
===================================================================
RCS file: /cvsroot/rdesktop/rdesktop/proto.h,v
retrieving revision 1.93
retrieving revision 1.94
diff -C2 -d -r1.93 -r1.94
*** proto.h	28 Apr 2006 07:55:36 -0000	1.93
--- proto.h	17 Sep 2006 11:04:49 -0000	1.94
***************
*** 166,177 ****
  void rdpsnd_send_completion(uint16 tick, uint8 packet_index);
  BOOL rdpsnd_init(void);
! /* rdpsnd_oss.c */
! 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_write(STREAM s, uint16 tick, uint8 index);
! void wave_out_play(void);
  /* secure.c */
  void sec_hash_48(uint8 * out, uint8 * in, uint8 * salt1, uint8 * salt2, uint8 salt);
--- 166,172 ----
  void rdpsnd_send_completion(uint16 tick, uint8 packet_index);
  BOOL rdpsnd_init(void);
! BOOL rdpsnd_select_driver(char *driver, char *options);
! void rdpsnd_show_help(void);
! inline void rdpsnd_play(void);
  /* secure.c */
  void sec_hash_48(uint8 * out, uint8 * in, uint8 * salt1, uint8 * salt2, uint8 salt);

Index: rdesktop.c
===================================================================
RCS file: /cvsroot/rdesktop/rdesktop/rdesktop.c,v
retrieving revision 1.149
retrieving revision 1.150
diff -C2 -d -r1.149 -r1.150
*** rdesktop.c	12 Apr 2006 06:47:24 -0000	1.149
--- rdesktop.c	17 Sep 2006 11:04:49 -0000	1.150
***************
*** 180,185 ****
  	fprintf(stderr,
  		"             or      mydeskjet=\"HP LaserJet IIIP\" to enter server driver as well\n");
! 	fprintf(stderr, "         '-r sound:[local|off|remote]': enable sound redirection\n");
  	fprintf(stderr, "                     remote would leave sound on server\n");
  	fprintf(stderr,
  		"         '-r clipboard:[off|PRIMARYCLIPBOARD|CLIPBOARD]': enable clipboard\n");
--- 180,190 ----
  	fprintf(stderr,
  		"             or      mydeskjet=\"HP LaserJet IIIP\" to enter server driver as well\n");
! #ifdef WITH_RDPSND
! 	fprintf(stderr,
! 		"         '-r sound:[local[:driver[:device]]|off|remote]': enable sound redirection\n");
  	fprintf(stderr, "                     remote would leave sound on server\n");
+ 	fprintf(stderr, "                     available drivers for 'local':\n");
+ 	rdpsnd_show_help();
+ #endif
  	fprintf(stderr,
  		"         '-r clipboard:[off|PRIMARYCLIPBOARD|CLIPBOARD]': enable clipboard\n");
***************
*** 664,668 ****
--- 669,702 ----
  							if (str_startswith(optarg, "local"))
  #ifdef WITH_RDPSND
+ 							{
+ 								char *driver = NULL, *options =
+ 									NULL;
+ 
+ 								if ((driver =
+ 								     next_arg(optarg, ':')))
+ 								{
+ 									if (!strlen(driver))
+ 									{
+ 										driver = NULL;
+ 									}
+ 									else if ((options =
+ 										  next_arg(driver,
+ 											   ':')))
+ 									{
+ 										if (!strlen
+ 										    (options))
+ 											options =
+ 												NULL;
+ 									}
+ 								}
+ 
  								g_rdpsnd = True;
+ 								if (!rdpsnd_select_driver
+ 								    (driver, options))
+ 								{
+ 									warning("Driver not available\n");
+ 								}
+ 							}
+ 
  #else
  								warning("Not compiled with sound support\n");
***************
*** 683,686 ****
--- 717,724 ----
  #ifdef WITH_RDPSND
  						g_rdpsnd = True;
+ 						if (!rdpsnd_select_driver(NULL, NULL))
+ 						{
+ 							warning("No sound-driver available\n");
+ 						}
  #else
  						warning("Not compiled with sound support\n");

Index: rdpsnd.c
===================================================================
RCS file: /cvsroot/rdesktop/rdesktop/rdpsnd.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** rdpsnd.c	17 Sep 2006 10:32:18 -0000	1.11
--- rdpsnd.c	17 Sep 2006 11:04:49 -0000	1.12
***************
*** 38,41 ****
--- 38,43 ----
  
  static VCHANNEL *rdpsnd_channel;
+ static struct audio_driver *drivers = NULL;
+ static struct audio_driver *current_driver = NULL;
  
  static BOOL device_open;
***************
*** 46,49 ****
--- 48,53 ----
  static struct audio_packet packet_queue[MAX_QUEUE];
  
+ void (*wave_out_play) (void);
+ 
  static STREAM
  rdpsnd_init_packet(uint16 type, uint16 size)
***************
*** 95,101 ****
  	in_uint8s(in, 4);	/* pad, status, pad */
  
! 	if (wave_out_open())
  	{
! 		wave_out_close();
  		device_available = True;
  	}
--- 99,105 ----
  	in_uint8s(in, 4);	/* pad, status, pad */
  
! 	if (current_driver->wave_out_open())
  	{
! 		current_driver->wave_out_close();
  		device_available = True;
  	}
***************
*** 128,132 ****
  			in_uint8s(in, discardcnt);
  
! 			if (device_available && wave_out_format_supported(format))
  			{
  				format_count++;
--- 132,136 ----
  			in_uint8s(in, discardcnt);
  
! 			if (device_available && current_driver->wave_out_format_supported(format))
  			{
  				format_count++;
***************
*** 206,218 ****
  		if (!device_open || (format != current_format))
  		{
! 			if (!device_open && !wave_out_open())
  			{
  				rdpsnd_send_completion(tick, packet_index);
  				return;
  			}
! 			if (!wave_out_set_format(&formats[format]))
  			{
  				rdpsnd_send_completion(tick, packet_index);
! 				wave_out_close();
  				device_open = False;
  				return;
--- 210,222 ----
  		if (!device_open || (format != current_format))
  		{
! 			if (!device_open && !current_driver->wave_out_open())
  			{
  				rdpsnd_send_completion(tick, packet_index);
  				return;
  			}
! 			if (!current_driver->wave_out_set_format(&formats[format]))
  			{
  				rdpsnd_send_completion(tick, packet_index);
! 				current_driver->wave_out_close();
  				device_open = False;
  				return;
***************
*** 222,226 ****
  		}
  
! 		rdpsnd_queue_write(s, tick, packet_index);
  		awaiting_data_packet = False;
  		return;
--- 226,230 ----
  		}
  
! 		current_driver->wave_out_write(s, tick, packet_index);
  		awaiting_data_packet = False;
  		return;
***************
*** 240,244 ****
  			break;
  		case RDPSND_CLOSE:
! 			wave_out_close();
  			device_open = False;
  			break;
--- 244,248 ----
  			break;
  		case RDPSND_CLOSE:
! 			current_driver->wave_out_close();
  			device_open = False;
  			break;
***************
*** 253,257 ****
  			if (device_open)
  			{
! 				wave_out_volume((volume & 0xffff), (volume & 0xffff0000) >> 16);
  			}
  			break;
--- 257,262 ----
  			if (device_open)
  			{
! 				current_driver->wave_out_volume((volume & 0xffff),
! 								(volume & 0xffff0000) >> 16);
  			}
  			break;
***************
*** 272,275 ****
--- 277,382 ----
  }
  
+ BOOL
+ rdpsnd_auto_open(void)
+ {
+ 	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");
+ 
+ 	return False;
+ }
+ 
+ void
+ rdpsnd_register_drivers(char *options)
+ {
+ 	struct audio_driver **reg;
+ 
+ 	/* The order of registrations define the probe-order
+ 	   when opening the device for the first time */
+ 	reg = &drivers;
+ #if defined(RDPSND_ALSA)
+ 	*reg = alsa_register(options);
+ 	reg = &((*reg)->next);
+ #endif
+ #if defined(RDPSND_OSS)
+ 	*reg = oss_register(options);
+ 	reg = &((*reg)->next);
+ #endif
+ #if defined(RDPSND_SUN)
+ 	*reg = sun_register(options);
+ 	reg = &((*reg)->next);
+ #endif
+ #if defined(RDPSND_SGI)
+ 	*reg = sgi_register(options);
+ 	reg = &((*reg)->next);
+ #endif
+ #if defined(RDPSND_LIBAO)
+ 	*reg = libao_register(options);
+ 	reg = &((*reg)->next);
+ #endif
+ }
+ 
+ BOOL
+ rdpsnd_select_driver(char *driver, char *options)
+ {
+ 	static struct audio_driver auto_driver;
+ 	struct audio_driver *pos;
+ 
+ 	drivers = NULL;
+ 	rdpsnd_register_drivers(options);
+ 
+ 	if (!driver)
+ 	{
+ 		auto_driver.wave_out_open = &rdpsnd_auto_open;
+ 		current_driver = &auto_driver;
+ 		return True;
+ 	}
+ 
+ 	pos = drivers;
+ 	while (pos != NULL)
+ 	{
+ 		if (!strcmp(pos->name, driver))
+ 		{
+ 			DEBUG(("selected %s\n", pos->name));
+ 			current_driver = pos;
+ 			return True;
+ 		}
+ 		pos = pos->next;
+ 	}
+ 	return False;
+ }
+ 
+ void
+ rdpsnd_show_help(void)
+ {
+ 	struct audio_driver *pos;
+ 
+ 	rdpsnd_register_drivers(NULL);
+ 
+ 	pos = drivers;
+ 	while (pos != NULL)
+ 	{
+ 		fprintf(stderr, "                     %s:\t%s\n", pos->name, pos->description);
+ 		pos = pos->next;
+ 	}
+ }
+ 
+ inline void
+ rdpsnd_play(void)
+ {
+ 	current_driver->wave_out_play();
+ }
+ 
  void
  rdpsnd_queue_write(STREAM s, uint16 tick, uint8 index)
***************
*** 295,299 ****
  
  	if (!g_dsp_busy)
! 		wave_out_play();
  }
  
--- 402,406 ----
  
  	if (!g_dsp_busy)
! 		current_driver->wave_out_play();
  }
  

Index: rdpsnd.h
===================================================================
RCS file: /cvsroot/rdesktop/rdesktop/rdpsnd.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** rdpsnd.h	17 Sep 2006 10:32:18 -0000	1.1
--- rdpsnd.h	17 Sep 2006 11:04:49 -0000	1.2
***************
*** 26,29 ****
--- 26,43 ----
  };
  
+ struct audio_driver
+ {
+ 	void (*wave_out_write) (STREAM s, uint16 tick, uint8 index);
+ 	  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;
+ 	struct audio_driver *next;
+ };
+ 
  extern BOOL g_dsp_busy;
  extern int g_dsp_fd;
***************
*** 35,36 ****
--- 49,57 ----
  inline void rdpsnd_queue_next(void);
  inline int rdpsnd_queue_next_tick(void);
+ 
+ /* Driver register functions */
+ struct audio_driver *alsa_register(char *options);
+ struct audio_driver *libao_register(char *options);
+ struct audio_driver *oss_register(char *options);
+ struct audio_driver *sgi_register(char *options);
+ struct audio_driver *sun_register(char *options);

Index: rdpsnd_alsa.c
===================================================================
RCS file: /cvsroot/rdesktop/rdesktop/rdpsnd_alsa.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** rdpsnd_alsa.c	17 Sep 2006 10:32:18 -0000	1.2
--- rdpsnd_alsa.c	17 Sep 2006 11:04:50 -0000	1.3
***************
*** 37,49 ****
  static short samplewidth;
  static int audiochannels;
  
  BOOL
! wave_out_open(void)
  {
- 	char *pcm_name;
  	int err;
  
- 	pcm_name = xstrdup(DEFAULTDEVICE);
- 
  	if ((err = snd_pcm_open(&pcm_handle, pcm_name, stream, 0)) < 0)
  	{
--- 37,47 ----
  static short samplewidth;
  static int audiochannels;
+ static char *pcm_name;
  
  BOOL
! alsa_open(void)
  {
  	int err;
  
  	if ((err = snd_pcm_open(&pcm_handle, pcm_name, stream, 0)) < 0)
  	{
***************
*** 61,65 ****
  
  void
! wave_out_close(void)
  {
  	/* Ack all remaining packets */
--- 59,63 ----
  
  void
! alsa_close(void)
  {
  	/* Ack all remaining packets */
***************
*** 71,75 ****
  	}
  
- 
  	if (pcm_handle)
  	{
--- 69,72 ----
***************
*** 80,84 ****
  
  BOOL
! wave_out_format_supported(WAVEFORMATEX * pwfx)
  {
  #if 0
--- 77,81 ----
  
  BOOL
! alsa_format_supported(WAVEFORMATEX * pwfx)
  {
  #if 0
***************
*** 113,117 ****
  
  BOOL
! wave_out_set_format(WAVEFORMATEX * pwfx)
  {
  	snd_pcm_hw_params_t *hwparams = NULL;
--- 110,114 ----
  
  BOOL
! alsa_set_format(WAVEFORMATEX * pwfx)
  {
  	snd_pcm_hw_params_t *hwparams = NULL;
***************
*** 211,215 ****
  
  void
! wave_out_volume(uint16 left, uint16 right)
  {
  	static int warned = 0;
--- 208,212 ----
  
  void
! alsa_volume(uint16 left, uint16 right)
  {
  	static int warned = 0;
***************
*** 217,221 ****
  	if (!warned)
  	{
! 		warning("volume changes currently not supported with experimental alsa-output\n");
  		warned = 1;
  	}
--- 214,218 ----
  	if (!warned)
  	{
! 		warning("volume changes currently not supported with alsa-output\n");
  		warned = 1;
  	}
***************
*** 223,227 ****
  
  void
! wave_out_play(void)
  {
  	struct audio_packet *packet;
--- 220,224 ----
  
  void
! alsa_play(void)
  {
  	struct audio_packet *packet;
***************
*** 286,287 ****
--- 283,312 ----
  	return;
  }
+ 
+ static struct audio_driver alsa_driver = {
+       wave_out_write:rdpsnd_queue_write,
+       wave_out_open:alsa_open,
+       wave_out_close:alsa_close,
+       wave_out_format_supported:alsa_format_supported,
+       wave_out_set_format:alsa_set_format,
+       wave_out_volume:alsa_volume,
+       wave_out_play:alsa_play,
+       name:"alsa",
+       description:"ALSA output driver, default device: " DEFAULTDEVICE,
+       next:NULL,
+ };
+ 
+ struct audio_driver *
+ alsa_register(char *options)
+ {
+ 	if (options)
+ 	{
+ 		pcm_name = xstrdup(options);
+ 	}
+ 	else
+ 	{
+ 		pcm_name = xstrdup(DEFAULTDEVICE);
+ 	}
+ 
+ 	return &alsa_driver;
+ }

Index: rdpsnd_libao.c
===================================================================
RCS file: /cvsroot/rdesktop/rdesktop/rdpsnd_libao.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** rdpsnd_libao.c	17 Sep 2006 10:32:18 -0000	1.15
--- rdpsnd_libao.c	17 Sep 2006 11:04:50 -0000	1.16
***************
*** 37,45 ****
  static BOOL reopened;
  static short samplewidth;
  
  BOOL
! wave_out_open(void)
  {
  	ao_sample_format format;
  
  	ao_initialize();
--- 37,53 ----
  static BOOL reopened;
  static short samplewidth;
+ static char *libao_device = NULL;
  
  BOOL
! libao_open(void)
  {
  	ao_sample_format format;
+ 	static int warned = 0;
+ 
+ 	if (!warned && libao_device)
+ 	{
+ 		warning("device-options not supported for libao-driver\n");
+ 		warned = 1;
+ 	}
  
  	ao_initialize();
***************
*** 68,72 ****
  
  void
! wave_out_close(void)
  {
  	/* Ack all remaining packets */
--- 76,80 ----
  
  void
! libao_close(void)
  {
  	/* Ack all remaining packets */
***************
*** 85,89 ****
  
  BOOL
! wave_out_format_supported(WAVEFORMATEX * pwfx)
  {
  	if (pwfx->wFormatTag != WAVE_FORMAT_PCM)
--- 93,97 ----
  
  BOOL
! libao_format_supported(WAVEFORMATEX * pwfx)
  {
  	if (pwfx->wFormatTag != WAVE_FORMAT_PCM)
***************
*** 102,106 ****
  
  BOOL
! wave_out_set_format(WAVEFORMATEX * pwfx)
  {
  	ao_sample_format format;
--- 110,114 ----
  
  BOOL
! libao_set_format(WAVEFORMATEX * pwfx)
  {
  	ao_sample_format format;
***************
*** 130,134 ****
  
  void
! wave_out_volume(uint16 left, uint16 right)
  {
  	warning("volume changes not supported with libao-output\n");
--- 138,142 ----
  
  void
! libao_volume(uint16 left, uint16 right)
  {
  	warning("volume changes not supported with libao-output\n");
***************
*** 136,140 ****
  
  void
! wave_out_play(void)
  {
  	struct audio_packet *packet;
--- 144,148 ----
  
  void
! libao_play(void)
  {
  	struct audio_packet *packet;
***************
*** 226,227 ****
--- 234,259 ----
  	return;
  }
+ 
+ static struct audio_driver libao_driver = {
+       wave_out_write:rdpsnd_queue_write,
+       wave_out_open:libao_open,
+       wave_out_close:libao_close,
+       wave_out_format_supported:libao_format_supported,
+       wave_out_set_format:libao_set_format,
+       wave_out_volume:libao_volume,
+       wave_out_play:libao_play,
+       name:"libao",
+       description:"libao output driver",
+       next:NULL,
+ };
+ 
+ struct audio_driver *
+ libao_register(char *options)
+ {
+ 	if (options)
+ 	{
+ 		libao_device = xstrdup(options);
+ 	}
+ 
+ 	return &libao_driver;
+ }

Index: rdpsnd_oss.c
===================================================================
RCS file: /cvsroot/rdesktop/rdesktop/rdpsnd_oss.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -C2 -d -r1.21 -r1.22
*** rdpsnd_oss.c	17 Sep 2006 10:32:18 -0000	1.21
--- rdpsnd_oss.c	17 Sep 2006 11:04:50 -0000	1.22
***************
*** 42,56 ****
  static int snd_rate;
  static short samplewidth;
  
  BOOL
! wave_out_open(void)
  {
- 	char *dsp_dev = getenv("AUDIODEV");
- 
- 	if (dsp_dev == NULL)
- 	{
- 		dsp_dev = xstrdup(DEFAULTDEVICE);
- 	}
- 
  	if ((g_dsp_fd = open(dsp_dev, O_WRONLY)) == -1)
  	{
--- 42,50 ----
  static int snd_rate;
  static short samplewidth;
+ static char *dsp_dev;
  
  BOOL
! oss_open(void)
  {
  	if ((g_dsp_fd = open(dsp_dev, O_WRONLY)) == -1)
  	{
***************
*** 63,67 ****
  
  void
! wave_out_close(void)
  {
  	close(g_dsp_fd);
--- 57,61 ----
  
  void
! oss_close(void)
  {
  	close(g_dsp_fd);
***************
*** 69,73 ****
  
  BOOL
! wave_out_format_supported(WAVEFORMATEX * pwfx)
  {
  	if (pwfx->wFormatTag != WAVE_FORMAT_PCM)
--- 63,67 ----
  
  BOOL
! oss_format_supported(WAVEFORMATEX * pwfx)
  {
  	if (pwfx->wFormatTag != WAVE_FORMAT_PCM)
***************
*** 82,86 ****
  
  BOOL
! wave_out_set_format(WAVEFORMATEX * pwfx)
  {
  	int stereo, format, fragments;
--- 76,80 ----
  
  BOOL
! oss_set_format(WAVEFORMATEX * pwfx)
  {
  	int stereo, format, fragments;
***************
*** 158,162 ****
  
  void
! wave_out_volume(uint16 left, uint16 right)
  {
  	static BOOL use_dev_mixer = False;
--- 152,156 ----
  
  void
! oss_volume(uint16 left, uint16 right)
  {
  	static BOOL use_dev_mixer = False;
***************
*** 193,197 ****
  
  void
! wave_out_play(void)
  {
  	struct audio_packet *packet;
--- 187,191 ----
  
  void
! oss_play(void)
  {
  	struct audio_packet *packet;
***************
*** 258,259 ****
--- 252,286 ----
  	return;
  }
+ 
+ static struct audio_driver oss_driver = {
+       wave_out_write:rdpsnd_queue_write,
+       wave_out_open:oss_open,
+       wave_out_close:oss_close,
+       wave_out_format_supported:oss_format_supported,
+       wave_out_set_format:oss_set_format,
+       wave_out_volume:oss_volume,
+       wave_out_play:oss_play,
+       name:"oss",
+       description:"OSS output driver, default device: " DEFAULTDEVICE " or $AUDIODEV",
+       next:NULL,
+ };
+ 
+ struct audio_driver *
+ oss_register(char *options)
+ {
+ 	if (options)
+ 	{
+ 		dsp_dev = xstrdup(options);
+ 	}
+ 	else
+ 	{
+ 		dsp_dev = getenv("AUDIODEV");
+ 
+ 		if (dsp_dev == NULL)
+ 		{
+ 			dsp_dev = xstrdup(DEFAULTDEVICE);
+ 		}
+ 	}
+ 
+ 	return &oss_driver;
+ }

Index: rdpsnd_sgi.c
===================================================================
RCS file: /cvsroot/rdesktop/rdesktop/rdpsnd_sgi.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** rdpsnd_sgi.c	17 Sep 2006 10:32:18 -0000	1.10
--- rdpsnd_sgi.c	17 Sep 2006 11:04:50 -0000	1.11
***************
*** 36,39 ****
--- 36,40 ----
  static BOOL g_swapaudio;
  static int width = AL_SAMPLE_16;
+ static char *sgi_output_device = NULL;
  
  double min_volume, max_volume, volume_range;
***************
*** 42,48 ****
  
  BOOL
! wave_out_open(void)
  {
  	ALparamInfo pinfo;
  
  #if (defined(IRIX_DEBUG))
--- 43,50 ----
  
  BOOL
! sgi_open(void)
  {
  	ALparamInfo pinfo;
+ 	static int warned = 0;
  
  #if (defined(IRIX_DEBUG))
***************
*** 50,53 ****
--- 52,61 ----
  #endif
  
+ 	if (!warned && sgi_output_device)
+ 	{
+ 		warning("device-options not supported for libao-driver\n");
+ 		warned = 1;
+ 	}
+ 
  	if (alGetParamInfo(AL_DEFAULT_OUTPUT, AL_GAIN, &pinfo) < 0)
  	{
***************
*** 86,90 ****
  
  void
! wave_out_close(void)
  {
  	/* Ack all remaining packets */
--- 94,98 ----
  
  void
! sgi_close(void)
  {
  	/* Ack all remaining packets */
***************
*** 111,115 ****
  
  BOOL
! wave_out_format_supported(WAVEFORMATEX * pwfx)
  {
  	if (pwfx->wFormatTag != WAVE_FORMAT_PCM)
--- 119,123 ----
  
  BOOL
! sgi_format_supported(WAVEFORMATEX * pwfx)
  {
  	if (pwfx->wFormatTag != WAVE_FORMAT_PCM)
***************
*** 124,128 ****
  
  BOOL
! wave_out_set_format(WAVEFORMATEX * pwfx)
  {
  	int channels;
--- 132,136 ----
  
  BOOL
! sgi_set_format(WAVEFORMATEX * pwfx)
  {
  	int channels;
***************
*** 208,212 ****
  
  void
! wave_out_volume(uint16 left, uint16 right)
  {
  	double gainleft, gainright;
--- 216,220 ----
  
  void
! sgi_volume(uint16 left, uint16 right)
  {
  	double gainleft, gainright;
***************
*** 241,245 ****
  
  void
! wave_out_play(void)
  {
  	struct audio_packet *packet;
--- 249,253 ----
  
  void
! sgi_play(void)
  {
  	struct audio_packet *packet;
***************
*** 300,301 ****
--- 308,332 ----
  	}
  }
+ 
+ static struct audio_driver sgi_driver = {
+       wave_out_write:rdpsnd_queue_write,
+       wave_out_open:sgi_open,
+       wave_out_close:sgi_close,
+       wave_out_format_supported:sgi_format_supported,
+       wave_out_set_format:sgi_set_format,
+       wave_out_volume:sgi_volume,
+       wave_out_play:sgi_play,
+       name:"sgi",
+       description:"SGI output driver",
+       next:NULL,
+ };
+ 
+ struct audio_driver *
+ sgi_register(char *options)
+ {
+ 	if (options)
+ 	{
+ 		sgi_output_device = xstrdup(options);
+ 	}
+ 	return &sgi_driver;
+ }

Index: rdpsnd_sun.c
===================================================================
RCS file: /cvsroot/rdesktop/rdesktop/rdpsnd_sun.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** rdpsnd_sun.c	17 Sep 2006 10:32:18 -0000	1.17
--- rdpsnd_sun.c	17 Sep 2006 11:04:50 -0000	1.18
***************
*** 38,52 ****
  static BOOL g_swapaudio;
  static short g_samplewidth;
  
  BOOL
! wave_out_open(void)
  {
- 	char *dsp_dev = getenv("AUDIODEV");
- 
- 	if (dsp_dev == NULL)
- 	{
- 		dsp_dev = xstrdup(DEFAULTDEVICE);
- 	}
- 
  	if ((g_dsp_fd = open(dsp_dev, O_WRONLY | O_NONBLOCK)) == -1)
  	{
--- 38,46 ----
  static BOOL g_swapaudio;
  static short g_samplewidth;
+ static char *dsp_dev;
  
  BOOL
! sun_open(void)
  {
  	if ((g_dsp_fd = open(dsp_dev, O_WRONLY | O_NONBLOCK)) == -1)
  	{
***************
*** 65,69 ****
  
  void
! wave_out_close(void)
  {
  	/* Ack all remaining packets */
--- 59,63 ----
  
  void
! sun_close(void)
  {
  	/* Ack all remaining packets */
***************
*** 86,90 ****
  
  BOOL
! wave_out_format_supported(WAVEFORMATEX * pwfx)
  {
  	if (pwfx->wFormatTag != WAVE_FORMAT_PCM)
--- 80,84 ----
  
  BOOL
! sun_format_supported(WAVEFORMATEX * pwfx)
  {
  	if (pwfx->wFormatTag != WAVE_FORMAT_PCM)
***************
*** 99,103 ****
  
  BOOL
! wave_out_set_format(WAVEFORMATEX * pwfx)
  {
  	audio_info_t info;
--- 93,97 ----
  
  BOOL
! sun_set_format(WAVEFORMATEX * pwfx)
  {
  	audio_info_t info;
***************
*** 153,157 ****
  
  void
! wave_out_volume(uint16 left, uint16 right)
  {
  	audio_info_t info;
--- 147,151 ----
  
  void
! sun_volume(uint16 left, uint16 right)
  {
  	audio_info_t info;
***************
*** 185,189 ****
  
  void
! wave_out_play(void)
  {
  	struct audio_packet *packet;
--- 179,183 ----
  
  void
! sun_play(void)
  {
  	struct audio_packet *packet;
***************
*** 278,279 ****
--- 272,306 ----
  	}
  }
+ 
+ static struct audio_driver sun_driver = {
+       wave_out_write:rdpsnd_queue_write,
+       wave_out_open:sun_open,
+       wave_out_close:sun_close,
+       wave_out_format_supported:sun_format_supported,
+       wave_out_set_format:sun_set_format,
+       wave_out_volume:sun_volume,
+       wave_out_play:sun_play,
+       name:"sun",
+       description:"SUN/BSD output driver, default device: " DEFAULTDEVICE " or $AUDIODEV",
+       next:NULL,
+ };
+ 
+ struct audio_driver *
+ sun_register(char *options)
+ {
+ 	if (options)
+ 	{
+ 		dsp_dev = xstrdup(options);
+ 	}
+ 	else
+ 	{
+ 		dsp_dev = getenv("AUDIODEV");
+ 
+ 		if (dsp_dev == NULL)
+ 		{
+ 			dsp_dev = xstrdup(DEFAULTDEVICE);
+ 		}
+ 	}
+ 
+ 	return &sun_driver;
+ }

Index: xwin.c
===================================================================
RCS file: /cvsroot/rdesktop/rdesktop/xwin.c,v
retrieving revision 1.213
retrieving revision 1.214
diff -C2 -d -r1.213 -r1.214
*** xwin.c	7 Aug 2006 11:46:28 -0000	1.213
--- xwin.c	17 Sep 2006 11:04:50 -0000	1.214
***************
*** 2306,2310 ****
  #ifdef WITH_RDPSND
  		if (g_dsp_busy && FD_ISSET(g_dsp_fd, &wfds))
! 			wave_out_play();
  #endif
  	}
--- 2306,2310 ----
  #ifdef WITH_RDPSND
  		if (g_dsp_busy && FD_ISSET(g_dsp_fd, &wfds))
! 			rdpsnd_play();
  #endif
  	}


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642