mirror of https://github.com/mpv-player/mpv
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.
This commit is contained in:
parent
485f439cfe
commit
3a01606dc0
|
@ -97,8 +97,6 @@ static void alsa_error_handler(const char *file, int line, const char *function,
|
||||||
static int control(int cmd, void *arg)
|
static int control(int cmd, void *arg)
|
||||||
{
|
{
|
||||||
switch(cmd) {
|
switch(cmd) {
|
||||||
case AOCONTROL_QUERY_FORMAT:
|
|
||||||
return CONTROL_TRUE;
|
|
||||||
case AOCONTROL_GET_VOLUME:
|
case AOCONTROL_GET_VOLUME:
|
||||||
case AOCONTROL_SET_VOLUME:
|
case AOCONTROL_SET_VOLUME:
|
||||||
{
|
{
|
||||||
|
|
|
@ -179,22 +179,6 @@ static int volume_oss4(ao_control_vol_t *vol, int cmd) {
|
||||||
// to set/get/query special features/parameters
|
// to set/get/query special features/parameters
|
||||||
static int control(int cmd,void *arg){
|
static int control(int cmd,void *arg){
|
||||||
switch(cmd){
|
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_GET_VOLUME:
|
||||||
case AOCONTROL_SET_VOLUME:
|
case AOCONTROL_SET_VOLUME:
|
||||||
{
|
{
|
||||||
|
|
|
@ -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);
|
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;
|
struct priv *priv = ao->priv;
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
|
|
|
@ -118,13 +118,6 @@ static int control(int cmd, void *arg){
|
||||||
|
|
||||||
mp_tmsg(MSGT_AO, MSGL_INFO, "[AO SGI] control.\n");
|
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;
|
return CONTROL_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -402,11 +402,6 @@ static void setup_device_paths(void)
|
||||||
// to set/get/query special features/parameters
|
// to set/get/query special features/parameters
|
||||||
static int control(int cmd,void *arg){
|
static int control(int cmd,void *arg){
|
||||||
switch(cmd){
|
switch(cmd){
|
||||||
case AOCONTROL_SET_DEVICE:
|
|
||||||
audio_dev=(char*)arg;
|
|
||||||
return CONTROL_OK;
|
|
||||||
case AOCONTROL_QUERY_FORMAT:
|
|
||||||
return CONTROL_TRUE;
|
|
||||||
case AOCONTROL_GET_VOLUME:
|
case AOCONTROL_GET_VOLUME:
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
|
|
|
@ -232,7 +232,7 @@ int ao_play(struct ao *ao, void *data, int len, int flags)
|
||||||
return ao->driver->play(ao, data, len, 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)
|
if (ao->driver->control)
|
||||||
return ao->driver->control(ao, cmd, arg);
|
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);
|
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);
|
return ao->driver->old_functions->control(cmd, arg);
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,27 @@
|
||||||
|
|
||||||
#include "bstr.h"
|
#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 {
|
typedef struct ao_info {
|
||||||
/* driver name ("Matrox Millennium G200/G400" */
|
/* driver name ("Matrox Millennium G200/G400" */
|
||||||
const char *name;
|
const char *name;
|
||||||
|
@ -53,7 +74,7 @@ struct ao_driver {
|
||||||
bool is_new;
|
bool is_new;
|
||||||
const struct ao_info *info;
|
const struct ao_info *info;
|
||||||
const struct ao_old_functions *old_functions;
|
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);
|
int (*init)(struct ao *ao, char *params);
|
||||||
void (*uninit)(struct ao *ao, bool cut_audio);
|
void (*uninit)(struct ao *ao, bool cut_audio);
|
||||||
void (*reset)(struct ao*ao);
|
void (*reset)(struct ao*ao);
|
||||||
|
@ -88,40 +109,18 @@ extern char *ao_subdevice;
|
||||||
|
|
||||||
void list_audio_out(void);
|
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);
|
struct ao *ao_create(struct MPOpts *opts, struct input_ctx *input);
|
||||||
void ao_init(struct ao *ao, char **ao_list);
|
void ao_init(struct ao *ao, char **ao_list);
|
||||||
void ao_uninit(struct ao *ao, bool cut_audio);
|
void ao_uninit(struct ao *ao, bool cut_audio);
|
||||||
int ao_play(struct ao *ao, void *data, int len, int flags);
|
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);
|
double ao_get_delay(struct ao *ao);
|
||||||
int ao_get_space(struct ao *ao);
|
int ao_get_space(struct ao *ao);
|
||||||
void ao_reset(struct ao *ao);
|
void ao_reset(struct ao *ao);
|
||||||
void ao_pause(struct ao *ao);
|
void ao_pause(struct ao *ao);
|
||||||
void ao_resume(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);
|
int old_ao_init(struct ao *ao, char *params);
|
||||||
void old_ao_uninit(struct ao *ao, bool cut_audio);
|
void old_ao_uninit(struct ao *ao, bool cut_audio);
|
||||||
void old_ao_reset(struct ao*ao);
|
void old_ao_reset(struct ao*ao);
|
||||||
|
|
Loading…
Reference in New Issue