mirror of
https://github.com/mpv-player/mpv
synced 2025-02-16 20:27:23 +00:00
audio/filter: remove unneeded AF_CONTROLs, convert to enum
The AF control commands used an elaborate and unnecessary organization for the command constants. Get rid of all that and convert the definitions to a simple enum. Also remove the control commands that were not really needed, because they were not used outside of the filters that implemented them.
This commit is contained in:
parent
93852b08f3
commit
5594718b6b
@ -438,7 +438,7 @@ static int af_fix_format_conversion(struct af_stream *s,
|
||||
if (!filter)
|
||||
return AF_ERROR;
|
||||
if (strcmp(filter, prev->info->name) == 0) {
|
||||
if (prev->control(prev, AF_CONTROL_FORMAT_FMT, &dstfmt) == AF_OK) {
|
||||
if (prev->control(prev, AF_CONTROL_SET_FORMAT, &dstfmt) == AF_OK) {
|
||||
*p_af = prev;
|
||||
return AF_OK;
|
||||
}
|
||||
@ -447,7 +447,7 @@ static int af_fix_format_conversion(struct af_stream *s,
|
||||
if (new == NULL)
|
||||
return AF_ERROR;
|
||||
new->auto_inserted = true;
|
||||
if (AF_OK != (rv = new->control(new, AF_CONTROL_FORMAT_FMT, &dstfmt)))
|
||||
if (AF_OK != (rv = new->control(new, AF_CONTROL_SET_FORMAT, &dstfmt)))
|
||||
return rv;
|
||||
*p_af = new;
|
||||
return AF_OK;
|
||||
@ -463,7 +463,7 @@ static int af_fix_channels(struct af_stream *s, struct af_instance **p_af,
|
||||
struct mp_audio actual = *prev->data;
|
||||
if (mp_chmap_equals(&actual.channels, &in.channels))
|
||||
return AF_FALSE;
|
||||
if (prev->control(prev, AF_CONTROL_CHANNELS, &in.channels) == AF_OK) {
|
||||
if (prev->control(prev, AF_CONTROL_SET_CHANNELS, &in.channels) == AF_OK) {
|
||||
*p_af = prev;
|
||||
return AF_OK;
|
||||
}
|
||||
@ -472,7 +472,7 @@ static int af_fix_channels(struct af_stream *s, struct af_instance **p_af,
|
||||
if (new == NULL)
|
||||
return AF_ERROR;
|
||||
new->auto_inserted = true;
|
||||
if (AF_OK != (rv = new->control(new, AF_CONTROL_CHANNELS, &in.channels)))
|
||||
if (AF_OK != (rv = new->control(new, AF_CONTROL_SET_CHANNELS, &in.channels)))
|
||||
return rv;
|
||||
*p_af = new;
|
||||
return AF_OK;
|
||||
@ -487,7 +487,7 @@ static int af_fix_rate(struct af_stream *s, struct af_instance **p_af,
|
||||
struct mp_audio actual = *prev->data;
|
||||
if (actual.rate == in.rate)
|
||||
return AF_FALSE;
|
||||
if (prev->control(prev, AF_CONTROL_RESAMPLE_RATE, &in.rate) == AF_OK) {
|
||||
if (prev->control(prev, AF_CONTROL_SET_RESAMPLE_RATE, &in.rate) == AF_OK) {
|
||||
*p_af = prev;
|
||||
return AF_OK;
|
||||
}
|
||||
@ -496,7 +496,7 @@ static int af_fix_rate(struct af_stream *s, struct af_instance **p_af,
|
||||
if (new == NULL)
|
||||
return AF_ERROR;
|
||||
new->auto_inserted = true;
|
||||
if (AF_OK != (rv = new->control(new, AF_CONTROL_RESAMPLE_RATE, &in.rate)))
|
||||
if (AF_OK != (rv = new->control(new, AF_CONTROL_SET_RESAMPLE_RATE, &in.rate)))
|
||||
return rv;
|
||||
*p_af = new;
|
||||
return AF_OK;
|
||||
|
@ -21,6 +21,7 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
@ -28,7 +29,6 @@
|
||||
#include "audio/format.h"
|
||||
#include "audio/chmap.h"
|
||||
#include "audio/audio.h"
|
||||
#include "control.h"
|
||||
#include "mpvcore/mp_msg.h"
|
||||
|
||||
struct af_instance;
|
||||
@ -96,6 +96,28 @@ struct af_stream {
|
||||
#define AF_ERROR -2
|
||||
#define AF_FATAL -3
|
||||
|
||||
// Parameters for af_control_*
|
||||
enum af_control {
|
||||
AF_CONTROL_REINIT = 1,
|
||||
AF_CONTROL_COMMAND_LINE,
|
||||
AF_CONTROL_SET_RESAMPLE_RATE,
|
||||
AF_CONTROL_SET_FORMAT,
|
||||
AF_CONTROL_SET_CHANNELS,
|
||||
AF_CONTROL_SET_VOLUME,
|
||||
AF_CONTROL_GET_VOLUME,
|
||||
AF_CONTROL_SET_PAN_LEVEL,
|
||||
AF_CONTROL_SET_PAN_NOUT,
|
||||
AF_CONTROL_SET_PAN_BALANCE,
|
||||
AF_CONTROL_GET_PAN_BALANCE,
|
||||
AF_CONTROL_SET_PLAYBACK_SPEED,
|
||||
};
|
||||
|
||||
// Argument for AF_CONTROL_SET_PAN_LEVEL
|
||||
typedef struct af_control_ext_s {
|
||||
void* arg; // Argument
|
||||
int ch; // Chanel number
|
||||
} af_control_ext_t;
|
||||
|
||||
struct af_stream *af_new(struct MPOpts *opts);
|
||||
void af_destroy(struct af_stream *s);
|
||||
int af_init(struct af_stream *s);
|
||||
|
@ -57,21 +57,15 @@ static int control(struct af_instance* af, int cmd, void* arg)
|
||||
case AF_CONTROL_COMMAND_LINE:{
|
||||
int ch=1;
|
||||
sscanf(arg,"%i", &ch);
|
||||
return control(af,AF_CONTROL_CENTER_CH | AF_CONTROL_SET, &ch);
|
||||
}
|
||||
case AF_CONTROL_CENTER_CH | AF_CONTROL_SET: // Requires reinit
|
||||
// Sanity check
|
||||
if((*(int*)arg >= AF_NCH) || (*(int*)arg < 0)){
|
||||
if((ch >= AF_NCH) || (ch < 0)){
|
||||
mp_msg(MSGT_AFILTER, MSGL_ERR, "[sub] Center channel number must be between "
|
||||
" 0 and %i current value is %i\n", AF_NCH-1, *(int*)arg);
|
||||
" 0 and %i current value is %i\n", AF_NCH-1, ch);
|
||||
return AF_ERROR;
|
||||
}
|
||||
s->ch = *(int*)arg;
|
||||
return AF_OK;
|
||||
case AF_CONTROL_CENTER_CH | AF_CONTROL_GET:
|
||||
*(int*)arg = s->ch;
|
||||
s->ch = ch;
|
||||
return AF_OK;
|
||||
}
|
||||
}
|
||||
return AF_UNKNOWN;
|
||||
}
|
||||
|
||||
|
@ -201,11 +201,11 @@ static int control(struct af_instance* af, int cmd, void* arg)
|
||||
|
||||
struct mp_chmap chmap;
|
||||
mp_chmap_from_channels(&chmap, nch);
|
||||
if (AF_OK != af->control(af, AF_CONTROL_CHANNELS | AF_CONTROL_SET, &chmap))
|
||||
if (AF_OK != af->control(af, AF_CONTROL_SET_CHANNELS, &chmap))
|
||||
return AF_ERROR;
|
||||
return AF_OK;
|
||||
}
|
||||
case AF_CONTROL_CHANNELS | AF_CONTROL_SET:
|
||||
case AF_CONTROL_SET_CHANNELS:
|
||||
// Reinit must be called after this function has been called
|
||||
|
||||
mp_audio_set_channels(af->data, (struct mp_chmap *)arg);
|
||||
|
@ -55,7 +55,7 @@ static int control(struct af_instance *af, int cmd, void *arg)
|
||||
|
||||
return mp_audio_config_equals(in, &orig_in) ? AF_OK : AF_FALSE;
|
||||
}
|
||||
case AF_CONTROL_FORMAT_FMT | AF_CONTROL_SET: {
|
||||
case AF_CONTROL_SET_FORMAT: {
|
||||
mp_audio_set_format(af->data, *(int*)arg);
|
||||
return AF_OK;
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ static int control(struct af_instance *af, int cmd, void *arg)
|
||||
|
||||
return mp_audio_config_equals(in, &orig_in) ? AF_OK : AF_FALSE;
|
||||
}
|
||||
case AF_CONTROL_FORMAT_FMT | AF_CONTROL_SET: {
|
||||
case AF_CONTROL_SET_FORMAT: {
|
||||
mp_audio_set_format(af->data, *(int*)arg);
|
||||
return AF_OK;
|
||||
}
|
||||
|
@ -65,7 +65,16 @@ static int control(struct af_instance* af, int cmd, void* arg)
|
||||
mp_msg(MSGT_AFILTER, MSGL_FATAL, "[delay] Out of memory\n");
|
||||
}
|
||||
|
||||
return control(af,AF_CONTROL_DELAY_LEN | AF_CONTROL_SET,s->d);
|
||||
if(AF_OK != af_from_ms(AF_NCH, s->d, s->wi, af->data->rate, 0.0, 1000.0))
|
||||
return AF_ERROR;
|
||||
s->ri = 0;
|
||||
for(i=0;i<AF_NCH;i++){
|
||||
mp_msg(MSGT_AFILTER, MSGL_DBG2, "[delay] Channel %i delayed by %0.3fms\n",
|
||||
i,MPCLAMP(s->d[i],0.0,1000.0));
|
||||
mp_msg(MSGT_AFILTER, MSGL_DBG3, "[delay] Channel %i delayed by %i samples\n",
|
||||
i,s->wi[i]);
|
||||
}
|
||||
return AF_OK;
|
||||
}
|
||||
case AF_CONTROL_COMMAND_LINE:{
|
||||
int n = 1;
|
||||
@ -80,29 +89,6 @@ static int control(struct af_instance* af, int cmd, void* arg)
|
||||
}
|
||||
return AF_OK;
|
||||
}
|
||||
case AF_CONTROL_DELAY_LEN | AF_CONTROL_SET:{
|
||||
int i;
|
||||
if(AF_OK != af_from_ms(AF_NCH, arg, s->wi, af->data->rate, 0.0, 1000.0))
|
||||
return AF_ERROR;
|
||||
s->ri = 0;
|
||||
for(i=0;i<AF_NCH;i++){
|
||||
mp_msg(MSGT_AFILTER, MSGL_DBG2, "[delay] Channel %i delayed by %0.3fms\n",
|
||||
i,MPCLAMP(s->d[i],0.0,1000.0));
|
||||
mp_msg(MSGT_AFILTER, MSGL_DBG3, "[delay] Channel %i delayed by %i samples\n",
|
||||
i,s->wi[i]);
|
||||
}
|
||||
return AF_OK;
|
||||
}
|
||||
case AF_CONTROL_DELAY_LEN | AF_CONTROL_GET:{
|
||||
int i;
|
||||
for(i=0;i<AF_NCH;i++){
|
||||
if(s->ri > s->wi[i])
|
||||
s->wi[i] = L - (s->ri - s->wi[i]);
|
||||
else
|
||||
s->wi[i] = s->wi[i] - s->ri;
|
||||
}
|
||||
return af_to_ms(AF_NCH, s->wi, arg, af->data->rate);
|
||||
}
|
||||
}
|
||||
return AF_UNKNOWN;
|
||||
}
|
||||
|
@ -161,19 +161,13 @@ static int control(struct af_instance* af, int cmd, void* arg)
|
||||
|
||||
sscanf(str + i + 1, "%d", &(s->sz));
|
||||
|
||||
return af->control(af, AF_CONTROL_EXPORT_SZ | AF_CONTROL_SET, &s->sz);
|
||||
}
|
||||
case AF_CONTROL_EXPORT_SZ | AF_CONTROL_SET:
|
||||
s->sz = * (int *) arg;
|
||||
if((s->sz <= 0) || (s->sz > 2048))
|
||||
mp_msg(MSGT_AFILTER, MSGL_ERR, "[export] Buffer size must be between"
|
||||
" 1 and 2048\n" );
|
||||
|
||||
return AF_OK;
|
||||
case AF_CONTROL_EXPORT_SZ | AF_CONTROL_GET:
|
||||
*(int*) arg = s->sz;
|
||||
return AF_OK;
|
||||
|
||||
}
|
||||
}
|
||||
return AF_UNKNOWN;
|
||||
}
|
||||
|
@ -259,18 +259,18 @@ static int control(struct af_instance *af, int cmd, void *arg)
|
||||
r = configure_lavrr(af, in, out);
|
||||
return r;
|
||||
}
|
||||
case AF_CONTROL_FORMAT_FMT | AF_CONTROL_SET: {
|
||||
case AF_CONTROL_SET_FORMAT: {
|
||||
if (af_to_avformat(*(int*)arg) == AV_SAMPLE_FMT_NONE)
|
||||
return AF_FALSE;
|
||||
|
||||
mp_audio_set_format(af->data, *(int*)arg);
|
||||
return AF_OK;
|
||||
}
|
||||
case AF_CONTROL_CHANNELS | AF_CONTROL_SET: {
|
||||
case AF_CONTROL_SET_CHANNELS: {
|
||||
mp_audio_set_channels(af->data, (struct mp_chmap *)arg);
|
||||
return AF_OK;
|
||||
}
|
||||
case AF_CONTROL_RESAMPLE_RATE | AF_CONTROL_SET:
|
||||
case AF_CONTROL_SET_RESAMPLE_RATE:
|
||||
out->rate = *(int *)arg;
|
||||
return AF_OK;
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ static int control(struct af_instance* af, int cmd, void* arg)
|
||||
int j,k;
|
||||
// Read number of outputs
|
||||
sscanf((char*)arg,"%i%n", &nch,&n);
|
||||
if(AF_OK != control(af,AF_CONTROL_PAN_NOUT | AF_CONTROL_SET, &nch))
|
||||
if(AF_OK != control(af,AF_CONTROL_SET_PAN_NOUT, &nch))
|
||||
return AF_ERROR;
|
||||
|
||||
// Read pan values
|
||||
@ -90,7 +90,7 @@ static int control(struct af_instance* af, int cmd, void* arg)
|
||||
}
|
||||
return AF_OK;
|
||||
}
|
||||
case AF_CONTROL_PAN_LEVEL | AF_CONTROL_SET:{
|
||||
case AF_CONTROL_SET_PAN_LEVEL:{
|
||||
int i;
|
||||
int ch = ((af_control_ext_t*)arg)->ch;
|
||||
float* level = ((af_control_ext_t*)arg)->arg;
|
||||
@ -100,17 +100,7 @@ static int control(struct af_instance* af, int cmd, void* arg)
|
||||
s->level[ch][i] = level[i];
|
||||
return AF_OK;
|
||||
}
|
||||
case AF_CONTROL_PAN_LEVEL | AF_CONTROL_GET:{
|
||||
int i;
|
||||
int ch = ((af_control_ext_t*)arg)->ch;
|
||||
float* level = ((af_control_ext_t*)arg)->arg;
|
||||
if (ch >= AF_NCH)
|
||||
return AF_FALSE;
|
||||
for(i=0;i<AF_NCH;i++)
|
||||
level[i] = s->level[ch][i];
|
||||
return AF_OK;
|
||||
}
|
||||
case AF_CONTROL_PAN_NOUT | AF_CONTROL_SET:
|
||||
case AF_CONTROL_SET_PAN_NOUT:
|
||||
// Reinit must be called after this function has been called
|
||||
|
||||
// Sanity check
|
||||
@ -121,7 +111,7 @@ static int control(struct af_instance* af, int cmd, void* arg)
|
||||
}
|
||||
s->nch=((int*)arg)[0];
|
||||
return AF_OK;
|
||||
case AF_CONTROL_PAN_BALANCE | AF_CONTROL_SET:{
|
||||
case AF_CONTROL_SET_PAN_BALANCE:{
|
||||
float val = *(float*)arg;
|
||||
if (s->nch)
|
||||
return AF_ERROR;
|
||||
@ -133,7 +123,7 @@ static int control(struct af_instance* af, int cmd, void* arg)
|
||||
}
|
||||
return AF_OK;
|
||||
}
|
||||
case AF_CONTROL_PAN_BALANCE | AF_CONTROL_GET:
|
||||
case AF_CONTROL_GET_PAN_BALANCE:
|
||||
if (s->nch)
|
||||
return AF_ERROR;
|
||||
*(float*)arg = s->level[0][1] - s->level[1][0];
|
||||
|
@ -413,7 +413,7 @@ static int control(struct af_instance *af, int cmd, void *arg)
|
||||
|
||||
return af_test_output(af, (struct mp_audio *)arg);
|
||||
}
|
||||
case AF_CONTROL_PLAYBACK_SPEED | AF_CONTROL_SET: {
|
||||
case AF_CONTROL_SET_PLAYBACK_SPEED: {
|
||||
if (s->speed_tempo) {
|
||||
if (s->speed_pitch)
|
||||
break;
|
||||
@ -428,14 +428,6 @@ static int control(struct af_instance *af, int cmd, void *arg)
|
||||
}
|
||||
return AF_OK;
|
||||
}
|
||||
case AF_CONTROL_SCALETEMPO_AMOUNT | AF_CONTROL_SET: {
|
||||
s->scale = *(float *)arg;
|
||||
s->scale = s->speed * s->scale_nominal;
|
||||
return AF_OK;
|
||||
}
|
||||
case AF_CONTROL_SCALETEMPO_AMOUNT | AF_CONTROL_GET:
|
||||
*(float *)arg = s->scale;
|
||||
return AF_OK;
|
||||
}
|
||||
return AF_UNKNOWN;
|
||||
}
|
||||
|
@ -87,36 +87,22 @@ static int control(struct af_instance* af, int cmd, void* arg)
|
||||
int ch=5;
|
||||
float fc=60.0;
|
||||
sscanf(arg,"%f:%i", &fc , &ch);
|
||||
if(AF_OK != control(af,AF_CONTROL_SUB_CH | AF_CONTROL_SET, &ch))
|
||||
return AF_ERROR;
|
||||
return control(af,AF_CONTROL_SUB_FC | AF_CONTROL_SET, &fc);
|
||||
}
|
||||
case AF_CONTROL_SUB_CH | AF_CONTROL_SET: // Requires reinit
|
||||
// Sanity check
|
||||
if((*(int*)arg >= AF_NCH) || (*(int*)arg < 0)){
|
||||
if(ch >= AF_NCH || ch < 0){
|
||||
mp_msg(MSGT_AFILTER, MSGL_ERR, "[sub] Subwoofer channel number must be between "
|
||||
" 0 and %i current value is %i\n", AF_NCH-1, *(int*)arg);
|
||||
" 0 and %i current value is %i\n", AF_NCH-1, ch);
|
||||
return AF_ERROR;
|
||||
}
|
||||
s->ch = *(int*)arg;
|
||||
return AF_OK;
|
||||
case AF_CONTROL_SUB_CH | AF_CONTROL_GET:
|
||||
*(int*)arg = s->ch;
|
||||
return AF_OK;
|
||||
case AF_CONTROL_SUB_FC | AF_CONTROL_SET: // Requires reinit
|
||||
// Sanity check
|
||||
if((*(float*)arg > 300) || (*(float*)arg < 20)){
|
||||
s->ch = ch;
|
||||
if(fc > 300 || fc < 20){
|
||||
mp_msg(MSGT_AFILTER, MSGL_ERR, "[sub] Cutoff frequency must be between 20Hz and"
|
||||
" 300Hz current value is %0.2f",*(float*)arg);
|
||||
" 300Hz current value is %0.2f",fc);
|
||||
return AF_ERROR;
|
||||
}
|
||||
// Set cutoff frequency
|
||||
s->fc = *(float*)arg;
|
||||
return AF_OK;
|
||||
case AF_CONTROL_SUB_FC | AF_CONTROL_GET:
|
||||
*(float*)arg = s->fc;
|
||||
s->fc = fc;
|
||||
return AF_OK;
|
||||
}
|
||||
}
|
||||
return AF_UNKNOWN;
|
||||
}
|
||||
|
||||
|
@ -56,10 +56,10 @@ static int control(struct af_instance *af, int cmd, void *arg)
|
||||
mp_audio_set_format(af->data, af_fmt_to_planar(af->data->format));
|
||||
return af_test_output(af, in);
|
||||
}
|
||||
case AF_CONTROL_VOLUME_LEVEL | AF_CONTROL_SET:
|
||||
case AF_CONTROL_SET_VOLUME:
|
||||
s->level = *(float *)arg;
|
||||
return AF_OK;
|
||||
case AF_CONTROL_VOLUME_LEVEL | AF_CONTROL_GET:
|
||||
case AF_CONTROL_GET_VOLUME:
|
||||
*(float *)arg = s->level;
|
||||
return AF_OK;
|
||||
}
|
||||
|
@ -1,127 +0,0 @@
|
||||
/*
|
||||
* This file is part of MPlayer.
|
||||
*
|
||||
* MPlayer is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* MPlayer is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with MPlayer; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#ifndef MPLAYER_CONTROL_H
|
||||
#define MPLAYER_CONTROL_H
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
/*********************************************
|
||||
// Extended control used with arguments that operates on only one
|
||||
// channel at the time
|
||||
*/
|
||||
typedef struct af_control_ext_s{
|
||||
void* arg; // Argument
|
||||
int ch; // Chanel number
|
||||
}af_control_ext_t;
|
||||
|
||||
/*********************************************
|
||||
// Control parameters
|
||||
*/
|
||||
|
||||
/* The control system is divided into 3 levels
|
||||
mandatory calls - all filters must answer to all of these
|
||||
optional calls - are optional
|
||||
filter specific calls - applies only to some filters
|
||||
*/
|
||||
|
||||
#define AF_CONTROL_MANDATORY 0x10000000
|
||||
#define AF_CONTROL_OPTIONAL 0x20000000
|
||||
#define AF_CONTROL_FILTER_SPECIFIC 0x40000000
|
||||
|
||||
// MANDATORY CALLS
|
||||
|
||||
/* Reinitialize filter. The optional argument contains the new
|
||||
configuration in form of a struct mp_audio struct. If the filter does not
|
||||
support the new format the struct should be changed and AF_FALSE
|
||||
should be returned. If the incoming and outgoing data streams are
|
||||
identical the filter can return AF_DETACH. This will remove the
|
||||
filter. */
|
||||
#define AF_CONTROL_REINIT 0x00000100 | AF_CONTROL_MANDATORY
|
||||
|
||||
// OPTIONAL CALLS
|
||||
|
||||
/* Commandline parameters. If there were any commandline parameters
|
||||
for this specific filter, they will be given as a char* in the
|
||||
argument */
|
||||
#define AF_CONTROL_COMMAND_LINE 0x00000300 | AF_CONTROL_OPTIONAL
|
||||
|
||||
|
||||
// FILTER SPECIFIC CALLS
|
||||
|
||||
// Basic operations: These can be ored with any of the below calls
|
||||
// Set argument
|
||||
#define AF_CONTROL_SET 0x00000000
|
||||
// Get argument
|
||||
#define AF_CONTROL_GET 0x00000001
|
||||
|
||||
// Resample
|
||||
|
||||
// Set output rate in resample
|
||||
#define AF_CONTROL_RESAMPLE_RATE 0x00000100 | AF_CONTROL_FILTER_SPECIFIC
|
||||
|
||||
// Format
|
||||
|
||||
#define AF_CONTROL_FORMAT_FMT 0x00000400 | AF_CONTROL_FILTER_SPECIFIC
|
||||
|
||||
// Channels
|
||||
|
||||
// Set number of output channels in channels
|
||||
#define AF_CONTROL_CHANNELS 0x00000600 | AF_CONTROL_FILTER_SPECIFIC
|
||||
|
||||
// Volume
|
||||
|
||||
// Set volume level, arg is a float* with the volume for all the channels
|
||||
#define AF_CONTROL_VOLUME_LEVEL 0x00000D00 | AF_CONTROL_FILTER_SPECIFIC
|
||||
|
||||
// Pan
|
||||
|
||||
// Pan levels, arg is a control_ext with a float*
|
||||
#define AF_CONTROL_PAN_LEVEL 0x00001A00 | AF_CONTROL_FILTER_SPECIFIC
|
||||
|
||||
// Number of outputs from pan, arg is int*
|
||||
#define AF_CONTROL_PAN_NOUT 0x00001B00 | AF_CONTROL_FILTER_SPECIFIC
|
||||
|
||||
// Balance, arg is float*; range -1 (left) to 1 (right), 0 center
|
||||
#define AF_CONTROL_PAN_BALANCE 0x00001C00 | AF_CONTROL_FILTER_SPECIFIC
|
||||
|
||||
|
||||
// Delay length in ms, arg is a control_ext with a float*
|
||||
#define AF_CONTROL_DELAY_LEN 0x00001E00 | AF_CONTROL_FILTER_SPECIFIC
|
||||
|
||||
|
||||
// Subwoofer
|
||||
|
||||
// Channel number which to insert the filtered data, arg in int*
|
||||
#define AF_CONTROL_SUB_CH 0x00001F00 | AF_CONTROL_FILTER_SPECIFIC
|
||||
|
||||
// Cutoff frequency [Hz] for lowpass filter, arg is float*
|
||||
#define AF_CONTROL_SUB_FC 0x00002000 | AF_CONTROL_FILTER_SPECIFIC
|
||||
|
||||
|
||||
// Export
|
||||
#define AF_CONTROL_EXPORT_SZ 0x00003000 | AF_CONTROL_FILTER_SPECIFIC
|
||||
|
||||
// Channel number which to inster the filtered data, arg in int*
|
||||
#define AF_CONTROL_CENTER_CH 0x00003200 | AF_CONTROL_FILTER_SPECIFIC
|
||||
|
||||
|
||||
#define AF_CONTROL_PLAYBACK_SPEED 0x00003500 | AF_CONTROL_FILTER_SPECIFIC
|
||||
#define AF_CONTROL_SCALETEMPO_AMOUNT 0x00003600 | AF_CONTROL_FILTER_SPECIFIC
|
||||
|
||||
#endif /* MPLAYER_CONTROL_H */
|
@ -72,8 +72,7 @@ static void checkvolume(struct mixer *mixer)
|
||||
ao_control_vol_t vol = {mixer->vol_l, mixer->vol_r};
|
||||
if (mixer->softvol) {
|
||||
float gain;
|
||||
if (!af_control_any_rev(mixer->af,
|
||||
AF_CONTROL_VOLUME_LEVEL | AF_CONTROL_GET, &gain))
|
||||
if (!af_control_any_rev(mixer->af, AF_CONTROL_GET_VOLUME, &gain))
|
||||
gain = 1.0;
|
||||
vol.left = (gain / (mixer->opts->softvol_max / 100.0)) * 100.0;
|
||||
vol.right = (gain / (mixer->opts->softvol_max / 100.0)) * 100.0;
|
||||
@ -119,15 +118,10 @@ static void setvolume_internal(struct mixer *mixer, float l, float r)
|
||||
return;
|
||||
}
|
||||
float gain = (l + r) / 2.0 / 100.0 * mixer->opts->softvol_max / 100.0;
|
||||
if (!af_control_any_rev(mixer->af,
|
||||
AF_CONTROL_VOLUME_LEVEL | AF_CONTROL_SET,
|
||||
&gain))
|
||||
{
|
||||
if (!af_control_any_rev(mixer->af, AF_CONTROL_SET_VOLUME, &gain)) {
|
||||
mp_tmsg(MSGT_GLOBAL, MSGL_V, "[Mixer] Inserting volume filter.\n");
|
||||
if (!(af_add(mixer->af, "volume", NULL)
|
||||
&& af_control_any_rev(mixer->af,
|
||||
AF_CONTROL_VOLUME_LEVEL | AF_CONTROL_SET,
|
||||
&gain)))
|
||||
&& af_control_any_rev(mixer->af, AF_CONTROL_SET_VOLUME, &gain)))
|
||||
mp_tmsg(MSGT_GLOBAL, MSGL_ERR,
|
||||
"[Mixer] No volume control available.\n");
|
||||
}
|
||||
@ -197,9 +191,7 @@ void mixer_decvolume(struct mixer *mixer)
|
||||
void mixer_getbalance(struct mixer *mixer, float *val)
|
||||
{
|
||||
if (mixer->af)
|
||||
af_control_any_rev(mixer->af,
|
||||
AF_CONTROL_PAN_BALANCE | AF_CONTROL_GET,
|
||||
&mixer->balance);
|
||||
af_control_any_rev(mixer->af, AF_CONTROL_GET_PAN_BALANCE, &mixer->balance);
|
||||
*val = mixer->balance;
|
||||
}
|
||||
|
||||
@ -226,8 +218,7 @@ void mixer_setbalance(struct mixer *mixer, float val)
|
||||
if (!mixer->af)
|
||||
return;
|
||||
|
||||
if (af_control_any_rev(mixer->af,
|
||||
AF_CONTROL_PAN_BALANCE | AF_CONTROL_SET, &val))
|
||||
if (af_control_any_rev(mixer->af, AF_CONTROL_SET_PAN_BALANCE, &val))
|
||||
return;
|
||||
|
||||
if (val == 0 || mixer->ao->channels.num < 2)
|
||||
@ -244,14 +235,12 @@ void mixer_setbalance(struct mixer *mixer, float val)
|
||||
for (i = 2; i < AF_NCH; i++) {
|
||||
arg_ext.ch = i;
|
||||
level[i] = 1.f;
|
||||
af_pan_balance->control(af_pan_balance,
|
||||
AF_CONTROL_PAN_LEVEL | AF_CONTROL_SET,
|
||||
af_pan_balance->control(af_pan_balance, AF_CONTROL_SET_PAN_LEVEL,
|
||||
&arg_ext);
|
||||
level[i] = 0.f;
|
||||
}
|
||||
|
||||
af_pan_balance->control(af_pan_balance,
|
||||
AF_CONTROL_PAN_BALANCE | AF_CONTROL_SET, &val);
|
||||
af_pan_balance->control(af_pan_balance, AF_CONTROL_SET_PAN_BALANCE, &val);
|
||||
}
|
||||
|
||||
char *mixer_get_volume_restore_data(struct mixer *mixer)
|
||||
|
@ -52,8 +52,7 @@ static int build_afilter_chain(struct MPContext *mpctx)
|
||||
mp_audio_buffer_get_format(mpctx->sh_audio->decode_buffer, &in_format);
|
||||
|
||||
int new_srate;
|
||||
if (af_control_any_rev(sh_audio->afilter,
|
||||
AF_CONTROL_PLAYBACK_SPEED | AF_CONTROL_SET,
|
||||
if (af_control_any_rev(sh_audio->afilter, AF_CONTROL_SET_PLAYBACK_SPEED,
|
||||
&opts->playback_speed))
|
||||
new_srate = in_format.rate;
|
||||
else {
|
||||
|
Loading…
Reference in New Issue
Block a user