From 139e42d9efdf1eed194a569aa9f7f661f828efff Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Thu, 7 Dec 2006 11:54:29 +0000 Subject: [PATCH] Restructure driver registration structures a bit so it is easier to add new fields (and also reduce some memory usage/leaks). git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/trunk/rdesktop@1344 423420c4-83ab-492f-b58f-81f9feb106b5 --- rdpsnd_alsa.c | 29 +++++++++++++++-------------- rdpsnd_libao.c | 29 +++++++++++++++-------------- rdpsnd_oss.c | 32 ++++++++++++++++++-------------- rdpsnd_sgi.c | 29 +++++++++++++++-------------- rdpsnd_sun.c | 30 +++++++++++++++--------------- 5 files changed, 78 insertions(+), 71 deletions(-) diff --git a/rdpsnd_alsa.c b/rdpsnd_alsa.c index 3a2c137..8671566 100644 --- a/rdpsnd_alsa.c +++ b/rdpsnd_alsa.c @@ -276,23 +276,24 @@ alsa_play(void) return; } +static struct audio_driver alsa_driver = { + .name = "alsa", + .description = "ALSA output driver, default device: " DEFAULTDEVICE, + + .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 = rdpsnd_dsp_softvol_set, + .wave_out_play = alsa_play, + + .need_byteswap_on_be = 0, + .need_resampling = 0, +}; + struct audio_driver * alsa_register(char *options) { - static struct audio_driver alsa_driver; - - alsa_driver.wave_out_open = alsa_open; - alsa_driver.wave_out_close = alsa_close; - alsa_driver.wave_out_format_supported = alsa_format_supported; - alsa_driver.wave_out_set_format = alsa_set_format; - alsa_driver.wave_out_volume = rdpsnd_dsp_softvol_set; - alsa_driver.wave_out_play = alsa_play; - alsa_driver.name = xstrdup("alsa"); - alsa_driver.description = xstrdup("ALSA output driver, default device: " DEFAULTDEVICE); - alsa_driver.need_byteswap_on_be = 0; - alsa_driver.need_resampling = 0; - alsa_driver.next = NULL; - if (options) { pcm_name = xstrdup(options); diff --git a/rdpsnd_libao.c b/rdpsnd_libao.c index 8832915..e9929d9 100644 --- a/rdpsnd_libao.c +++ b/rdpsnd_libao.c @@ -175,23 +175,24 @@ libao_play(void) return; } +static struct audio_driver libao_driver = { + .name = "libao", + .description = "libao output driver, default device: system dependent", + + .wave_out_open = libao_open, + .wave_out_close = libao_close, + .wave_out_format_supported = rdpsnd_dsp_resample_supported, + .wave_out_set_format = libao_set_format, + .wave_out_volume = rdpsnd_dsp_softvol_set, + .wave_out_play = libao_play, + + .need_byteswap_on_be = 1, + .need_resampling = 1, +}; + struct audio_driver * libao_register(char *options) { - static struct audio_driver libao_driver; - - libao_driver.wave_out_open = libao_open; - libao_driver.wave_out_close = libao_close; - libao_driver.wave_out_format_supported = rdpsnd_dsp_resample_supported; - libao_driver.wave_out_set_format = libao_set_format; - libao_driver.wave_out_volume = rdpsnd_dsp_softvol_set; - libao_driver.wave_out_play = libao_play; - libao_driver.name = xstrdup("libao"); - libao_driver.description = xstrdup("libao output driver, default device: system dependent"); - libao_driver.need_byteswap_on_be = 1; - libao_driver.need_resampling = 1; - libao_driver.next = NULL; - if (options) { libao_device = xstrdup(options); diff --git a/rdpsnd_oss.c b/rdpsnd_oss.c index 0e08d51..e3c0178 100644 --- a/rdpsnd_oss.c +++ b/rdpsnd_oss.c @@ -46,9 +46,11 @@ static int snd_rate; static short samplewidth; static char *dsp_dev; -static struct audio_driver oss_driver; static BOOL in_esddsp; +/* This is a just a forward declaration */ +static struct audio_driver oss_driver; + static BOOL detect_esddsp(void) { @@ -296,22 +298,24 @@ oss_play(void) return; } +static struct audio_driver oss_driver = { + .name = "oss", + .description = "OSS output driver, default device: " DEFAULTDEVICE " or $AUDIODEV", + + .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, + + .need_byteswap_on_be = 0, + .need_resampling = 0, +}; + struct audio_driver * oss_register(char *options) { - oss_driver.wave_out_open = oss_open; - oss_driver.wave_out_close = oss_close; - oss_driver.wave_out_format_supported = oss_format_supported; - oss_driver.wave_out_set_format = oss_set_format; - oss_driver.wave_out_volume = oss_volume; - oss_driver.wave_out_play = oss_play; - oss_driver.name = xstrdup("oss"); - oss_driver.description = - xstrdup("OSS output driver, default device: " DEFAULTDEVICE " or $AUDIODEV"); - oss_driver.need_byteswap_on_be = 0; - oss_driver.need_resampling = 0; - oss_driver.next = NULL; - if (options) { dsp_dev = xstrdup(options); diff --git a/rdpsnd_sgi.c b/rdpsnd_sgi.c index bb56582..c8d9ebe 100644 --- a/rdpsnd_sgi.c +++ b/rdpsnd_sgi.c @@ -273,23 +273,24 @@ sgi_play(void) } } +static struct audio_driver sgi_driver = { + .name = "sgi", + .description = "SGI output driver", + + .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, + + .need_byteswap_on_be = 1, + .need_resampling = 0, +}; + struct audio_driver * sgi_register(char *options) { - static struct audio_driver sgi_driver; - - sgi_driver.wave_out_open = sgi_open; - sgi_driver.wave_out_close = sgi_close; - sgi_driver.wave_out_format_supported = sgi_format_supported; - sgi_driver.wave_out_set_format = sgi_set_format; - sgi_driver.wave_out_volume = sgi_volume; - sgi_driver.wave_out_play = sgi_play; - sgi_driver.name = xstrdup("sgi"); - sgi_driver.description = xstrdup("SGI output driver"); - sgi_driver.need_byteswap_on_be = 1; - sgi_driver.need_resampling = 0; - sgi_driver.next = NULL; - if (options) { sgi_output_device = xstrdup(options); diff --git a/rdpsnd_sun.c b/rdpsnd_sun.c index 3bf2c9b..af4c47a 100644 --- a/rdpsnd_sun.c +++ b/rdpsnd_sun.c @@ -242,24 +242,24 @@ sun_play(void) } } +static struct audio_driver sun_driver = { + .name = "sun", + .description = "SUN/BSD output driver, default device: " DEFAULTDEVICE " or $AUDIODEV", + + .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, + + .need_byteswap_on_be = 1, + .need_resampling = 0, +}; + struct audio_driver * sun_register(char *options) { - static struct audio_driver sun_driver; - - sun_driver.wave_out_open = sun_open; - sun_driver.wave_out_close = sun_close; - sun_driver.wave_out_format_supported = sun_format_supported; - sun_driver.wave_out_set_format = sun_set_format; - sun_driver.wave_out_volume = sun_volume; - sun_driver.wave_out_play = sun_play; - sun_driver.name = xstrdup("sun"); - sun_driver.description = - xstrdup("SUN/BSD output driver, default device: " DEFAULTDEVICE " or $AUDIODEV"); - sun_driver.need_byteswap_on_be = 1; - sun_driver.need_resampling = 0; - sun_driver.next = NULL; - if (options) { dsp_dev = xstrdup(options);