mirror of
https://github.com/mpv-player/mpv
synced 2024-08-24 07:21:49 +02:00
softvol, ao_pulse: prefer ao_pulse volume control by default
--softvol is enabled by default. For most audio outputs, this is a good thing, as they have either their own (bad) soft volume implementation, or control the system mixer. With ao_pulse, the situation is a bit different: it supports per-application volume (i.e. volume control is not really global). More importantly, ao_pulse uses a rather large audio buffer, and changing the volume with mplayer's volume filter has a large delay. With the native ao_pulse volume control, it's instant, because PulseAudio's audio filtering happens at a later stage in its processing pipeline (inaccessible for mplayer). This means native volume control should really be allowed for ao_pulse, while it's the reverse for other audio outputs. Make --softvol a choice option, and add a new "auto" choice. This is default and will use PA's volume control with ao_pulse, and mplayer's volume filter otherwise (i.e. the old softvol behavior).
This commit is contained in:
parent
c57883b71b
commit
425ac31a3b
@ -1741,9 +1741,19 @@
|
||||
timing is imprecise and you cannot use the RTC either. Comes at the
|
||||
price of higher CPU consumption.
|
||||
|
||||
--no-softvol
|
||||
Try to use the sound card mixer (if available), instead of using the volume
|
||||
audio filter.
|
||||
--softvol=<mode>
|
||||
Control whether to use the volume controls of the audio output driver, or
|
||||
the internal mplayer volume filter.
|
||||
|
||||
:no: prefer audio driver controls, use the volume filter only if
|
||||
absolutely needed
|
||||
:yes: always use the volume filter
|
||||
:auto: prefer the volume filter if the audio driver uses the system mixer (default)
|
||||
|
||||
The intention with ``auto`` is to avoid changing system mixer settings with
|
||||
default settings. mplayer is a video player, not a mixer panel. On the other
|
||||
hand, mixer controls should be used for sound servers like PulseAudio, which
|
||||
provide per-application volume.
|
||||
|
||||
--softvol-max=<10.0-10000.0>
|
||||
Set the maximum amplification level in percent (default: 200). A value of
|
||||
|
@ -587,7 +587,10 @@ const m_option_t mplayer_opts[]={
|
||||
|
||||
OPT_STRING("mixer", mixer_device, 0),
|
||||
OPT_STRING("mixer-channel", mixer_channel, 0),
|
||||
OPT_MAKE_FLAGS("softvol", softvol, 0),
|
||||
OPT_CHOICE("softvol", softvol, 0,
|
||||
({"no", SOFTVOL_NO},
|
||||
{"yes", SOFTVOL_YES},
|
||||
{"auto", SOFTVOL_AUTO})),
|
||||
OPT_FLOATRANGE("softvol-max", softvol_max, 0, 10, 10000),
|
||||
{"volstep", &volstep, CONF_TYPE_INT, CONF_RANGE, 0, 100, NULL},
|
||||
{"volume", &start_volume, CONF_TYPE_FLOAT, CONF_RANGE, -1, 10000, NULL},
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include "config.h"
|
||||
#include "defaultopts.h"
|
||||
#include "options.h"
|
||||
#include "mixer.h"
|
||||
|
||||
void set_default_mplayer_options(struct MPOpts *opts)
|
||||
{
|
||||
@ -10,7 +11,7 @@ void set_default_mplayer_options(struct MPOpts *opts)
|
||||
.audio_driver_list = NULL,
|
||||
.video_driver_list = NULL,
|
||||
.fixed_vo = 1,
|
||||
.softvol = 1,
|
||||
.softvol = SOFTVOL_AUTO,
|
||||
.softvol_max = 200,
|
||||
.ao_buffersize = -1,
|
||||
.vo_wintitle = "mplayer - ${filename}",
|
||||
|
@ -184,6 +184,8 @@ static int init(struct ao *ao, char *params)
|
||||
struct priv *priv = talloc_zero(ao, struct priv);
|
||||
ao->priv = priv;
|
||||
|
||||
ao->per_application_mixer = true;
|
||||
|
||||
if (params) {
|
||||
devarg = strdup(params);
|
||||
sink = strchr(devarg, ':');
|
||||
|
@ -104,6 +104,7 @@ struct ao {
|
||||
bool initialized;
|
||||
bool untimed;
|
||||
bool no_persistent_volume;
|
||||
bool per_application_mixer;
|
||||
const struct ao_driver *driver;
|
||||
void *priv;
|
||||
struct encode_lavc_context *encode_lavc_ctx;
|
||||
|
7
mixer.c
7
mixer.c
@ -32,10 +32,15 @@ static void checkvolume(struct mixer *mixer)
|
||||
if (!mixer->ao)
|
||||
return;
|
||||
|
||||
if (mixer->softvol == SOFTVOL_AUTO) {
|
||||
mixer->softvol = mixer->ao->per_application_mixer
|
||||
? SOFTVOL_NO : SOFTVOL_YES;
|
||||
}
|
||||
|
||||
ao_control_vol_t vol;
|
||||
if (mixer->softvol || CONTROL_OK != ao_control(mixer->ao,
|
||||
AOCONTROL_GET_VOLUME, &vol)) {
|
||||
mixer->softvol = true;
|
||||
mixer->softvol = SOFTVOL_YES;
|
||||
if (!mixer->afilter)
|
||||
return;
|
||||
float db_vals[AF_NCH];
|
||||
|
8
mixer.h
8
mixer.h
@ -24,11 +24,17 @@
|
||||
#include "libaf/af.h"
|
||||
#include "libao2/audio_out.h"
|
||||
|
||||
enum {
|
||||
SOFTVOL_NO = 0,
|
||||
SOFTVOL_YES = 1,
|
||||
SOFTVOL_AUTO = 2,
|
||||
};
|
||||
|
||||
typedef struct mixer {
|
||||
struct ao *ao;
|
||||
af_stream_t *afilter;
|
||||
int volstep;
|
||||
bool softvol;
|
||||
int softvol;
|
||||
float softvol_max;
|
||||
bool muted;
|
||||
bool muted_by_us;
|
||||
|
Loading…
Reference in New Issue
Block a user