From 3a01606dc05b2cedb9792a6f8adefeba6e434ab0 Mon Sep 17 00:00:00 2001 From: Uoti Urpala Date: Sat, 7 Apr 2012 16:26:56 +0300 Subject: [PATCH] libao2: change control() types to enum, remove unused ones Change the audio driver control() command argument from "int" to "enum aocontrol". Remove unused control types (SET_DEVICE, GET_DEVICE, QUERY_FORMAT, SET_PLUGIN_DRIVER, SET_PLUGIN_LIST). The QUERY_FORMAT one looks like there's a possibility such functionality could be useful in the future, but as ao_oss was the only driver to have an actual implementation of it, the current code wasn't worth keeping. --- libao2/ao_alsa.c | 2 -- libao2/ao_oss.c | 16 ---------------- libao2/ao_pulse.c | 2 +- libao2/ao_sgi.c | 7 ------- libao2/ao_sun.c | 5 ----- libao2/audio_out.c | 4 ++-- libao2/audio_out.h | 49 ++++++++++++++++++++++++------------------------- 7 files changed, 27 insertions(+), 58 deletions(-) diff --git a/libao2/ao_alsa.c b/libao2/ao_alsa.c index 1581be4b80..e155a07cd5 100644 --- a/libao2/ao_alsa.c +++ b/libao2/ao_alsa.c @@ -97,8 +97,6 @@ static void alsa_error_handler(const char *file, int line, const char *function, static int control(int cmd, void *arg) { switch(cmd) { - case AOCONTROL_QUERY_FORMAT: - return CONTROL_TRUE; case AOCONTROL_GET_VOLUME: case AOCONTROL_SET_VOLUME: { diff --git a/libao2/ao_oss.c b/libao2/ao_oss.c index 82a0dd51e5..9290a73380 100644 --- a/libao2/ao_oss.c +++ b/libao2/ao_oss.c @@ -179,22 +179,6 @@ static int volume_oss4(ao_control_vol_t *vol, int cmd) { // to set/get/query special features/parameters static int control(int cmd,void *arg){ switch(cmd){ - case AOCONTROL_SET_DEVICE: - dsp=(char*)arg; - return CONTROL_OK; - case AOCONTROL_GET_DEVICE: - *(char**)arg=dsp; - return CONTROL_OK; -#ifdef SNDCTL_DSP_GETFMTS - case AOCONTROL_QUERY_FORMAT: - { - int format; - if (!ioctl(audio_fd, SNDCTL_DSP_GETFMTS, &format)) - if ((unsigned int)format & (unsigned long)arg) - return CONTROL_TRUE; - return CONTROL_FALSE; - } -#endif case AOCONTROL_GET_VOLUME: case AOCONTROL_SET_VOLUME: { diff --git a/libao2/ao_pulse.c b/libao2/ao_pulse.c index ba95ccf2d2..fb331933d6 100644 --- a/libao2/ao_pulse.c +++ b/libao2/ao_pulse.c @@ -420,7 +420,7 @@ static void info_func(struct pa_context *c, const struct pa_sink_input_info *i, pa_threaded_mainloop_signal(priv->mainloop, 0); } -static int control(struct ao *ao, int cmd, void *arg) +static int control(struct ao *ao, enum aocontrol cmd, void *arg) { struct priv *priv = ao->priv; switch (cmd) { diff --git a/libao2/ao_sgi.c b/libao2/ao_sgi.c index 40bc6b9177..492c8ff3ba 100644 --- a/libao2/ao_sgi.c +++ b/libao2/ao_sgi.c @@ -118,13 +118,6 @@ static int control(int cmd, void *arg){ mp_tmsg(MSGT_AO, MSGL_INFO, "[AO SGI] control.\n"); - switch(cmd) { - case AOCONTROL_QUERY_FORMAT: - /* Do not reject any format: return the closest matching - * format if the request is not supported natively. */ - return CONTROL_TRUE; - } - return CONTROL_UNKNOWN; } diff --git a/libao2/ao_sun.c b/libao2/ao_sun.c index ef8417c5f9..ecdb23d4af 100644 --- a/libao2/ao_sun.c +++ b/libao2/ao_sun.c @@ -402,11 +402,6 @@ static void setup_device_paths(void) // to set/get/query special features/parameters static int control(int cmd,void *arg){ switch(cmd){ - case AOCONTROL_SET_DEVICE: - audio_dev=(char*)arg; - return CONTROL_OK; - case AOCONTROL_QUERY_FORMAT: - return CONTROL_TRUE; case AOCONTROL_GET_VOLUME: { int fd; diff --git a/libao2/audio_out.c b/libao2/audio_out.c index 6130e2ed33..268c17d749 100644 --- a/libao2/audio_out.c +++ b/libao2/audio_out.c @@ -232,7 +232,7 @@ int ao_play(struct ao *ao, void *data, int len, int flags) return ao->driver->play(ao, data, len, flags); } -int ao_control(struct ao *ao, int cmd, void *arg) +int ao_control(struct ao *ao, enum aocontrol cmd, void *arg) { if (ao->driver->control) return ao->driver->control(ao, cmd, arg); @@ -299,7 +299,7 @@ int old_ao_play(struct ao *ao, void *data, int len, int flags) return ao->driver->old_functions->play(data, len, flags); } -int old_ao_control(struct ao *ao, int cmd, void *arg) +int old_ao_control(struct ao *ao, enum aocontrol cmd, void *arg) { return ao->driver->old_functions->control(cmd, arg); } diff --git a/libao2/audio_out.h b/libao2/audio_out.h index 1c472565a0..2e59c42aa4 100644 --- a/libao2/audio_out.h +++ b/libao2/audio_out.h @@ -23,6 +23,27 @@ #include "bstr.h" +#define CONTROL_OK 1 +#define CONTROL_TRUE 1 +#define CONTROL_FALSE 0 +#define CONTROL_UNKNOWN -1 +#define CONTROL_ERROR -2 +#define CONTROL_NA -3 + +enum aocontrol { + // _VOLUME commands take struct ao_control_vol pointer for input/output. + // If there's only one volume, SET should use average of left/right. + AOCONTROL_GET_VOLUME, + AOCONTROL_SET_VOLUME, +}; + +#define AOPLAY_FINAL_CHUNK 1 + +typedef struct ao_control_vol { + float left; + float right; +} ao_control_vol_t; + typedef struct ao_info { /* driver name ("Matrox Millennium G200/G400" */ const char *name; @@ -53,7 +74,7 @@ struct ao_driver { bool is_new; const struct ao_info *info; const struct ao_old_functions *old_functions; - int (*control)(struct ao *ao, int cmd, void *arg); + int (*control)(struct ao *ao, enum aocontrol cmd, void *arg); int (*init)(struct ao *ao, char *params); void (*uninit)(struct ao *ao, bool cut_audio); void (*reset)(struct ao*ao); @@ -88,40 +109,18 @@ extern char *ao_subdevice; void list_audio_out(void); -#define CONTROL_OK 1 -#define CONTROL_TRUE 1 -#define CONTROL_FALSE 0 -#define CONTROL_UNKNOWN -1 -#define CONTROL_ERROR -2 -#define CONTROL_NA -3 - -#define AOCONTROL_SET_DEVICE 1 -#define AOCONTROL_GET_DEVICE 2 -#define AOCONTROL_QUERY_FORMAT 3 /* test for availabilty of a format */ -#define AOCONTROL_GET_VOLUME 4 -#define AOCONTROL_SET_VOLUME 5 -#define AOCONTROL_SET_PLUGIN_DRIVER 6 -#define AOCONTROL_SET_PLUGIN_LIST 7 - -#define AOPLAY_FINAL_CHUNK 1 - -typedef struct ao_control_vol { - float left; - float right; -} ao_control_vol_t; - struct ao *ao_create(struct MPOpts *opts, struct input_ctx *input); void ao_init(struct ao *ao, char **ao_list); void ao_uninit(struct ao *ao, bool cut_audio); int ao_play(struct ao *ao, void *data, int len, int flags); -int ao_control(struct ao *ao, int cmd, void *arg); +int ao_control(struct ao *ao, enum aocontrol cmd, void *arg); double ao_get_delay(struct ao *ao); int ao_get_space(struct ao *ao); void ao_reset(struct ao *ao); void ao_pause(struct ao *ao); void ao_resume(struct ao *ao); -int old_ao_control(struct ao *ao, int cmd, void *arg); +int old_ao_control(struct ao *ao, enum aocontrol cmd, void *arg); int old_ao_init(struct ao *ao, char *params); void old_ao_uninit(struct ao *ao, bool cut_audio); void old_ao_reset(struct ao*ao); -- 2.11.4.GIT