diff options
-rw-r--r-- | DOCS/man/input.rst | 11 | ||||
-rw-r--r-- | player/loadfile.c | 16 |
2 files changed, 27 insertions, 0 deletions
diff --git a/DOCS/man/input.rst b/DOCS/man/input.rst index 76678c2b3c..11a8f0021f 100644 --- a/DOCS/man/input.rst +++ b/DOCS/man/input.rst @@ -765,6 +765,17 @@ The following hooks are currently defined: ``file-local-options/<option name>``. The player will wait until all hooks are run. +``on_preloaded`` + Called after a file has been opened, and before tracks are selected and + decoders are created. This has some usefulness if an API users wants + to select tracks manually, based on the set of available tracks. It's + also useful to initialize ``--lavfi-complex`` in a specific way by API, + without having to "probe" the available streams at first. + + Note that this does not yet apply default track selection. Which operations + exactly can be done and not be done, and what information is available and + what is not yet available yet, is all subject to change. + ``on_unload`` Run before closing a file, and before actually uninitializing everything. It's not possible to resume playback in this state. diff --git a/player/loadfile.c b/player/loadfile.c index bd48bb4b0e..7a0afe4c52 100644 --- a/player/loadfile.c +++ b/player/loadfile.c @@ -871,6 +871,19 @@ static int process_open_hooks(struct MPContext *mpctx) return 0; } +static int process_preloaded_hooks(struct MPContext *mpctx) +{ + mp_hook_run(mpctx, NULL, "on_preloaded"); + + while (!mp_hook_test_completion(mpctx, "on_preloaded")) { + mp_idle(mpctx); + if (mpctx->stop_play) + return -1; + } + + return 0; +} + static void process_unload_hooks(struct MPContext *mpctx) { mp_hook_run(mpctx, NULL, "on_unload"); @@ -1256,6 +1269,9 @@ reopen_file: check_previous_track_selection(mpctx); + if (process_preloaded_hooks(mpctx)) + goto terminate_playback; + if (!init_complex_filters(mpctx)) goto terminate_playback; |