[vlc-commits] cli: add "rate" command to get/set the rate

Rémi Denis-Courmont git at videolan.org
Sun Oct 18 12:24:06 CEST 2020


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Oct 18 12:55:20 2020 +0300| [e2920f0d9388be8db54152d913ceb7bc3a7e8c53] | committer: Rémi Denis-Courmont

cli: add "rate" command to get/set the rate

(Beware the locale decimal separator.)

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=e2920f0d9388be8db54152d913ceb7bc3a7e8c53
---

 modules/control/cli/player.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/modules/control/cli/player.c b/modules/control/cli/player.c
index ec3392863b..02f9760811 100644
--- a/modules/control/cli/player.c
+++ b/modules/control/cli/player.c
@@ -139,6 +139,22 @@ static void PlayerDoVoid(intf_thread_t *intf, void (*cb)(vlc_player_t *))
     vlc_player_Unlock(player);
 }
 
+static void PlayerDoFloat(intf_thread_t *intf, const char *const *args,
+                          size_t count,
+                          void (*setter)(vlc_player_t *, float),
+                          float (*getter)(vlc_player_t *))
+{
+    vlc_playlist_t *playlist = intf->p_sys->playlist;
+    vlc_player_t *player = vlc_playlist_GetPlayer(playlist);
+
+    vlc_player_Lock(player);
+    if (count < 2)
+        msg_print(intf, "%f", getter(player));
+    else
+        setter(player, atof(args[1]));
+    vlc_player_Unlock(player);
+}
+
 static void PlayerPause(intf_thread_t *intf, const char *const *args,
                         size_t count)
 {
@@ -211,6 +227,11 @@ static void PlayerNormal(intf_thread_t *intf, const char *const *args,
     (void) args; (void) count;
 }
 
+static void PlayerRate(intf_thread_t *intf, const char *const *args, size_t n)
+{
+    PlayerDoFloat(intf, args, n, vlc_player_ChangeRate, vlc_player_GetRate);
+}
+
 static void PlayerFrame(intf_thread_t *intf, const char *const *args,
                         size_t count)
 {
@@ -845,6 +866,7 @@ static const struct cli_handler cmds[] =
     { "faster", PlayerFaster },
     { "slower", PlayerSlower },
     { "normal", PlayerNormal },
+    { "rate", PlayerRate },
     { "frame", PlayerFrame },
     { "info", PlayerItemInfo },
     { "get_time", PlayerGetTime },



More information about the vlc-commits mailing list