summaryrefslogtreecommitdiffstats
path: root/mpvcore
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-09-19 14:32:47 +0200
committerwm4 <wm4@nowhere>2013-09-20 13:23:25 +0200
commitb8e42ae13c511855fcba0b6b795d55b37e461665 (patch)
treef7090d8218894692ac600da6e7d6e62c382d1731 /mpvcore
parent234d967bed3784657279052e23fdfa751ae1e7fc (diff)
downloadmpv-b8e42ae13c511855fcba0b6b795d55b37e461665.tar.bz2
mpv-b8e42ae13c511855fcba0b6b795d55b37e461665.tar.xz
mixer: restore volume with playback resume
Note that this is intentionally never done if the AO or softvolume is different, or if the current volume control method is thought to control system wide volume (such as ALSA) or otherwise user controllable (such as PulseAudio). The intention is to keep things robust and to avoid messing with the user's audio settings as far as possible, while still providing the ability to resume volume if it makes sense.
Diffstat (limited to 'mpvcore')
-rw-r--r--mpvcore/command.c16
-rw-r--r--mpvcore/mplayer.c3
-rw-r--r--mpvcore/options.c1
-rw-r--r--mpvcore/options.h1
4 files changed, 19 insertions, 2 deletions
diff --git a/mpvcore/command.c b/mpvcore/command.c
index dedac9dc10..ea71b9e082 100644
--- a/mpvcore/command.c
+++ b/mpvcore/command.c
@@ -804,6 +804,21 @@ static int mp_property_mute(m_option_t *prop, int action, void *arg,
return M_PROPERTY_NOT_IMPLEMENTED;
}
+static int mp_property_volrestore(m_option_t *prop, int action,
+ void *arg, MPContext *mpctx)
+{
+ switch (action) {
+ case M_PROPERTY_GET: {
+ char *s = mixer_get_volume_restore_data(&mpctx->mixer);
+ *(char **)arg = s;
+ return s ? M_PROPERTY_OK : M_PROPERTY_UNAVAILABLE;
+ }
+ case M_PROPERTY_SET:
+ return M_PROPERTY_NOT_IMPLEMENTED;
+ }
+ return mp_property_generic_option(prop, action, arg, mpctx);
+}
+
/// Audio delay (RW)
static int mp_property_audio_delay(m_option_t *prop, int action,
void *arg, MPContext *mpctx)
@@ -1806,6 +1821,7 @@ static const m_option_t mp_properties[] = {
M_OPTION_PROPERTY_CUSTOM("aid", mp_property_audio),
{ "balance", mp_property_balance, CONF_TYPE_FLOAT,
M_OPT_RANGE, -1, 1, NULL },
+ M_OPTION_PROPERTY_CUSTOM("volume-restore-data", mp_property_volrestore),
// Video
M_OPTION_PROPERTY_CUSTOM("fullscreen", mp_property_fullscreen),
diff --git a/mpvcore/mplayer.c b/mpvcore/mplayer.c
index fafb88d022..00229364e6 100644
--- a/mpvcore/mplayer.c
+++ b/mpvcore/mplayer.c
@@ -809,8 +809,7 @@ static const char *backup_properties[] = {
"speed",
"edition",
"pause",
- //"volume",
- //"mute",
+ "volume-restore-data",
"audio-delay",
//"balance",
"fullscreen",
diff --git a/mpvcore/options.c b/mpvcore/options.c
index a09a28856f..e3b3137aed 100644
--- a/mpvcore/options.c
+++ b/mpvcore/options.c
@@ -565,6 +565,7 @@ const m_option_t mp_opts[] = {
({"auto", -1},
{"no", 0},
{"yes", 1}, {"", 1})),
+ OPT_STRING("volume-restore-data", mixer_restore_volume_data, 0),
OPT_FLAG("gapless-audio", gapless_audio, 0),
// set screen dimensions (when not detectable or virtual!=visible)
diff --git a/mpvcore/options.h b/mpvcore/options.h
index 67074de241..d425d0789b 100644
--- a/mpvcore/options.h
+++ b/mpvcore/options.h
@@ -51,6 +51,7 @@ typedef struct MPOpts {
int softvol;
float mixer_init_volume;
int mixer_init_mute;
+ char *mixer_restore_volume_data;
int volstep;
float softvol_max;
int gapless_audio;