From 5a0e71a972054f22ae5089228d981a59ae796326 Mon Sep 17 00:00:00 2001 From: Uoti Urpala Date: Fri, 28 Jan 2011 20:13:58 +0200 Subject: commands: improve playback speed property/commands Add a definition to show the playback speed property on screen, and change the separate commands (speed_mult etc) to use the property mechanism. Now 'set_property_osd speed' can show the value on OSD, and the separate commands respect the range limits of the option. --- command.c | 34 +++++++++++++++------------------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/command.c b/command.c index c00112114e..efe538f739 100644 --- a/command.c +++ b/command.c @@ -2398,6 +2398,7 @@ static struct property_osd_display { { "capturing", 0, -1, _("Capturing: %s") }, { "pts_association_mode", 0, -1, "PTS association mode: %s" }, { "hr_seek", 0, -1, "hr-seek: %s" }, + { "speed", 0, -1, _("Speed: x %6s") }, // audio { "volume", OSD_VOLUME, -1, _("Volume") }, { "mute", 0, -1, _("Mute: %s") }, @@ -2850,28 +2851,23 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd) break; case MP_CMD_SPEED_INCR:{ - float v = cmd->args[0].v.f; - opts->playback_speed += v; - reinit_audio_chain(mpctx); - set_osd_tmsg(OSD_MSG_SPEED, 1, osd_duration, "Speed: x %6.2f", - opts->playback_speed); - } break; + float v = cmd->args[0].v.f; + mp_property_do("speed", M_PROPERTY_STEP_UP, &v, mpctx); + show_property_osd(mpctx, "speed"); + break; + } - case MP_CMD_SPEED_MULT:{ - float v = cmd->args[0].v.f; - opts->playback_speed *= v; - reinit_audio_chain(mpctx); - set_osd_tmsg(OSD_MSG_SPEED, 1, osd_duration, "Speed: x %6.2f", - opts->playback_speed); - } break; + case MP_CMD_SPEED_MULT: + case_fallthrough_hack = true; case MP_CMD_SPEED_SET:{ - float v = cmd->args[0].v.f; - opts->playback_speed = v; - reinit_audio_chain(mpctx); - set_osd_tmsg(OSD_MSG_SPEED, 1, osd_duration, "Speed: x %6.2f", - opts->playback_speed); - } break; + float v = cmd->args[0].v.f; + if (case_fallthrough_hack) + v *= mpctx->opts.playback_speed; + mp_property_do("speed", M_PROPERTY_SET, &v, mpctx); + show_property_osd(mpctx, "speed"); + break; + } case MP_CMD_FRAME_STEP: add_step_frame(mpctx); -- cgit v1.2.3