Hopefully nothing uses this. (I know one exception, but, well, what can I do.)
Unified · Split
| @@ -35,6 +35,9 @@ Interface changes · 34 unmodified lines | ||
| 35 | 35 | - the OSX bundle now logs to "~/Library/Logs/mpv.log" by default |
| 36 | 36 | - deprecate the --cache-secs option (once removed, the cache cannot be |
| 37 | 37 | limited by time anymore) |
| 38 | + - remove deprecated legacy hook API ("hook-add", "hook-ack"). Use either the | |
| 39 | + libmpv API (mpv_hook_add(), mpv_hook_continue()), or the Lua scripting | |
| 40 | + wrappers (mp.add_hook()). | |
| 38 | 41 | --- mpv 0.32.0 --- |
| 39 | 42 | - change behavior when using legacy option syntax with options that start |
| 40 | 43 | with two dashes (``--`` instead of a ``-``). Now, using the recommended |
| @@ -1286,47 +1286,6 @@ The following hooks are currently defined: · 1285 unmodified lines | ||
| 1286 | 1286 | Run before closing a file, and before actually uninitializing |
| 1287 | 1287 | everything. It's not possible to resume playback in this state. |
| 1288 | 1288 | |
| 1289 | −Legacy hook API | |
| 1290 | −~~~~~~~~~~~~~~~ | |
| 1291 | − | |
| 1292 | −.. warning:: | |
| 1293 | − | |
| 1294 | − The legacy API is deprecated and will be removed soon. | |
| 1295 | − | |
| 1296 | −There are two special commands involved. Also, the client must listen for | |
| 1297 | −client messages (``MPV_EVENT_CLIENT_MESSAGE`` in the C API). | |
| 1298 | − | |
| 1299 | −``hook-add <hook-name> <id> <priority>`` | |
| 1300 | − Subscribe to the hook identified by the first argument (basically, the | |
| 1301 | − name of event). The ``id`` argument is an arbitrary integer chosen by the | |
| 1302 | − user. ``priority`` is used to sort all hook handlers globally across all | |
| 1303 | − clients. Each client can register multiple hook handlers (even for the | |
| 1304 | − same hook-name). Once the hook is registered, it cannot be unregistered. | |
| 1305 | − | |
| 1306 | − When a specific event happens, all registered handlers are run serially. | |
| 1307 | − This uses a protocol every client has to follow explicitly. When a hook | |
| 1308 | − handler is run, a client message (``MPV_EVENT_CLIENT_MESSAGE``) is sent to | |
| 1309 | − the client which registered the hook. This message has the following | |
| 1310 | − arguments: | |
| 1311 | − | |
| 1312 | − 1. the string ``hook_run`` | |
| 1313 | − 2. the ``id`` argument the hook was registered with as string (this can be | |
| 1314 | − used to correctly handle multiple hooks registered by the same client, | |
| 1315 | − as long as the ``id`` argument is unique in the client) | |
| 1316 | − 3. something undefined, used by the hook mechanism to track hook execution | |
| 1317 | − | |
| 1318 | − Upon receiving this message, the client can handle the event. While doing | |
| 1319 | − this, the player core will still react to requests, but playback will | |
| 1320 | − typically be stopped. | |
| 1321 | − | |
| 1322 | − When the client is done, it must continue the core's hook execution by | |
| 1323 | − running the ``hook-ack`` command. | |
| 1324 | − | |
| 1325 | −``hook-ack <string>`` | |
| 1326 | − Run the next hook in the global chain of hooks. The argument is the 3rd | |
| 1327 | − argument of the client message that starts hook execution for the | |
| 1328 | − current client. | |
| 1329 | − | |
| 1330 | 1289 | Input Command Prefixes |
| 1331 | 1290 | ---------------------- |
| 1332 | 1291 | |
| @@ -1728,7 +1728,7 @@ int mpv_hook_add(mpv_handle *ctx, uint64_t reply_userdata, · 1727 unmodified lines | ||
| 1728 | 1728 | const char *name, int priority) |
| 1729 | 1729 | { |
| 1730 | 1730 | lock_core(ctx); |
| 1731 | − mp_hook_add(ctx->mpctx, ctx->name, name, reply_userdata, priority, false); | |
| 1731 | + mp_hook_add(ctx->mpctx, ctx->name, name, reply_userdata, priority); | |
| 1732 | 1732 | unlock_core(ctx); |
| 1733 | 1733 | return 0; |
| 1734 | 1734 | } |
| @@ -123,7 +123,6 @@ struct hook_handler { · 122 unmodified lines | ||
| 123 | 123 | uint64_t user_id; // user-chosen ID |
| 124 | 124 | int priority; // priority for global hook order |
| 125 | 125 | int64_t seq; // unique ID, != 0, also for fixed order on equal priorities |
| 126 | − bool legacy; // old cmd based hook API | |
| 127 | 126 | bool active; // hook is currently in progress (only 1 at a time for now) |
| 128 | 127 | }; |
| 129 | 128 | |
| @@ -178,29 +177,13 @@ static int invoke_hook_handler(struct MPContext *mpctx, struct hook_handler *h) · 48 unmodified lines | ||
| 178 | 177 | h->active = true; |
| 179 | 178 | |
| 180 | 179 | uint64_t reply_id = 0; |
| 181 | − void *data; | |
| 182 | − int msg; | |
| 183 | − if (h->legacy) { | |
| 184 | − mpv_event_client_message *m = talloc_ptrtype(NULL, m); | |
| 185 | − *m = (mpv_event_client_message){0}; | |
| 186 | − MP_TARRAY_APPEND(m, m->args, m->num_args, "hook_run"); | |
| 187 | − MP_TARRAY_APPEND(m, m->args, m->num_args, | |
| 188 | − talloc_asprintf(m, "%llu", (long long)h->user_id)); | |
| 189 | − MP_TARRAY_APPEND(m, m->args, m->num_args, | |
| 190 | − talloc_asprintf(m, "%llu", (long long)h->seq)); | |
| 191 | − data = m; | |
| 192 | − msg = MPV_EVENT_CLIENT_MESSAGE; | |
| 193 | − } else { | |
| 194 | − mpv_event_hook *m = talloc_ptrtype(NULL, m); | |
| 195 | − *m = (mpv_event_hook){ | |
| 196 | − .name = talloc_strdup(m, h->type), | |
| 197 | − .id = h->seq, | |
| 198 | − }, | |
| 199 | − reply_id = h->user_id; | |
| 200 | − data = m; | |
| 201 | − msg = MPV_EVENT_HOOK; | |
| 202 | − } | |
| 203 | − int r = mp_client_send_event(mpctx, h->client, reply_id, msg, data); | |
| 180 | + mpv_event_hook *m = talloc_ptrtype(NULL, m); | |
| 181 | + *m = (mpv_event_hook){ | |
| 182 | + .name = talloc_strdup(m, h->type), | |
| 183 | + .id = h->seq, | |
| 184 | + }, | |
| 185 | + reply_id = h->user_id; | |
| 186 | + int r = mp_client_send_event(mpctx, h->client, reply_id, MPV_EVENT_HOOK, m); | |
| 204 | 187 | if (r < 0) { |
| 205 | 188 | MP_WARN(mpctx, "Sending hook command failed. Removing hook.\n"); |
| 206 | 189 | hook_remove(mpctx, h); |
| @@ -261,11 +244,8 @@ static int compare_hook(const void *pa, const void *pb) · 54 unmodified lines | ||
| 261 | 244 | } |
| 262 | 245 | |
| 263 | 246 | void mp_hook_add(struct MPContext *mpctx, const char *client, const char *name, |
| 264 | − uint64_t user_id, int pri, bool legacy) | |
| 247 | + uint64_t user_id, int pri) | |
| 265 | 248 | { |
| 266 | − if (legacy) | |
| 267 | − MP_WARN(mpctx, "The old hook API is deprecated! Use the libmpv API.\n"); | |
| 268 | − | |
| 269 | 249 | struct command_ctx *cmd = mpctx->command_ctx; |
| 270 | 250 | struct hook_handler *h = talloc_ptrtype(cmd, h); |
| 271 | 251 | int64_t seq = ++cmd->hook_seq; |
| @@ -275,7 +255,6 @@ void mp_hook_add(struct MPContext *mpctx, const char *client, const char *name, · 3 unmodified lines | ||
| 275 | 255 | .user_id = user_id, |
| 276 | 256 | .priority = pri, |
| 277 | 257 | .seq = seq, |
| 278 | − .legacy = legacy, | |
| 279 | 258 | }; |
| 280 | 259 | MP_TARRAY_APPEND(cmd, cmd->hooks, cmd->num_hooks, h); |
| 281 | 260 | qsort(cmd->hooks, cmd->num_hooks, sizeof(cmd->hooks[0]), compare_hook); |
| @@ -5411,33 +5390,6 @@ static void cmd_write_watch_later_config(void *p) · 5129 unmodified lines | ||
| 5411 | 5390 | mp_write_watch_later_conf(mpctx); |
| 5412 | 5391 | } |
| 5413 | 5392 | |
| 5414 | −static void cmd_hook_add(void *p) | |
| 5415 | −{ | |
| 5416 | − struct mp_cmd_ctx *cmd = p; | |
| 5417 | − struct MPContext *mpctx = cmd->mpctx; | |
| 5418 | − | |
| 5419 | − if (!cmd->cmd->sender) { | |
| 5420 | − MP_ERR(mpctx, "Can be used from client API only.\n"); | |
| 5421 | − cmd->success = false; | |
| 5422 | − return; | |
| 5423 | − } | |
| 5424 | − mp_hook_add(mpctx, cmd->cmd->sender, cmd->args[0].v.s, cmd->args[1].v.i, | |
| 5425 | − cmd->args[2].v.i, true); | |
| 5426 | −} | |
| 5427 | − | |
| 5428 | −static void cmd_hook_ack(void *p) | |
| 5429 | −{ | |
| 5430 | − struct mp_cmd_ctx *cmd = p; | |
| 5431 | − struct MPContext *mpctx = cmd->mpctx; | |
| 5432 | − | |
| 5433 | − if (!cmd->cmd->sender) { | |
| 5434 | − MP_ERR(mpctx, "Can be used from client API only.\n"); | |
| 5435 | − cmd->success = false; | |
| 5436 | − return; | |
| 5437 | − } | |
| 5438 | − mp_hook_continue(mpctx, cmd->cmd->sender, cmd->args[0].v.i); | |
| 5439 | −} | |
| 5440 | − | |
| 5441 | 5393 | static void cmd_mouse(void *p) |
| 5442 | 5394 | { |
| 5443 | 5395 | struct mp_cmd_ctx *cmd = p; |
| @@ -5950,11 +5902,6 @@ const struct mp_cmd_def mp_cmds[] = { · 506 unmodified lines | ||
| 5950 | 5902 | |
| 5951 | 5903 | { "write-watch-later-config", cmd_write_watch_later_config }, |
| 5952 | 5904 | |
| 5953 | − { "hook-add", cmd_hook_add, { OPT_STRING("arg0", v.s, 0), | |
| 5954 | − OPT_INT("arg1", v.i, 0), | |
| 5955 | − OPT_INT("arg2", v.i, 0) }}, | |
| 5956 | − { "hook-ack", cmd_hook_ack, { OPT_INT("arg0", v.i, 0) }}, | |
| 5957 | − | |
| 5958 | 5905 | { "mouse", cmd_mouse, { OPT_INT("x", v.i, 0), |
| 5959 | 5906 | OPT_INT("y", v.i, 0), |
| 5960 | 5907 | OPT_INT("button", v.i, 0, OPTDEF_INT(-1)), |
| @@ -107,7 +107,7 @@ bool mp_hook_test_completion(struct MPContext *mpctx, char *type); · 106 unmodified lines | ||
| 107 | 107 | void mp_hook_start(struct MPContext *mpctx, char *type); |
| 108 | 108 | int mp_hook_continue(struct MPContext *mpctx, char *client, uint64_t id); |
| 109 | 109 | void mp_hook_add(struct MPContext *mpctx, const char *client, const char *name, |
| 110 | − uint64_t user_id, int pri, bool legacy); | |
| 110 | + uint64_t user_id, int pri); | |
| 111 | 111 | |
| 112 | 112 | void mark_seek(struct MPContext *mpctx); |
| 113 | 113 | |