summaryrefslogtreecommitdiffstats
path: root/player/command.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-08-10 18:40:16 +0200
committerwm4 <wm4@nowhere>2015-08-10 18:40:16 +0200
commitfedaad8250b9c9e262da3cda2114ccf5b62703a3 (patch)
treeffd35bcfbb0b50f828ecb7e78756478248311395 /player/command.c
parent3d1cc17ab27b98294f5710e69250e95347d84598 (diff)
downloadmpv-fedaad8250b9c9e262da3cda2114ccf5b62703a3.tar.bz2
mpv-fedaad8250b9c9e262da3cda2114ccf5b62703a3.tar.xz
player: separate controls for user and video controlled speed
For video sync, we want separate playback speed controls for user- requested speed and the "correction" speed for video timing. Further, we use this separation to make sure only a resampler is inserted if playback speed is only changed for video sync correction. As of this commit, this is basically inactive code. It's just preparation for the video sync code (the following commit).
Diffstat (limited to 'player/command.c')
-rw-r--r--player/command.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/player/command.c b/player/command.c
index c87d9378b7..486c7262b8 100644
--- a/player/command.c
+++ b/player/command.c
@@ -279,9 +279,8 @@ static int mp_property_playback_speed(void *ctx, struct m_property *prop,
double speed = mpctx->opts->playback_speed;
switch (action) {
case M_PROPERTY_SET: {
- double new_speed = *(double *)arg;
- if (speed != new_speed)
- set_playback_speed(mpctx, new_speed);
+ mpctx->opts->playback_speed = *(double *)arg;
+ update_playback_speed(mpctx);
return M_PROPERTY_OK;
}
case M_PROPERTY_PRINT:
@@ -291,6 +290,18 @@ static int mp_property_playback_speed(void *ctx, struct m_property *prop,
return mp_property_generic_option(mpctx, prop, action, arg);
}
+static int mp_property_av_speed_correction(void *ctx, struct m_property *prop,
+ int action, void *arg)
+{
+ MPContext *mpctx = ctx;
+ char *type = prop->priv;
+ switch (type[0]) {
+ case 'a': return m_property_double_ro(action, arg, mpctx->speed_factor_a);
+ case 'v': return m_property_double_ro(action, arg, mpctx->speed_factor_v);
+ }
+ abort();
+}
+
/// filename with path (RO)
static int mp_property_path(void *ctx, struct m_property *prop,
int action, void *arg)
@@ -639,7 +650,7 @@ static int mp_property_playtime_remaining(void *ctx, struct m_property *prop,
if (!time_remaining(mpctx, &remaining))
return M_PROPERTY_UNAVAILABLE;
- double speed = mpctx->opts->playback_speed;
+ double speed = mpctx->video_speed;
return property_time(action, arg, remaining / speed);
}
@@ -3305,6 +3316,8 @@ static const struct m_property mp_properties[] = {
{"loop", mp_property_generic_option},
{"loop-file", mp_property_generic_option},
{"speed", mp_property_playback_speed},
+ {"audio-speed-correction", mp_property_av_speed_correction, .priv = "a"},
+ {"video-speed-correction", mp_property_av_speed_correction, .priv = "v"},
{"filename", mp_property_filename},
{"stream-open-filename", mp_property_stream_open_filename},
{"file-size", mp_property_file_size},
@@ -3536,7 +3549,7 @@ static const char *const *const mp_event_property_change[] = {
E(MPV_EVENT_TICK, "time-pos", "stream-pos", "stream-time-pos", "avsync",
"percent-pos", "time-remaining", "playtime-remaining", "playback-time",
"estimated-vf-fps", "drop-frame-count", "vo-drop-frame-count",
- "total-avsync-change"),
+ "total-avsync-change", "audio-speed-correction", "video-speed-correction"),
E(MPV_EVENT_VIDEO_RECONFIG, "video-out-params", "video-params",
"video-format", "video-codec", "video-bitrate", "dwidth", "dheight",
"width", "height", "fps", "aspect", "vo-configured", "current-vo",