summaryrefslogtreecommitdiffstats
path: root/player/client.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-03-17 18:26:56 +0100
committerwm4 <wm4@nowhere>2014-03-17 18:26:56 +0100
commit637664d95ad5e2ad72b91998dc4685bf0fe6cdeb (patch)
tree86845d85012850a58b213c7f4046b4a855dd5a2a /player/client.c
parent422af1b948135e422a13e5d58bef32e4ee38f172 (diff)
downloadmpv-637664d95ad5e2ad72b91998dc4685bf0fe6cdeb.tar.bz2
mpv-637664d95ad5e2ad72b91998dc4685bf0fe6cdeb.tar.xz
command, lua: change script_message semantics
Change script_message to broadcast the message to all clients. Add a new script_message_to command, which does what the old script_message command did. This is intended as simplification, although it might lead to chaos too.
Diffstat (limited to 'player/client.c')
-rw-r--r--player/client.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/player/client.c b/player/client.c
index 675410893d..42d2fb2bb8 100644
--- a/player/client.c
+++ b/player/client.c
@@ -339,6 +339,7 @@ static void status_reply(struct mpv_handle *ctx, int event,
}
// set ev->data to a new copy of the original data
+// (done only for message types that are broadcast)
static void dup_event_data(struct mpv_event *ev)
{
switch (ev->event_id) {
@@ -346,6 +347,17 @@ static void dup_event_data(struct mpv_event *ev)
case MPV_EVENT_UNPAUSE:
ev->data = talloc_memdup(NULL, ev->data, sizeof(mpv_event_pause_reason));
break;
+ case MPV_EVENT_CLIENT_MESSAGE: {
+ struct mpv_event_client_message *src = ev->data;
+ struct mpv_event_client_message *msg =
+ talloc_zero(NULL, struct mpv_event_client_message);
+ for (int n = 0; n < src->num_args; n++) {
+ MP_TARRAY_APPEND(msg, msg->args, msg->num_args,
+ talloc_strdup(msg, src->args[n]));
+ }
+ ev->data = msg;
+ break;
+ }
default:
// Doesn't use events with memory allocation.
if (ev->data)