[vlc-commits] cli: pass private data to command callbacks
Rémi Denis-Courmont
git at videolan.org
Sun Nov 29 14:55:46 CET 2020
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Nov 28 16:01:39 2020 +0200| [523c4e77c8f5236c77907320277337a222eac459] | committer: Rémi Denis-Courmont
cli: pass private data to command callbacks
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=523c4e77c8f5236c77907320277337a222eac459
---
modules/control/cli/cli.c | 21 ++++++++------
modules/control/cli/cli.h | 3 +-
modules/control/cli/player.c | 64 ++++++++++++++++++++++--------------------
modules/control/cli/playlist.c | 28 +++++++++---------
4 files changed, 62 insertions(+), 54 deletions(-)
diff --git a/modules/control/cli/cli.c b/modules/control/cli/cli.c
index 185ccdf089..dfab8127a7 100644
--- a/modules/control/cli/cli.c
+++ b/modules/control/cli/cli.c
@@ -160,7 +160,8 @@ void RegisterHandlers(intf_thread_t *intf, const struct cli_handler *handlers,
# include "../intromsg.h"
#endif
-static int Help( intf_thread_t *p_intf, const char *const *args, size_t count)
+static int Help(intf_thread_t *p_intf, const char *const *args, size_t count,
+ void *data)
{
msg_rc("%s", _("+----[ Remote control commands ]"));
msg_rc( "| ");
@@ -220,23 +221,26 @@ static int Help( intf_thread_t *p_intf, const char *const *args, size_t count)
msg_rc("%s", _("| quit . . . . . . . . . . . . . . . . . . . quit vlc"));
msg_rc( "| ");
msg_rc("%s", _("+----[ end of help ]"));
- (void) args; (void) count;
+ (void) args; (void) count; (void) data;
return 0;
}
-static int Intf(intf_thread_t *intf, const char *const *args, size_t count)
+static int Intf(intf_thread_t *intf, const char *const *args, size_t count,
+ void *data)
{
return intf_Create(vlc_object_instance(intf), count == 1 ? "" : args[1]);
}
-static int Quit(intf_thread_t *intf, const char *const *args, size_t count)
+static int Quit(intf_thread_t *intf, const char *const *args, size_t count,
+ void *data)
{
libvlc_Quit(vlc_object_instance(intf));
(void) args; (void) count;
return 0;
}
-static int LogOut(intf_thread_t *intf, const char *const *args, size_t count)
+static int LogOut(intf_thread_t *intf, const char *const *args, size_t count,
+ void *data)
{
intf_sys_t *sys = intf->p_sys;
@@ -274,7 +278,8 @@ static int LogOut(intf_thread_t *intf, const char *const *args, size_t count)
return 0;
}
-static int KeyAction(intf_thread_t *intf, const char *const *args, size_t n)
+static int KeyAction(intf_thread_t *intf, const char *const *args, size_t n,
+ void *data)
{
vlc_object_t *vlc = VLC_OBJECT(vlc_object_instance(intf));
@@ -363,7 +368,7 @@ error: wordfree(&we);
{
const struct command *c = *pp;;
- ret = c->handler.callback(intf, args, count);
+ ret = c->handler.callback(intf, args, count, c->data);
}
else
{
@@ -426,7 +431,7 @@ static void *Run(void *data)
else if (sys->pi_socket_listen == NULL)
break;
else
- LogOut(intf, NULL, 0);
+ LogOut(intf, NULL, 0, intf);
}
int canc = vlc_savecancel();
diff --git a/modules/control/cli/cli.h b/modules/control/cli/cli.h
index d526d3fd20..394396cc88 100644
--- a/modules/control/cli/cli.h
+++ b/modules/control/cli/cli.h
@@ -53,7 +53,8 @@ void msg_print(intf_thread_t *p_intf, const char *psz_fmt, ...);
#define msg_rc(...) msg_print(p_intf, __VA_ARGS__)
#define STATUS_CHANGE "status change: "
-typedef int (*cli_callback)(intf_thread_t *, const char *const *, size_t);
+typedef int (*cli_callback)(intf_thread_t *, const char *const *, size_t,
+ void *);
struct cli_handler
{
diff --git a/modules/control/cli/player.c b/modules/control/cli/player.c
index 5de680f515..e31fb98820 100644
--- a/modules/control/cli/player.c
+++ b/modules/control/cli/player.c
@@ -194,14 +194,14 @@ static int PlayerDoFloat(intf_thread_t *intf, const char *const *args,
}
static int PlayerPause(intf_thread_t *intf, const char *const *args,
- size_t count)
+ size_t count, void *data)
{
(void) args; (void) count;
return PlayerDoVoid(intf, vlc_player_TogglePause);
}
static int PlayerFastForward(intf_thread_t *intf, const char *const *args,
- size_t count)
+ size_t count, void *data)
{
vlc_playlist_t *playlist = intf->p_sys->playlist;
vlc_player_t *player = vlc_playlist_GetPlayer(playlist);
@@ -226,7 +226,7 @@ static int PlayerFastForward(intf_thread_t *intf, const char *const *args,
}
static int PlayerRewind(intf_thread_t *intf, const char *const *args,
- size_t count)
+ size_t count, void *data)
{
vlc_playlist_t *playlist = intf->p_sys->playlist;
vlc_player_t *player = vlc_playlist_GetPlayer(playlist);
@@ -250,14 +250,14 @@ static int PlayerRewind(intf_thread_t *intf, const char *const *args,
}
static int PlayerFaster(intf_thread_t *intf, const char *const *args,
- size_t count)
+ size_t count, void *data)
{
(void) args; (void) count;
return PlayerDoVoid(intf, vlc_player_IncrementRate);
}
static int PlayerSlower(intf_thread_t *intf, const char *const *args,
- size_t count)
+ size_t count, void *data)
{
(void) args; (void) count;
return PlayerDoVoid(intf, vlc_player_DecrementRate);
@@ -269,55 +269,56 @@ static void PlayerDoNormal(vlc_player_t *player)
}
static int PlayerNormal(intf_thread_t *intf, const char *const *args,
- size_t count)
+ size_t count, void *data)
{
(void) args; (void) count;
return PlayerDoVoid(intf, PlayerDoNormal);
}
-static int PlayerRate(intf_thread_t *intf, const char *const *args, size_t n)
+static int PlayerRate(intf_thread_t *intf, const char *const *args, size_t n,
+ void *data)
{
return PlayerDoFloat(intf, args, n, vlc_player_ChangeRate,
vlc_player_GetRate);
}
static int PlayerFrame(intf_thread_t *intf, const char *const *args,
- size_t count)
+ size_t count, void *data)
{
(void) args; (void) count;
return PlayerDoVoid(intf, vlc_player_NextVideoFrame);
}
static int PlayerChapterPrev(intf_thread_t *intf, const char *const *args,
- size_t count)
+ size_t count, void *data)
{
(void) args; (void) count;
return PlayerDoVoid(intf, vlc_player_SelectPrevChapter);
}
static int PlayerChapterNext(intf_thread_t *intf, const char *const *args,
- size_t count)
+ size_t count, void *data)
{
(void) args; (void) count;
return PlayerDoVoid(intf, vlc_player_SelectNextChapter);
}
static int PlayerTitlePrev(intf_thread_t *intf, const char *const *args,
- size_t count)
+ size_t count, void *data)
{
(void) args; (void) count;
return PlayerDoVoid(intf, vlc_player_SelectPrevTitle);
}
static int PlayerTitleNext(intf_thread_t *intf, const char *const *args,
- size_t count)
+ size_t count, void *data)
{
(void) args; (void) count;
return PlayerDoVoid(intf, vlc_player_SelectNextTitle);
}
static int PlayerSeek(intf_thread_t *intf, const char *const *args,
- size_t count)
+ size_t count, void *data)
{
vlc_player_t *player = vlc_playlist_GetPlayer(intf->p_sys->playlist);
@@ -350,7 +351,7 @@ static int PlayerSeek(intf_thread_t *intf, const char *const *args,
}
static int PlayerSetChapter(intf_thread_t *intf, const char *const *args,
- size_t count)
+ size_t count, void *data)
{
vlc_player_t *player = vlc_playlist_GetPlayer(intf->p_sys->playlist);
int ret = 0;
@@ -379,7 +380,7 @@ static int PlayerSetChapter(intf_thread_t *intf, const char *const *args,
}
static int PlayerSetTitle(intf_thread_t *intf, const char *const *args,
- size_t count)
+ size_t count, void *data)
{
vlc_player_t *player = vlc_playlist_GetPlayer(intf->p_sys->playlist);
int ret = 0;
@@ -414,7 +415,7 @@ static int PlayerSetTitle(intf_thread_t *intf, const char *const *args,
}
static int PlayerSetTrack(intf_thread_t *intf, const char *const *args,
- size_t count)
+ size_t count, void *data)
{
vlc_player_t *player = vlc_playlist_GetPlayer(intf->p_sys->playlist);
const char *psz_cmd = args[0];
@@ -477,7 +478,7 @@ out:
}
static int PlayerRecord(intf_thread_t *intf, const char *const *args,
- size_t count)
+ size_t count, void *data)
{
vlc_player_t *player = vlc_playlist_GetPlayer(intf->p_sys->playlist);
@@ -501,7 +502,7 @@ static int PlayerRecord(intf_thread_t *intf, const char *const *args,
}
static int PlayerItemInfo(intf_thread_t *intf, const char *const *args,
- size_t count)
+ size_t count, void *data)
{
vlc_player_t *player = vlc_playlist_GetPlayer(intf->p_sys->playlist);
input_item_t *item;
@@ -535,7 +536,7 @@ static int PlayerItemInfo(intf_thread_t *intf, const char *const *args,
}
static int PlayerGetTime(intf_thread_t *intf, const char *const *args,
- size_t count)
+ size_t count, void *data)
{
vlc_player_t *player = vlc_playlist_GetPlayer(intf->p_sys->playlist);
vlc_tick_t t;
@@ -552,7 +553,7 @@ static int PlayerGetTime(intf_thread_t *intf, const char *const *args,
}
static int PlayerGetLength(intf_thread_t *intf, const char *const *args,
- size_t count)
+ size_t count, void *data)
{
vlc_player_t *player = vlc_playlist_GetPlayer(intf->p_sys->playlist);
vlc_tick_t l;
@@ -570,7 +571,7 @@ static int PlayerGetLength(intf_thread_t *intf, const char *const *args,
}
static int PlayerGetTitle(intf_thread_t *intf, const char *const *args,
- size_t count)
+ size_t count, void *data)
{
vlc_player_t *player = vlc_playlist_GetPlayer(intf->p_sys->playlist);
const struct vlc_player_title *title;
@@ -584,14 +585,14 @@ static int PlayerGetTitle(intf_thread_t *intf, const char *const *args,
}
static int PlayerVoutSnapshot(intf_thread_t *intf, const char *const *args,
- size_t count)
+ size_t count, void *data)
{
(void) args; (void) count;
return PlayerDoVoid(intf, vlc_player_vout_Snapshot);
}
static int PlayerFullscreen(intf_thread_t *intf, const char *const *args,
- size_t count)
+ size_t count, void *data)
{
vlc_player_t *player = vlc_playlist_GetPlayer(intf->p_sys->playlist);
bool fs = !vlc_player_vout_IsFullscreen(player);
@@ -608,7 +609,8 @@ static int PlayerFullscreen(intf_thread_t *intf, const char *const *args,
return 0;
}
-static int Volume(intf_thread_t *intf, const char *const *args, size_t count)
+static int Volume(intf_thread_t *intf, const char *const *args, size_t count,
+ void *data)
{
vlc_player_t *player = vlc_playlist_GetPlayer(intf->p_sys->playlist);
@@ -642,7 +644,7 @@ static int Volume(intf_thread_t *intf, const char *const *args, size_t count)
}
static int VolumeMove(intf_thread_t *intf, const char *const *args,
- size_t count)
+ size_t count, void *data)
{
vlc_player_t *player = vlc_playlist_GetPlayer(intf->p_sys->playlist);
const char *psz_cmd = args[0];
@@ -661,7 +663,7 @@ static int VolumeMove(intf_thread_t *intf, const char *const *args,
}
static int VideoConfig(intf_thread_t *intf, const char *const *args,
- size_t n_args)
+ size_t n_args, void *data)
{
vlc_player_t *player = vlc_playlist_GetPlayer(intf->p_sys->playlist);
vout_thread_t *p_vout = vlc_player_vout_Hold(player);
@@ -764,7 +766,7 @@ static int VideoConfig(intf_thread_t *intf, const char *const *args,
}
static int AudioDevice(intf_thread_t *intf, const char *const *args,
- size_t count)
+ size_t count, void *data)
{
const char *cmd = args[0];
const char *arg = count > 1 ? args[1] : "";
@@ -828,7 +830,7 @@ out:
}
static int AudioChannel(intf_thread_t *intf, const char *const *args,
- size_t n_args)
+ size_t n_args, void *data)
{
const char *cmd = args[0];
const char *arg = n_args > 1 ? args[1] : "";
@@ -878,7 +880,7 @@ out:
}
static int Statistics(intf_thread_t *intf, const char *const *args,
- size_t count)
+ size_t count, void *data)
{
vlc_player_t *player = vlc_playlist_GetPlayer(intf->p_sys->playlist);
input_item_t *item;
@@ -938,7 +940,7 @@ static int Statistics(intf_thread_t *intf, const char *const *args,
}
static int IsPlaying(intf_thread_t *intf, const char *const *args,
- size_t count)
+ size_t count, void *data)
{
intf_sys_t *sys = intf->p_sys;
vlc_player_t *player = vlc_playlist_GetPlayer(sys->playlist);
@@ -954,7 +956,7 @@ static int IsPlaying(intf_thread_t *intf, const char *const *args,
}
static int PlayerStatus(intf_thread_t *intf, const char *const *args,
- size_t count)
+ size_t count, void *data)
{
vlc_playlist_t *playlist = intf->p_sys->playlist;
vlc_player_t *player = vlc_playlist_GetPlayer(playlist);
diff --git a/modules/control/cli/playlist.c b/modules/control/cli/playlist.c
index 1d2d8e4e26..3740a9798c 100644
--- a/modules/control/cli/playlist.c
+++ b/modules/control/cli/playlist.c
@@ -174,21 +174,21 @@ static int PlaylistDoVoid(intf_thread_t *intf, int (*cb)(vlc_playlist_t *))
}
static int PlaylistPrev(intf_thread_t *intf, const char *const *args,
- size_t count)
+ size_t count, void *data)
{
(void) args; (void) count;
return PlaylistDoVoid(intf, vlc_playlist_Prev);
}
static int PlaylistNext(intf_thread_t *intf, const char *const *args,
- size_t count)
+ size_t count, void *data)
{
(void) args; (void) count;
return PlaylistDoVoid(intf, vlc_playlist_Next);
}
static int PlaylistPlay(intf_thread_t *intf, const char *const *args,
- size_t count)
+ size_t count, void *data)
{
(void) args; (void) count;
return PlaylistDoVoid(intf, vlc_playlist_Start);
@@ -201,7 +201,7 @@ static int PlaylistDoStop(vlc_playlist_t *playlist)
}
static int PlaylistStop(intf_thread_t *intf, const char *const *args,
- size_t count)
+ size_t count, void *data)
{
(void) args; (void) count;
return PlaylistDoVoid(intf, PlaylistDoStop);
@@ -215,7 +215,7 @@ static int PlaylistDoClear(vlc_playlist_t *playlist)
}
static int PlaylistClear(intf_thread_t *intf, const char *const *args,
- size_t count)
+ size_t count, void *data)
{
(void) args; (void) count;
return PlaylistDoVoid(intf, PlaylistDoClear);
@@ -233,14 +233,14 @@ static int PlaylistDoSort(vlc_playlist_t *playlist)
}
static int PlaylistSort(intf_thread_t *intf, const char *const *args,
- size_t count)
+ size_t count, void *data)
{
(void) args; (void) count;
return PlaylistDoVoid(intf, PlaylistDoSort);
}
static int PlaylistList(intf_thread_t *intf, const char *const *args,
- size_t count)
+ size_t count, void *data)
{
vlc_playlist_t *playlist = intf->p_sys->playlist;
@@ -287,21 +287,21 @@ static int PlaylistRepeatCommon(intf_thread_t *intf, const char *const *args,
}
static int PlaylistRepeat(intf_thread_t *intf, const char *const *args,
- size_t count)
+ size_t count, void *data)
{
return PlaylistRepeatCommon(intf, args, count,
VLC_PLAYLIST_PLAYBACK_REPEAT_CURRENT);
}
static int PlaylistLoop(intf_thread_t *intf, const char *const *args,
- size_t count)
+ size_t count, void *data)
{
return PlaylistRepeatCommon(intf, args, count,
VLC_PLAYLIST_PLAYBACK_REPEAT_ALL);
}
static int PlaylistRandom(intf_thread_t *intf, const char *const *args,
- size_t count)
+ size_t count, void *data)
{
vlc_playlist_t *playlist = intf->p_sys->playlist;
@@ -332,7 +332,7 @@ static int PlaylistRandom(intf_thread_t *intf, const char *const *args,
}
static int PlaylistGoto(intf_thread_t *intf, const char *const *args,
- size_t n_args)
+ size_t n_args, void *data)
{
vlc_playlist_t *playlist = intf->p_sys->playlist;
const char *arg = n_args > 1 ? args[1] : "";
@@ -439,19 +439,19 @@ static int PlaylistAddCommon(intf_thread_t *intf, const char *const *args,
}
static int PlaylistAdd(intf_thread_t *intf, const char *const *args,
- size_t count)
+ size_t count, void *data)
{
return PlaylistAddCommon(intf, args, count, true);
}
static int PlaylistEnqueue(intf_thread_t *intf, const char *const *args,
- size_t count)
+ size_t count, void *data)
{
return PlaylistAddCommon(intf, args, count, false);
}
static int PlaylistMove(intf_thread_t *intf, const char *const *args,
- size_t count)
+ size_t count, void *data)
{
vlc_playlist_t *playlist = intf->p_sys->playlist;
int ret;
More information about the vlc-commits
mailing list