diff options
-rw-r--r-- | DOCS/interface-changes.rst | 3 | ||||
-rw-r--r-- | DOCS/man/input.rst | 23 | ||||
-rw-r--r-- | audio/mixer.c | 1 | ||||
-rw-r--r-- | player/command.c | 22 |
4 files changed, 42 insertions, 7 deletions
diff --git a/DOCS/interface-changes.rst b/DOCS/interface-changes.rst index bc6a9fd53f..5b9b45faeb 100644 --- a/DOCS/interface-changes.rst +++ b/DOCS/interface-changes.rst @@ -29,6 +29,9 @@ Interface changes instead of "sample" - change VO opengl scaler-resizes-only default to enabled - add VO opengl "tscale-interpolates-only" suboption + - make "volume" and "mute" properties changeable even if no audio output is + active (this gives not-ideal behavior if --softvol=no is used) + - add "volume-max" and "mixer-active" properties --- mpv 0.15.0 --- - change "yadif" video filter defaults --- mpv 0.14.0 --- diff --git a/DOCS/man/input.rst b/DOCS/man/input.rst index c847b861b0..76678c2b3c 100644 --- a/DOCS/man/input.rst +++ b/DOCS/man/input.rst @@ -1224,11 +1224,30 @@ Property list ``hr-seek`` (RW) See ``--hr-seek``. +``mixer-active`` + Return ``yes`` if the audio mixer is active, ``no`` otherwise. This has + implications for ``--softvol=no`` mode: if the mixer is active, changing + ``volume`` doesn't actually change anything on the system mixer. If the + ``--volume`` or ``--mute`` option are used, these might not be applied + property until the mixer becomes active either. (The options, if set, will + just overwrite the mixer state at audio initialization.) + + While the behavior with ``mixer-active==yes`` is relatively well-defined, + the ``no`` case will provide possibly wrong or insignificant values. + + Note that an active mixer does not necessarily imply active audio output, + although this is implied in the current implementation. + ``volume`` (RW) - Current volume (see ``--volume`` for details). + Current volume (see ``--volume`` for details). Also see ``mixer-active`` + property. + +``volume-max`` + Current maximum value the volume property can be set to. (This may depend + on the ``--softvol-max`` option.) ``mute`` (RW) - Current mute status (``yes``/``no``). + Current mute status (``yes``/``no``). Also see ``mixer-active`` property. ``audio-delay`` (RW) See ``--audio-delay``. diff --git a/audio/mixer.c b/audio/mixer.c index 5f147872ab..01bb4d5088 100644 --- a/audio/mixer.c +++ b/audio/mixer.c @@ -399,4 +399,5 @@ void mixer_uninit_audio(struct mixer *mixer) } mixer->ao = NULL; mixer->af = NULL; + mixer->softvol = false; } diff --git a/player/command.c b/player/command.c index d5cccd2474..848905da32 100644 --- a/player/command.c +++ b/player/command.c @@ -1538,13 +1538,18 @@ static int mp_property_partially_seekable(void *ctx, struct m_property *prop, return m_property_flag_ro(action, arg, mpctx->demuxer->partially_seekable); } +static int mp_property_mixer_active(void *ctx, struct m_property *prop, + int action, void *arg) +{ + MPContext *mpctx = ctx; + return m_property_flag_ro(action, arg, mixer_audio_initialized(mpctx->mixer)); +} + /// Volume (RW) static int mp_property_volume(void *ctx, struct m_property *prop, int action, void *arg) { MPContext *mpctx = ctx; - if (!mixer_audio_initialized(mpctx->mixer)) - return M_PROPERTY_UNAVAILABLE; switch (action) { case M_PROPERTY_GET: mixer_getbothvolume(mpctx->mixer, arg); @@ -1578,13 +1583,18 @@ static int mp_property_volume(void *ctx, struct m_property *prop, return M_PROPERTY_NOT_IMPLEMENTED; } +static int mp_property_volume_max(void *ctx, struct m_property *prop, + int action, void *arg) +{ + MPContext *mpctx = ctx; + return m_property_float_ro(action, arg, mixer_getmaxvolume(mpctx->mixer)); +} + /// Mute (RW) static int mp_property_mute(void *ctx, struct m_property *prop, int action, void *arg) { MPContext *mpctx = ctx; - if (!mixer_audio_initialized(mpctx->mixer)) - return M_PROPERTY_ERROR; switch (action) { case M_PROPERTY_SET: mixer_setmute(mpctx->mixer, *(int *) arg); @@ -3553,7 +3563,9 @@ static const struct m_property mp_properties[] = { M_PROPERTY_ALIAS("playlist-count", "playlist/count"), // Audio + {"mixer-active", mp_property_mixer_active}, {"volume", mp_property_volume}, + {"volume-max", mp_property_volume_max}, {"mute", mp_property_mute}, {"audio-delay", mp_property_audio_delay}, {"audio-codec-name", mp_property_audio_codec_name}, @@ -3734,7 +3746,7 @@ static const char *const *const mp_event_property_change[] = { E(MPV_EVENT_AUDIO_RECONFIG, "audio-format", "audio-codec", "audio-bitrate", "samplerate", "channels", "audio", "volume", "mute", "balance", "volume-restore-data", "current-ao", "audio-codec-name", "audio-params", - "audio-out-params"), + "audio-out-params", "volume-max", "mixer-active"), E(MPV_EVENT_SEEK, "seeking", "core-idle", "eof-reached"), E(MPV_EVENT_PLAYBACK_RESTART, "seeking", "core-idle", "eof-reached"), E(MPV_EVENT_METADATA_UPDATE, "metadata", "filtered-metadata", "media-title"), |