[vlc-commits] cli: privatise playlist command handlers

Rémi Denis-Courmont git at videolan.org
Sat Oct 17 20:36:15 CEST 2020


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Oct 17 21:26:55 2020 +0300| [613db8a0e4b8b02626484696b7cbec07bd684a09] | committer: Rémi Denis-Courmont

cli: privatise playlist command handlers

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

 modules/control/cli/cli.c      | 18 ++----------
 modules/control/cli/cli.h      | 15 +---------
 modules/control/cli/playlist.c | 66 ++++++++++++++++++++++++++++++++----------
 3 files changed, 54 insertions(+), 45 deletions(-)

diff --git a/modules/control/cli/cli.c b/modules/control/cli/cli.c
index b14e651093..3355c98349 100644
--- a/modules/control/cli/cli.c
+++ b/modules/control/cli/cli.c
@@ -218,15 +218,6 @@ static void KeyAction(intf_thread_t *intf, const char *const *args, size_t n)
 
 static const struct cli_handler cmds[] =
 {
-    { "playlist", PlaylistList },
-    { "sort", PlaylistSort },
-    { "play", PlaylistPlay },
-    { "stop", PlaylistStop },
-    { "clear", PlaylistClear },
-    { "prev", PlaylistPrev },
-    { "next", PlaylistNext },
-    { "status", PlaylistStatus },
-
     { "longhelp", Help },
     { "h", Help },
     { "help", Help },
@@ -236,13 +227,6 @@ static const struct cli_handler cmds[] =
     { "quit", Quit },
 
     { "intf", Intf },
-    { "add", PlaylistAdd },
-    { "repeat", PlaylistRepeat },
-    { "loop", PlaylistLoop },
-    { "random", PlaylistRandom },
-    { "enqueue", PlaylistEnqueue },
-    { "goto", PlaylistGoto },
-
     { "key", KeyAction },
     { "hotkey", KeyAction },
 };
@@ -709,6 +693,8 @@ static int Activate( vlc_object_t *p_this )
     if (unlikely(p_sys->player_cli == NULL))
         goto error;
 
+    RegisterPlaylist(p_intf);
+
     if( vlc_clone( &p_sys->thread, Run, p_intf, VLC_THREAD_PRIORITY_LOW ) )
         goto error;
 
diff --git a/modules/control/cli/cli.h b/modules/control/cli/cli.h
index a48f54232d..8e70436dd7 100644
--- a/modules/control/cli/cli.h
+++ b/modules/control/cli/cli.h
@@ -61,17 +61,4 @@ void RegisterHandlers(intf_thread_t *intf, const struct cli_handler *handlers,
 void *RegisterPlayer(intf_thread_t *intf);
 void DeregisterPlayer(intf_thread_t *intf, void *);
 
-void PlaylistPrev(intf_thread_t *intf, const char *const *, size_t);
-void PlaylistNext(intf_thread_t *intf, const char *const *, size_t);
-void PlaylistPlay(intf_thread_t *intf, const char *const *, size_t);
-void PlaylistStop(intf_thread_t *intf, const char *const *, size_t);
-void PlaylistClear(intf_thread_t *intf, const char *const *, size_t);
-void PlaylistSort(intf_thread_t *intf, const char *const *, size_t);
-void PlaylistList(intf_thread_t *intf, const char *const *, size_t);
-void PlaylistStatus(intf_thread_t *intf, const char *const *, size_t);
-void PlaylistRepeat(intf_thread_t *intf, const char *const *, size_t);
-void PlaylistLoop(intf_thread_t *intf, const char *const *, size_t);
-void PlaylistRandom(intf_thread_t *intf, const char *const *, size_t);
-void PlaylistGoto(intf_thread_t *intf, const char *const *, size_t);
-void PlaylistAdd(intf_thread_t *intf, const char *const *, size_t);
-void PlaylistEnqueue(intf_thread_t *intf, const char *const *, size_t);
+void RegisterPlaylist(intf_thread_t *intf);
diff --git a/modules/control/cli/playlist.c b/modules/control/cli/playlist.c
index 120884cfcc..5097c7c4c5 100644
--- a/modules/control/cli/playlist.c
+++ b/modules/control/cli/playlist.c
@@ -172,19 +172,22 @@ static void PlaylistDoVoid(intf_thread_t *intf, int (*cb)(vlc_playlist_t *))
     vlc_playlist_Unlock(playlist);
 }
 
-void PlaylistPrev(intf_thread_t *intf, const char *const *args, size_t count)
+static void PlaylistPrev(intf_thread_t *intf, const char *const *args,
+                         size_t count)
 {
     PlaylistDoVoid(intf, vlc_playlist_Prev);
     (void) args; (void) count;
 }
 
-void PlaylistNext(intf_thread_t *intf, const char *const *args, size_t count)
+static void PlaylistNext(intf_thread_t *intf, const char *const *args,
+                         size_t count)
 {
     PlaylistDoVoid(intf, vlc_playlist_Next);
     (void) args; (void) count;
 }
 
-void PlaylistPlay(intf_thread_t *intf, const char *const *args, size_t count)
+static void PlaylistPlay(intf_thread_t *intf, const char *const *args,
+                         size_t count)
 {
     PlaylistDoVoid(intf, vlc_playlist_Start);
     (void) args; (void) count;
@@ -196,7 +199,8 @@ static int PlaylistDoStop(vlc_playlist_t *playlist)
     return 0;
 }
 
