[vlc-commits] cli: attach private data to handlers
Rémi Denis-Courmont
git at videolan.org
Sun Nov 29 14:55:42 CET 2020
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Nov 28 15:48:21 2020 +0200| [5ebc14f23b2d78cb7d05aa39bf438b6c27dcc82d] | committer: Rémi Denis-Courmont
cli: attach private data to handlers
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=5ebc14f23b2d78cb7d05aa39bf438b6c27dcc82d
---
modules/control/cli/cli.c | 6 ++++--
modules/control/cli/cli.h | 2 +-
modules/control/cli/player.c | 2 +-
modules/control/cli/playlist.c | 3 ++-
4 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/modules/control/cli/cli.c b/modules/control/cli/cli.c
index 2e13ed0e83..9cb5b9ffaa 100644
--- a/modules/control/cli/cli.c
+++ b/modules/control/cli/cli.c
@@ -120,6 +120,7 @@ struct command {
const char *name;
struct cli_handler handler;
};
+ void *data;
};
static int cmdcmp(const void *a, const void *b)
@@ -131,7 +132,7 @@ static int cmdcmp(const void *a, const void *b)
}
void RegisterHandlers(intf_thread_t *intf, const struct cli_handler *handlers,
- size_t count)
+ size_t count, void *opaque)
{
intf_sys_t *sys = intf->p_sys;
@@ -142,6 +143,7 @@ void RegisterHandlers(intf_thread_t *intf, const struct cli_handler *handlers,
break;
cmd->handler = handlers[i];
+ cmd->data = opaque;
struct command **pp = tsearch(&cmd->name, &sys->commands, cmdcmp);
if (unlikely(pp == NULL))
@@ -767,7 +769,7 @@ static int Activate( vlc_object_t *p_this )
p_sys->pi_socket_listen = pi_socket;
p_sys->playlist = vlc_intf_GetMainPlaylist(p_intf);;
- RegisterHandlers(p_intf, cmds, ARRAY_SIZE(cmds));
+ RegisterHandlers(p_intf, cmds, ARRAY_SIZE(cmds), p_intf);
/* Line-buffered stdout */
setvbuf( stdout, (char *)NULL, _IOLBF, 0 );
diff --git a/modules/control/cli/cli.h b/modules/control/cli/cli.h
index b4a010d633..8149b40170 100644
--- a/modules/control/cli/cli.h
+++ b/modules/control/cli/cli.h
@@ -60,7 +60,7 @@ struct cli_handler
};
void RegisterHandlers(intf_thread_t *intf, const struct cli_handler *handlers,
- size_t count);
+ size_t count, void *opaque);
void *RegisterPlayer(intf_thread_t *intf);
void DeregisterPlayer(intf_thread_t *intf, void *);
diff --git a/modules/control/cli/player.c b/modules/control/cli/player.c
index daedef4f9f..5de680f515 100644
--- a/modules/control/cli/player.c
+++ b/modules/control/cli/player.c
@@ -1072,7 +1072,7 @@ void *RegisterPlayer(intf_thread_t *intf)
pc->input_buffering = false;
pc->show_position = var_InheritBool(intf, "rc-show-pos");
- RegisterHandlers(intf, cmds, ARRAY_SIZE(cmds));
+ RegisterHandlers(intf, cmds, ARRAY_SIZE(cmds), player);
vlc_player_Lock(player);
pc->player_listener = vlc_player_AddListener(player, &player_cbs, pc);
diff --git a/modules/control/cli/playlist.c b/modules/control/cli/playlist.c
index 20881b502d..1d2d8e4e26 100644
--- a/modules/control/cli/playlist.c
+++ b/modules/control/cli/playlist.c
@@ -504,5 +504,6 @@ static const struct cli_handler cmds[] =
void RegisterPlaylist(intf_thread_t *intf)
{
- RegisterHandlers(intf, cmds, ARRAY_SIZE(cmds));
+ RegisterHandlers(intf, cmds, ARRAY_SIZE(cmds),
+ vlc_intf_GetMainPlaylist(intf));
}
More information about the vlc-commits
mailing list