From c387884667c19cee54f813e1850c7516c84d1ace Mon Sep 17 00:00:00 2001 From: Jack Moffitt <jack@xiph.org> Date: Mon, 30 Oct 2000 04:38:49 +0000 Subject: [PATCH] now this actually works :) git-svn-id: http://svn.xiph.org/trunk/ao@778 0101bb08-14d6-0310-b084-bc0e0c8e3800 --- src/audio_out.c | 8 ++--- src/plugins/alsa/ao_alsa.c | 53 ++++++++------------------------ src/plugins/esd/ao_esd.c | 39 ++++++----------------- src/plugins/irix/ao_irix.c | 48 +++++++++-------------------- src/plugins/oss/ao_oss.c | 31 +++++-------------- src/plugins/solaris/ao_solaris.c | 35 ++++++--------------- 6 files changed, 57 insertions(+), 157 deletions(-) diff --git a/src/audio_out.c b/src/audio_out.c index 93395e6..3f37ae1 100644 --- a/src/audio_out.c +++ b/src/audio_out.c @@ -76,13 +76,13 @@ driver_tree_t *_get_plugin(char *plugin_file) return NULL; } - dt->functions->get_driver_info = dlsym(dt->handle, "get_driver_info"); + dt->functions->get_driver_info = dlsym(dt->handle, "plugin_get_driver_info"); if (dlerror()) { free(dt->functions); free(dt); return NULL; } - dt->functions->open = dlsym(dt->handle, "open"); + dt->functions->open = dlsym(dt->handle, "plugin_open"); if (dlerror()) { free(dt->functions); free(dt); return NULL; } - dt->functions->play = dlsym(dt->handle, "play"); + dt->functions->play = dlsym(dt->handle, "plugin_play"); if (dlerror()) { free(dt->functions); free(dt); return NULL; } - dt->functions->close = dlsym(dt->handle, "close"); + dt->functions->close = dlsym(dt->handle, "plugin_close"); if (dlerror()) { free(dt->functions); free(dt); return NULL; } } else { return NULL; diff --git a/src/plugins/alsa/ao_alsa.c b/src/plugins/alsa/ao_alsa.c index 4c595ca..99fa18c 100644 --- a/src/plugins/alsa/ao_alsa.c +++ b/src/plugins/alsa/ao_alsa.c @@ -45,23 +45,21 @@ typedef struct ao_alsa_internal_s int dev; } ao_alsa_internal_t; -static ao_info_t ao_alsa_info = +ao_info_t ao_alsa_info = { "Advanced Linux Sound Architecture (ALSA) output", "alsa", "Stan Seibert <volsung@asu.edu>", - "" + "Otuputs to the Advanced Linux Sound Architecture." }; -static void -ao_alsa_parse_options(ao_alsa_internal_t *state, ao_option_t *options) +void ao_alsa_parse_options(ao_alsa_internal_t *state, ao_option_t *options) { state->card = 0; state->dev = 0; state->buf_size = AO_ALSA_BUF_SIZE; - while (options) - { + while (options) { if (!strcmp(options->key, "card")) state->card = atoi(options->value); else if (!strcmp(options->key, "dev")) @@ -73,8 +71,7 @@ ao_alsa_parse_options(ao_alsa_internal_t *state, ao_option_t *options) } } -static ao_internal_t* -ao_alsa_open (uint_32 bits, uint_32 rate, uint_32 channels, ao_option_t *options) +ao_internal_t *plugin_open(uint_32 bits, uint_32 rate, uint_32 channels, ao_option_t *options) { ao_alsa_internal_t *state; snd_pcm_channel_params_t param; @@ -87,8 +84,7 @@ ao_alsa_open (uint_32 bits, uint_32 rate, uint_32 channels, ao_option_t *options param.format.interleave = 1; - switch (bits) - { + switch (bits) { case 8 : param.format.format = SND_PCM_SFMT_S8; break; case 16 : param.format.format = ao_is_big_endian() ? @@ -126,16 +122,14 @@ ao_alsa_open (uint_32 bits, uint_32 rate, uint_32 channels, ao_option_t *options state->card, state->dev, SND_PCM_OPEN_PLAYBACK | SND_PCM_OPEN_NONBLOCK); - if ( err < 0 ) - { + if (err < 0) { free(state); return NULL; } err = snd_pcm_channel_params(state->pcm_handle, ¶m); - if (err < 0 ) - { + if (err < 0) { snd_pcm_close(state->pcm_handle); free(state); return NULL; @@ -150,16 +144,14 @@ ao_alsa_open (uint_32 bits, uint_32 rate, uint_32 channels, ao_option_t *options return state; } -static void -ao_alsa_close (ao_internal_t *state) +void plugin_close(ao_internal_t *state) { ao_alsa_internal_t *s = (ao_alsa_internal_t *) state; snd_pcm_close(s->pcm_handle); free(s); } -static void -ao_alsa_write_buffer (ao_alsa_internal_t *s) +void ao_alsa_write_buffer(ao_alsa_internal_t *s) { snd_pcm_channel_status_t status; snd_pcm_t *pcm_handle = s->pcm_handle; @@ -188,16 +180,14 @@ ao_alsa_write_buffer (ao_alsa_internal_t *s) } } -static void -ao_alsa_play (ao_internal_t *state, void* output_samples, uint_32 num_bytes) +void plugin_play(ao_internal_t *state, void* output_samples, uint_32 num_bytes) { ao_alsa_internal_t *s = (ao_alsa_internal_t *) state; int packed = 0; int copy_len; char *samples = (char *) output_samples; - while (packed < num_bytes) - { + while (packed < num_bytes) { /* Pack the buffer */ if (num_bytes-packed < s->buf_size-s->buf_end) copy_len = num_bytes - packed; @@ -209,28 +199,11 @@ ao_alsa_play (ao_internal_t *state, void* output_samples, uint_32 num_bytes) s->buf_end += copy_len; if(s->buf_end == s->buf_size) - { ao_alsa_write_buffer(s); - } } } -static ao_info_t* -ao_alsa_get_driver_info (void) +ao_info_t *plugin_get_driver_info(void) { return &ao_alsa_info; } - -ao_functions_t ao_alsa = -{ - ao_alsa_get_driver_info, - ao_alsa_open, - ao_alsa_play, - ao_alsa_close -}; - - - - - - diff --git a/src/plugins/esd/ao_esd.c b/src/plugins/esd/ao_esd.c index fad7193..16fd3d7 100644 --- a/src/plugins/esd/ao_esd.c +++ b/src/plugins/esd/ao_esd.c @@ -39,21 +39,19 @@ typedef struct ao_esd_internal_s char *host; } ao_esd_internal_t; -static ao_info_t ao_esd_info = +ao_info_t ao_esd_info = { "ESounD output", "esd", "Stan Seibert <volsung@asu.edu>", - "" + "Outputs to the Enlighted Sound Daemon." }; -static void -ao_esd_parse_options(ao_esd_internal_t *state, ao_option_t *options) +void ao_esd_parse_options(ao_esd_internal_t *state, ao_option_t *options) { state->host = NULL; - while (options) - { + while (options) { if (!strcmp(options->key, "host")) state->host = strdup(options->value); @@ -61,8 +59,7 @@ ao_esd_parse_options(ao_esd_internal_t *state, ao_option_t *options) } } -static ao_internal_t* -ao_esd_open (uint_32 bits, uint_32 rate, uint_32 channels, ao_option_t *options) +ao_internal_t *plugin_open(uint_32 bits, uint_32 rate, uint_32 channels, ao_option_t *options) { ao_esd_internal_t *state; int esd_bits; @@ -109,8 +106,7 @@ ao_esd_open (uint_32 bits, uint_32 rate, uint_32 channels, ao_option_t *options) return state; } -static void -ao_esd_close (ao_internal_t *state) +void plugin_close(ao_internal_t *state) { ao_esd_internal_t *s = (ao_esd_internal_t *) state; close(s->sock); @@ -118,29 +114,12 @@ ao_esd_close (ao_internal_t *state) free(s); } -static void -ao_esd_play (ao_internal_t *state, void* output_samples, uint_32 num_bytes) +void plugin_play(ao_internal_t *state, void* output_samples, uint_32 num_bytes) { - write( ((ao_esd_internal_t *) state)->sock, output_samples, - num_bytes ); + write(((ao_esd_internal_t *) state)->sock, output_samples, num_bytes); } -static ao_info_t* -ao_esd_get_driver_info (void) +ao_info_t *plugin_get_driver_info(void) { return &ao_esd_info; } - -ao_functions_t ao_esd = -{ - ao_esd_get_driver_info, - ao_esd_open, - ao_esd_play, - ao_esd_close -}; - - - - - - diff --git a/src/plugins/irix/ao_irix.c b/src/plugins/irix/ao_irix.c index 60a1b41..96dd972 100644 --- a/src/plugins/irix/ao_irix.c +++ b/src/plugins/irix/ao_irix.c @@ -45,7 +45,7 @@ typedef struct ao_irix_internal_s { } ao_irix_internal_t; -static ao_info_t ao_irix_info = +ao_info_t ao_irix_info = { "Irix audio output ", "irix", @@ -57,8 +57,7 @@ static ao_info_t ao_irix_info = /* * open the audio device for writing to */ -static ao_internal_t* -ao_irix_open(uint_32 bits, uint_32 rate, uint_32 channels, ao_option_t *options) +ao_internal_t *plugin_open(uint_32 bits, uint_32 rate, uint_32 channels, ao_option_t *options) { ALpv params[2]; int dev = AL_DEFAULT_OUTPUT; @@ -75,29 +74,25 @@ ao_irix_open(uint_32 bits, uint_32 rate, uint_32 channels, ao_option_t *options) state->alconfig = alNewConfig(); - if (alSetQueueSize(state->alconfig, BUFFER_SIZE) < 0) - { + if (alSetQueueSize(state->alconfig, BUFFER_SIZE) < 0) { fprintf(stderr, "alSetQueueSize failed: %s\n", alGetErrorString(oserror())); return 0; } - if (alSetChannels(state->alconfig, channels) < 0) - { + if (alSetChannels(state->alconfig, channels) < 0) { fprintf(stderr, "alSetChannels(%d) failed: %s\n", channels, alGetErrorString(oserror())); return 0; } - if (alSetDevice(state->alconfig, dev) < 0) - { + if (alSetDevice(state->alconfig, dev) < 0) { fprintf(stderr, "alSetDevice failed: %s\n", alGetErrorString(oserror())); return 0; } - if (alSetSampFmt(state->alconfig, AL_SAMPFMT_TWOSCOMP) < 0) - { + if (alSetSampFmt(state->alconfig, AL_SAMPFMT_TWOSCOMP) < 0) { fprintf(stderr, "alSetSampFmt failed: %s\n", alGetErrorString(oserror())); return 0; @@ -105,15 +100,13 @@ ao_irix_open(uint_32 bits, uint_32 rate, uint_32 channels, ao_option_t *options) state->alport = alOpenPort("AC3Decode", "w", 0); - if (!state->alport) - { + if (!state->alport) { fprintf(stderr, "alOpenPort failed: %s\n", alGetErrorString(oserror())); return 0; } - switch (bits) - { + switch (bits) { case 8: state->bytesPerWord = 1; wsize = AL_SAMPLE_8; @@ -134,8 +127,7 @@ ao_irix_open(uint_32 bits, uint_32 rate, uint_32 channels, ao_option_t *options) break; } - if (alSetWidth(state->alconfig, wsize) < 0) - { + if (alSetWidth(state->alconfig, wsize) < 0) { fprintf(stderr, "alSetWidth failed: %s\n", alGetErrorString(oserror())); return 0; } @@ -156,17 +148,14 @@ ao_irix_open(uint_32 bits, uint_32 rate, uint_32 channels, ao_option_t *options) * play the sample to the already opened file descriptor */ -static void -ao_irix_play(ao_internal_t *state, void* output_samples, uint_32 num_bytes) +void plugin_play(ao_internal_t *state, void* output_samples, uint_32 num_bytes) { - alWriteFrames( ((ao_irix_internal_t *) state)->alport, - output_samples, num_bytes); + alWriteFrames(((ao_irix_internal_t *)state)->alport, output_samples, num_bytes); } -static void -ao_irix_close(ao_internal_t *state) +void plugin_close(ao_internal_t *state) { - ao_irix_internal_t *s = (ao_irix_internal_t *) state; + ao_irix_internal_t *s = (ao_irix_internal_t *)state; alClosePort(s->alport); alFreeConfig(s->alconfig); @@ -174,16 +163,7 @@ ao_irix_close(ao_internal_t *state) free(state); } -static ao_info_t* -ao_irix_get_driver_info(void) +ao_info_t *plugin_get_driver_info(void) { return &ao_irix_info; } - -ao_functions_t ao_irix = -{ - ao_irix_get_driver_info, - ao_irix_open, - ao_irix_play, - ao_irix_close -}; diff --git a/src/plugins/oss/ao_oss.c b/src/plugins/oss/ao_oss.c index 82f0a40..46b3b79 100644 --- a/src/plugins/oss/ao_oss.c +++ b/src/plugins/oss/ao_oss.c @@ -41,12 +41,12 @@ #include <ao/ao.h> -static ao_info_t ao_oss_info = +ao_info_t ao_oss_info = { "OSS audio driver output ", "oss", "Aaron Holtzman <aholtzma@ess.engr.uvic.ca>", - "" + "Outputs audio to the Open Sound System driver." }; @@ -55,13 +55,11 @@ typedef struct ao_oss_internal_s { int fd; } ao_oss_internal_t; -static void -ao_oss_parse_options(ao_oss_internal_t *state, ao_option_t *options) +void ao_oss_parse_options(ao_oss_internal_t *state, ao_option_t *options) { state->dev = NULL; - while (options) - { + while (options) { if (!strcmp(options->key, "dsp")) state->dev = strdup(options->value); @@ -75,8 +73,7 @@ ao_oss_parse_options(ao_oss_internal_t *state, ao_option_t *options) /* * open the audio device for writing to */ -static ao_internal_t* -ao_oss_open(uint_32 bits, uint_32 rate, uint_32 channels, ao_option_t *options) +ao_internal_t *plugin_open(uint_32 bits, uint_32 rate, uint_32 channels, ao_option_t *options) { ao_oss_internal_t *state; int tmp; @@ -147,16 +144,13 @@ ao_oss_open(uint_32 bits, uint_32 rate, uint_32 channels, ao_option_t *options) /* * play the sample to the already opened file descriptor */ -static void -ao_oss_play(ao_internal_t *state, void *output_samples, uint_32 num_bytes) +void plugin_play(ao_internal_t *state, void *output_samples, uint_32 num_bytes) { - write( ((ao_oss_internal_t *)state)->fd, output_samples, num_bytes); } -static void -ao_oss_close(ao_internal_t *state) +void plugin_close(ao_internal_t *state) { ao_oss_internal_t *s = (ao_oss_internal_t *) state; close(s->fd); @@ -165,16 +159,7 @@ ao_oss_close(ao_internal_t *state) } -static ao_info_t* -ao_oss_get_driver_info(void) +ao_info_t *plugin_get_driver_info(void) { return &ao_oss_info; } - -ao_functions_t ao_oss = -{ - ao_oss_get_driver_info, - ao_oss_open, - ao_oss_play, - ao_oss_close -}; diff --git a/src/plugins/solaris/ao_solaris.c b/src/plugins/solaris/ao_solaris.c index a6ad7a4..57c62f7 100644 --- a/src/plugins/solaris/ao_solaris.c +++ b/src/plugins/solaris/ao_solaris.c @@ -41,9 +41,9 @@ int usleep(unsigned int useconds); #include <ao/ao.h> -static ao_info_t ao_solaris_info = +ao_info_t ao_solaris_info = { - "Solaris audio output ", + "Solaris audio output", "solaris", "Aaron Holtzman <aholtzma@ess.engr.uvic.ca>", "WARNING: This driver is untested." @@ -59,10 +59,8 @@ typedef struct ao_solaris_internal_s { /* * open the audio device for writing to */ -static ao_internal_t* -ao_open(uint_32 bits, uint_32 rate, uint_32 channels, ao_option_t *options) +ao_internal_t *plugin_open(uint_32 bits, uint_32 rate, uint_32 channels, ao_option_t *options) { - ao_solaris_internal_t *state; state = malloc(sizeof(ao_solaris_internal_t)); @@ -76,8 +74,7 @@ ao_open(uint_32 bits, uint_32 rate, uint_32 channels, ao_option_t *options) */ state->fd=open(state->dev,O_WRONLY); - if(state->fd < 0) - { + if(state->fd < 0) { fprintf(stderr,"%s: Opening audio device %s\n", strerror(errno), state->dev); goto ERR; @@ -98,8 +95,7 @@ ao_open(uint_32 bits, uint_32 rate, uint_32 channels, ao_option_t *options) /* An implicit GETINFO is also performed so we can get * the buffer_size */ - if(ioctl(state->fd, AUDIO_SETINFO, &(state->info)) < 0) - { + if(ioctl(state->fd, AUDIO_SETINFO, &(state->info)) < 0) { fprintf(stderr, "%s: Writing audio config block\n",strerror(errno)); goto ERR; } @@ -114,32 +110,19 @@ ERR: /* * play the sample to the already opened file descriptor */ -static void -ao_solaris_play(ao_internal_t *state, void *output_samples, uint_32 num_bytes) +void plugin_play(ao_internal_t *state, void *output_samples, uint_32 num_bytes) { - write( ((ao_solaris_internal_t *) state)->fd, - output_samples, num_bytes); + write(((ao_solaris_internal_t *)state)->fd, output_samples, num_bytes); } -static void -ao_solaris_close(ao_internal_t *state) +void plugin_close(ao_internal_t *state) { close(((ao_solaris_internal_t *) state)->fd); free(state); } -static const ao_info_t* -ao_solaris_get_driver_info(void) +const ao_info_t *plugin_get_driver_info(void) { return &ao_solaris_info; } - - -ao_functions_t ao_solaris = -{ - ao_solaris_get_driver_info, - ao_solaris_open, - ao_solaris_play, - ao_solaris_close -}; -- GitLab