Skip to content

Commit 7621a02

Browse files
author
wm4
committed
shitmess
1 parent 99d9921 commit 7621a02

File tree

7 files changed

+80
-43
lines changed

7 files changed

+80
-43
lines changed

DOCS/interface-changes.rst

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,17 @@ Interface changes
2020
::
2121

2222
--- mpv 0.18.2 ---
23+
- partially re-add --softvol=auto capability:
24+
- rename --softvol to --user-volume-mode and undeprecate it
25+
- implement selecting the "correct" volume control with the newly added
26+
user-volume property
27+
- change default key bindings to control user-volume instead of volume
28+
(you will have to do the same with custom bindings)
29+
- all of the above should restore most of PulseAudio behavior
2330
- deprecate "balance" option/property (no replacement)
2431
--- mpv 0.18.1 ---
2532
- deprecate --heartbeat-cmd
26-
- remove --softvol=no capability:
33+
- remove --softvol=no/--softvol=auto capability:
2734
- deprecate --softvol, it now does nothing
2835
- --volume, --mute, and the corresponding properties now always control
2936
softvol, and behave as expected without surprises (e.g. you can set

DOCS/man/input.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1242,6 +1242,9 @@ Property list
12421242
``volume`` (RW)
12431243
Current volume (see ``--volume`` for details).
12441244

1245+
See also ``user-volume``, in particular if you are interested in pre-
1246+
mpv 0.18.1 behavior.
1247+
12451248
``volume-max`` (RW)
12461249
Current maximum value the volume property can be set to. (Equivalent to the
12471250
``--volume-max`` option.)
@@ -1260,6 +1263,15 @@ Property list
12601263
Similar to ``ao-volume``, but controls the mute state. May be unimplemented
12611264
even if ``ao-volume`` works.
12621265

1266+
``user-volume`` (RW)
1267+
This switches between the ``ao-volume`` or ``volume`` properties, depending
1268+
on the ``--user-volume-mode`` option.
1269+
1270+
In particular, this property is unavailable if the audio chain is not active
1271+
(such as when playing a file without audio, or in idle mode).
1272+
1273+
There is no such property for the mute control.
1274+
12631275
``audio-delay`` (RW)
12641276
See ``--audio-delay``.
12651277

DOCS/man/options.rst

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,23 +1091,32 @@ Audio
10911091
``--no-audio``
10921092
Do not play sound.
10931093

1094-
``--mute=<auto|yes|no>``
1095-
Set startup audio mute status. ``auto`` (default) will not change the mute
1096-
status.
1094+
``--mute=<yes|no|auto>``
1095+
Set startup audio mute status (default: no).
1096+
1097+
``auto`` is a deprecated alias for ``no`` (before mpv 0.18.1 the situation
1098+
was different).
10971099

10981100
See also: ``--volume``.
10991101

1100-
``--softvol=<no|yes|auto>``
1101-
Deprecated/unfunctional. Before mpv 0.18.1, this used to control whether
1102-
to use the volume controls of the audio output driver or the internal mpv
1103-
volume filter.
1102+
``--user-volume-mode=<no|yes|auto>``, ``--softvol=<...>``
1103+
Decides what the ``user-volume`` property controls (default: auto).
11041104

1105-
The current behavior is as if this option was set to ``yes``. The other
1106-
behaviors are not available anymore, although ``auto`` almost matches
1107-
current behavior in most cases.
1105+
:no: ``user-volume`` redirects to ``ao-volume`` (i.e. always changes
1106+
the audio API's volume control)
1107+
:yes: ``user-volume`` redirects to ``volume`` (i.e. always changes the
1108+
internal mixer)
1109+
:auto: control ``ao-volume`` if the audio API does per-application
1110+
audio control (like wasapi and PulseAudio), otherwise ``volume``
11081111

1109-
The ``no`` behavior is still partially available through the ``ao-volume``
1110-
and ``ao-mute`` properties. But there are no options to reset these.
1112+
``--softvol`` is a deprecated alias - it some situation it will appear to do
1113+
roughly the same as before mpv 0.18.1, while in others the different
1114+
implementation becomes apparent.
1115+
1116+
This is the behavior since mpv 0.18.2. In mpv 0.18.1, this option was
1117+
deprecated and did nothing. Before mpv 0.18.1, this used to control whether
1118+
to use the volume controls of the audio output driver or the internal mpv
1119+
volume filter.
11111120

11121121
``--audio-demuxer=<[+]name>``
11131122
Use this audio demuxer type when using ``--audio-file``. Use a '+' before
@@ -1289,18 +1298,6 @@ Audio
12891298
if you want to force a different audio profile (e.g. with PulseAudio),
12901299
or to set your own application name when using libmpv.
12911300

1292-
``--volume-restore-data=<string>``
1293-
Used internally for use by playback resume (e.g. with ``quit-watch-later``).
1294-
Restoring value has to be done carefully, because different AOs as well as
1295-
softvol can have different value ranges, and we don't want to restore
1296-
volume if setting the volume changes it system wide. The normal options
1297-
(like ``--volume``) would always set the volume. This option was added for
1298-
restoring volume in a safer way (by storing the method used to set the
1299-
volume), and is not generally useful. Its semantics are considered private
1300-
to mpv.
1301-
1302-
Do not use.
1303-
13041301
``--audio-buffer=<seconds>``
13051302
Set the audio output minimum buffer. The audio device might actually create
13061303
a larger buffer if it pleases. If the device creates a smaller buffer,

etc/input.conf

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333
#MOUSE_BTN2 cycle pause # toggle pause on/off
3434
#MOUSE_BTN3 seek 10
3535
#MOUSE_BTN4 seek -10
36-
#MOUSE_BTN5 add volume -2
37-
#MOUSE_BTN6 add volume 2
36+
#MOUSE_BTN5 add user-volume -2
37+
#MOUSE_BTN6 add user-volume 2
3838

3939
# Mouse wheels, touchpad or other input devices that have axes
4040
# if the input devices supports precise scrolling it will also scale the
@@ -87,10 +87,10 @@
8787
#x add sub-delay +0.1 # add
8888
#ctrl++ add audio-delay 0.100 # this changes audio/video sync
8989
#ctrl+- add audio-delay -0.100
90-
#9 add volume -2
91-
#/ add volume -2
92-
#0 add volume 2
93-
#* add volume 2
90+
#9 add user-volume -2
91+
#/ add user-volume -2
92+
#0 add user-volume 2
93+
#* add user-volume 2
9494
#m cycle mute
9595
#1 add contrast -1
9696
#2 add contrast 1
@@ -136,8 +136,8 @@
136136
#REWIND seek -60
137137
#NEXT playlist-next
138138
#PREV playlist-prev
139-
#VOLUME_UP add volume 2
140-
#VOLUME_DOWN add volume -2
139+
#VOLUME_UP add user-volume 2
140+
#VOLUME_DOWN add user-volume -2
141141
#MUTE cycle mute
142142
#CLOSE_WIN quit
143143
#CLOSE_WIN {encode} quit 4
@@ -157,9 +157,9 @@
157157
#AR_PREV_HOLD seek -120
158158
#AR_MENU show-progress
159159
#AR_MENU_HOLD cycle mute
160-
#AR_VUP add volume 2
160+
#AR_VUP add user-volume 2
161161
#AR_VUP_HOLD add chapter 1
162-
#AR_VDOWN add volume -2
162+
#AR_VDOWN add user-volume -2
163163
#AR_VDOWN_HOLD add chapter -1
164164

165165
# For tv://

options/options.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ const m_option_t mp_opts[] = {
406406

407407
OPT_FLAG("window-dragging", allow_win_drag, CONF_GLOBAL),
408408

409-
OPT_CHOICE("softvol", softvol, 0,
409+
OPT_CHOICE("user-volume-mode", softvol, 0,
410410
({"no", SOFTVOL_NO},
411411
{"yes", SOFTVOL_YES},
412412
{"auto", SOFTVOL_AUTO})),
@@ -687,6 +687,7 @@ const m_option_t mp_opts[] = {
687687
OPT_REPLACED("media-title", "force-media-title"),
688688
OPT_REPLACED("input-unix-socket", "input-ipc-server"),
689689
OPT_REPLACED("softvol-max", "volume-max"),
690+
OPT_REPLACED("softvol", "user-volume-mode"),
690691

691692
{0}
692693
};

player/audio.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,9 +194,6 @@ static int recreate_audio_filters(struct MPContext *mpctx)
194194
if (afs->initialized < 1 && af_init(afs) < 0)
195195
goto fail;
196196

197-
if (mpctx->opts->softvol == SOFTVOL_NO)
198-
MP_ERR(mpctx, "--softvol=no is not supported anymore.\n");
199-
200197
audio_update_volume(mpctx);
201198
audio_update_balance(mpctx);
202199

player/command.c

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1617,7 +1617,7 @@ static int mp_property_ao_volume(void *ctx, struct m_property *prop,
16171617
MPContext *mpctx = ctx;
16181618
struct ao *ao = mpctx->ao;
16191619
if (!ao)
1620-
return M_PROPERTY_NOT_IMPLEMENTED;
1620+
return M_PROPERTY_UNAVAILABLE;
16211621

16221622
switch (action) {
16231623
case M_PROPERTY_SET: {
@@ -1660,7 +1660,7 @@ static int mp_property_ao_mute(void *ctx, struct m_property *prop,
16601660
MPContext *mpctx = ctx;
16611661
struct ao *ao = mpctx->ao;
16621662
if (!ao)
1663-
return M_PROPERTY_NOT_IMPLEMENTED;
1663+
return M_PROPERTY_UNAVAILABLE;
16641664

16651665
switch (action) {
16661666
case M_PROPERTY_SET: {
@@ -1683,6 +1683,25 @@ static int mp_property_ao_mute(void *ctx, struct m_property *prop,
16831683
return M_PROPERTY_NOT_IMPLEMENTED;
16841684
}
16851685

1686+
static int mp_property_user_volume(void *ctx, struct m_property *prop,
1687+
int action, void *arg)
1688+
{
1689+
MPContext *mpctx = ctx;
1690+
struct ao *ao = mpctx->ao;
1691+
if (!ao)
1692+
return M_PROPERTY_UNAVAILABLE;
1693+
1694+
bool softvol;
1695+
switch (mpctx->opts->softvol) {
1696+
case SOFTVOL_NO: softvol = false; break;
1697+
case SOFTVOL_YES: softvol = true; break;
1698+
default:
1699+
softvol = ao_control(ao, AOCONTROL_HAS_PER_APP_VOLUME, NULL) != CONTROL_OK;
1700+
}
1701+
1702+
return mp_property_do(softvol ? "volume" : "ao-volume", action, arg, ctx);
1703+
}
1704+
16861705
static int get_device_entry(int item, int action, void *arg, void *ctx)
16871706
{
16881707
struct ao_device_list *list = ctx;
@@ -3702,6 +3721,7 @@ static const struct m_property mp_properties[] = {
37023721
{"mute", mp_property_mute},
37033722
{"ao-volume", mp_property_ao_volume},
37043723
{"ao-mute", mp_property_ao_mute},
3724+
{"user-volume", mp_property_user_volume},
37053725
{"audio-delay", mp_property_audio_delay},
37063726
{"audio-codec-name", mp_property_audio_codec_name},
37073727
{"audio-codec", mp_property_audio_codec},
@@ -3888,7 +3908,7 @@ static const char *const *const mp_event_property_change[] = {
38883908
"colormatrix-output-range", "colormatrix-primaries", "video-aspect"),
38893909
E(MPV_EVENT_AUDIO_RECONFIG, "audio-format", "audio-codec", "audio-bitrate",
38903910
"samplerate", "channels", "audio", "volume", "mute", "balance",
3891-
"current-ao", "audio-codec-name", "audio-params",
3911+
"current-ao", "audio-codec-name", "audio-params", "user-volume",
38923912
"audio-out-params", "volume-max", "mixer-active"),
38933913
E(MPV_EVENT_SEEK, "seeking", "core-idle", "eof-reached"),
38943914
E(MPV_EVENT_PLAYBACK_RESTART, "seeking", "core-idle", "eof-reached"),
@@ -4050,11 +4070,14 @@ static const struct property_osd_display {
40504070
{ "clock", "Clock" },
40514071
// audio
40524072
{ "volume", "Volume",
4053-
.msg = "Volume: ${?volume:${volume}% ${?mute==yes:(Muted)}}${!volume:${volume}}",
4073+
.msg = "Internal volume: ${?volume:${volume}% ${?mute==yes:(Muted)}}${!volume:${volume}}",
40544074
.osd_progbar = OSD_VOLUME },
40554075
{ "ao-volume", "AO Volume",
40564076
.msg = "AO Volume: ${?ao-volume:${ao-volume}% ${?ao-mute==yes:(Muted)}}${!ao-volume:${ao-volume}}",
40574077
.osd_progbar = OSD_VOLUME },
4078+
{ "user-volume", "Volume",
4079+
.msg = "Volume: ${?user-volume:${user-volume}% ${?mute==yes:(Muted)}}${!user-volume:${user-volume}}",
4080+
.osd_progbar = OSD_VOLUME },
40584081
{ "mute", "Mute" },
40594082
{ "ao-mute", "AO Mute" },
40604083
{ "audio-delay", "A-V delay" },

0 commit comments

Comments
 (0)