-void PlaylistStop(intf_thread_t *intf, const char *const *args, size_t count)
+static void PlaylistStop(intf_thread_t *intf, const char *const *args,
+                         size_t count)
 {
     PlaylistDoVoid(intf, PlaylistDoStop);
     (void) args; (void) count;
@@ -209,7 +213,8 @@ static int PlaylistDoClear(vlc_playlist_t *playlist)
     return 0;
 }
 
-void PlaylistClear(intf_thread_t *intf, const char *const *args, size_t count)
+static void PlaylistClear(intf_thread_t *intf, const char *const *args,
+                          size_t count)
 {
     PlaylistDoVoid(intf, PlaylistDoClear);
     (void) args; (void) count;
@@ -226,13 +231,15 @@ static int PlaylistDoSort(vlc_playlist_t *playlist)
     return vlc_playlist_Sort(playlist, &criteria, 1);
 }
 
-void PlaylistSort(intf_thread_t *intf, const char *const *args, size_t count)
+static void PlaylistSort(intf_thread_t *intf, const char *const *args,
+                         size_t count)
 {
     PlaylistDoVoid(intf, PlaylistDoSort);
     (void) args; (void) count;
 }
 
-void PlaylistList(intf_thread_t *intf, const char *const *args, size_t count)
+static void PlaylistList(intf_thread_t *intf, const char *const *args,
+                         size_t count)
 {
     vlc_playlist_t *playlist = intf->p_sys->playlist;
 
@@ -244,7 +251,8 @@ void PlaylistList(intf_thread_t *intf, const char *const *args, size_t count)
     (void) args; (void) count;
 }
 
-void PlaylistStatus(intf_thread_t *intf, const char *const *args, size_t count)
+static void PlaylistStatus(intf_thread_t *intf, const char *const *args,
+                           size_t count)
 {
     vlc_playlist_t *playlist = intf->p_sys->playlist;
     vlc_player_t *player = vlc_playlist_GetPlayer(playlist);
@@ -329,18 +337,21 @@ static void PlaylistRepeatCommon(intf_thread_t *intf, const char *const *args,
     vlc_playlist_Unlock(playlist);
 }
 
-void PlaylistRepeat(intf_thread_t *intf, const char *const *args, size_t count)
+static void PlaylistRepeat(intf_thread_t *intf, const char *const *args,
+                           size_t count)
 {
     PlaylistRepeatCommon(intf, args, count,
                          VLC_PLAYLIST_PLAYBACK_REPEAT_CURRENT);
 }
 
-void PlaylistLoop(intf_thread_t *intf, const char *const *args, size_t count)
+static void PlaylistLoop(intf_thread_t *intf, const char *const *args,
+                         size_t count)
 {
     PlaylistRepeatCommon(intf, args, count, VLC_PLAYLIST_PLAYBACK_REPEAT_ALL);
 }
 
-void PlaylistRandom(intf_thread_t *intf, const char *const *args, size_t count)
+static void PlaylistRandom(intf_thread_t *intf, const char *const *args,
+                           size_t count)
 {
     vlc_playlist_t *playlist = intf->p_sys->playlist;
 
@@ -369,7 +380,8 @@ void PlaylistRandom(intf_thread_t *intf, const char *const *args, size_t count)
     vlc_playlist_Unlock(playlist);
 }
 
-void PlaylistGoto(intf_thread_t *intf, const char *const *args, size_t n_args)
+static void PlaylistGoto(intf_thread_t *intf, const char *const *args,
+                         size_t n_args)
 {
     vlc_playlist_t *playlist = intf->p_sys->playlist;
     const char *arg = n_args > 1 ? args[1] : "";
@@ -465,13 +477,37 @@ static void PlaylistAddCommon(intf_thread_t *intf, const char *const *args,
     vlc_playlist_Unlock(playlist);
 }
 
-void PlaylistAdd(intf_thread_t *intf, const char *const *args, size_t count)
+static void PlaylistAdd(intf_thread_t *intf, const char *const *args,
+                        size_t count)
 {
     PlaylistAddCommon(intf, args, count, true);
 }
 
-void PlaylistEnqueue(intf_thread_t *intf, const char *const *args,
-                     size_t count)
+static void PlaylistEnqueue(intf_thread_t *intf, const char *const *args,
+                            size_t count)
 {
     PlaylistAddCommon(intf, args, count, false);
 }
+
+static const struct cli_handler cmds[] =
+{
+    { "playlist", PlaylistList },
+    { "sort", PlaylistSort },
+    { "play", PlaylistPlay },
+    { "stop", PlaylistStop },
+    { "clear", PlaylistClear },
+    { "prev", PlaylistPrev },
+    { "next", PlaylistNext },
+    { "status", PlaylistStatus },
+    { "add", PlaylistAdd },
+    { "repeat", PlaylistRepeat },
+    { "loop", PlaylistLoop },
+    { "random", PlaylistRandom },
+    { "enqueue", PlaylistEnqueue },
+    { "goto", PlaylistGoto },
+};
+
+void RegisterPlaylist(intf_thread_t *intf)
+{
+    RegisterHandlers(intf, cmds, ARRAY_SIZE(cmds));
+}



More information about the vlc-commits mailing list