From cdeea0392004995d437919d910d243299ca46065 Mon Sep 17 00:00:00 2001 From: Thomas Guillem Date: Wed, 9 Oct 2024 09:04:39 +0200 Subject: [PATCH] preparser: use input_item_parser_cbs_t for callbacks --- include/vlc_preparser.h | 10 +--------- lib/media.c | 4 ++-- modules/gui/qt/player/player_controller.cpp | 6 +++--- src/media_source/media_tree.c | 4 ++-- src/playlist/preparse.c | 4 ++-- src/preparser/preparser.c | 10 +++++----- test/libvlc/media.c | 4 ++-- 7 files changed, 17 insertions(+), 25 deletions(-) diff --git a/include/vlc_preparser.h b/include/vlc_preparser.h index 3bbdd03edecf..d8e230ccbf38 100644 --- a/include/vlc_preparser.h +++ b/include/vlc_preparser.h @@ -55,14 +55,6 @@ typedef enum input_item_meta_request_option_t META_REQUEST_OPTION_PARSE_SUBITEMS = 0x10, } input_item_meta_request_option_t; -struct vlc_metadata_cbs { - void (*on_preparse_ended)(input_item_t *, int status, void *userdata); - void (*on_subtree_added)(input_item_t *, input_item_node_t *subtree, void *userdata); - void (*on_attachments_added)(input_item_t *item, - input_attachment_t *const *array, - size_t count, void *userdata); -}; - /** * This function creates the preparser object and thread. * @@ -97,7 +89,7 @@ VLC_API vlc_preparser_t *vlc_preparser_New( vlc_object_t *obj, */ VLC_API int vlc_preparser_Push( vlc_preparser_t *preparser, input_item_t *item, input_item_meta_request_option_t option, - const struct vlc_metadata_cbs *cbs, + const input_item_parser_cbs_t *cbs, void *cbs_userdata, int timeout, void *id ); diff --git a/lib/media.c b/lib/media.c index 6637f422d070..95fa4c939c95 100644 --- a/lib/media.c +++ b/lib/media.c @@ -718,8 +718,8 @@ libvlc_media_get_filestat( libvlc_media_t *p_md, unsigned type, uint64_t *out ) return 1; } -static const struct vlc_metadata_cbs preparser_callbacks = { - .on_preparse_ended = input_item_preparse_ended, +static const input_item_parser_cbs_t preparser_callbacks = { + .on_ended = input_item_preparse_ended, .on_subtree_added = input_item_subtree_added, .on_attachments_added = input_item_attachments_added, }; diff --git a/modules/gui/qt/player/player_controller.cpp b/modules/gui/qt/player/player_controller.cpp index 0eca0da5fbd6..3cceecc87e1e 100644 --- a/modules/gui/qt/player/player_controller.cpp +++ b/modules/gui/qt/player/player_controller.cpp @@ -1097,9 +1097,9 @@ static const struct vlc_player_timer_smpte_cbs player_timer_smpte_cbs = { // art fetcher callbacks -static const struct vlc_metadata_cbs art_fetcher_cbs = []{ - struct vlc_metadata_cbs cbs{}; - cbs.on_preparse_ended = on_preparse_ended_callback; +static const input_item_parser_cbs_t art_fetcher_cbs = []{ + input_item_parser_cbs_t cbs{}; + cbs.on_ended = on_preparse_ended_callback; return cbs; }(); diff --git a/src/media_source/media_tree.c b/src/media_source/media_tree.c index f3ccbfc5894a..41230a6139f8 100644 --- a/src/media_source/media_tree.c +++ b/src/media_source/media_tree.c @@ -333,9 +333,9 @@ vlc_media_tree_Remove(vlc_media_tree_t *tree, input_item_t *media) return true; } -static const struct vlc_metadata_cbs preparser_callbacks = { +static const input_item_parser_cbs_t preparser_callbacks = { + .on_ended = media_subtree_preparse_ended, .on_subtree_added = media_subtree_changed, - .on_preparse_ended = media_subtree_preparse_ended }; void diff --git a/src/playlist/preparse.c b/src/playlist/preparse.c index 9436cf35089a..092e49ce7faf 100644 --- a/src/playlist/preparse.c +++ b/src/playlist/preparse.c @@ -104,8 +104,8 @@ on_preparse_ended(input_item_t *media, int status, void *userdata) vlc_playlist_Unlock(playlist); } -static const struct vlc_metadata_cbs preparser_callbacks = { - .on_preparse_ended = on_preparse_ended, +static const input_item_parser_cbs_t preparser_callbacks = { + .on_ended = on_preparse_ended, .on_subtree_added = on_subtree_added, }; diff --git a/src/preparser/preparser.c b/src/preparser/preparser.c index f267d8be1d33..03777742824e 100644 --- a/src/preparser/preparser.c +++ b/src/preparser/preparser.c @@ -48,7 +48,7 @@ struct task vlc_preparser_t *preparser; input_item_t *item; input_item_meta_request_option_t options; - const struct vlc_metadata_cbs *cbs; + const input_item_parser_cbs_t *cbs; void *userdata; void *id; vlc_tick_t timeout; @@ -69,7 +69,7 @@ static void RunnableRun(void *); static struct task * TaskNew(vlc_preparser_t *preparser, input_item_t *item, input_item_meta_request_option_t options, - const struct vlc_metadata_cbs *cbs, void *userdata, + const input_item_parser_cbs_t *cbs, void *userdata, void *id, vlc_tick_t timeout) { assert(timeout >= 0); @@ -129,10 +129,10 @@ NotifyPreparseEnded(struct task *task, bool art_fetched) if (task->cbs == NULL) return; - if (task->cbs->on_preparse_ended) { + if (task->cbs->on_ended) { int status = atomic_load_explicit(&task->preparse_status, memory_order_relaxed); - task->cbs->on_preparse_ended(task->item, status, task->userdata); + task->cbs->on_ended(task->item, status, task->userdata); } } @@ -341,7 +341,7 @@ vlc_preparser_t* vlc_preparser_New( vlc_object_t *parent, unsigned max_threads, int vlc_preparser_Push( vlc_preparser_t *preparser, input_item_t *item, input_item_meta_request_option_t i_options, - const struct vlc_metadata_cbs *cbs, void *cbs_userdata, + const input_item_parser_cbs_t *cbs, void *cbs_userdata, int timeout_ms, void *id ) { if( atomic_load( &preparser->deactivated ) ) diff --git a/test/libvlc/media.c b/test/libvlc/media.c index 3a93c8f69704..5dcab5a1a745 100644 --- a/test/libvlc/media.c +++ b/test/libvlc/media.c @@ -236,8 +236,8 @@ static void test_input_metadata_timeout(libvlc_instance_t *vlc, int timeout, vlc_sem_t sem; vlc_sem_init (&sem, 0); - const struct vlc_metadata_cbs cbs = { - .on_preparse_ended = input_item_preparse_timeout, + const input_item_parser_cbs_t cbs = { + .on_ended = input_item_preparse_timeout, }; vlc_preparser_t *parser = vlc_preparser_New(VLC_OBJECT(vlc->p_libvlc_int),