Skip to content

Commit

Permalink
preparser: use input_item_parser_cbs_t for callbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
tguillem authored and robUx4 committed Oct 11, 2024
1 parent eff41fc commit cdeea03
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 25 deletions.
10 changes: 1 addition & 9 deletions include/vlc_preparser.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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 );

Expand Down
4 changes: 2 additions & 2 deletions lib/media.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down
6 changes: 3 additions & 3 deletions modules/gui/qt/player/player_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}();

Expand Down
4 changes: 2 additions & 2 deletions src/media_source/media_tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/playlist/preparse.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

Expand Down
10 changes: 5 additions & 5 deletions src/preparser/preparser.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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 ) )
Expand Down
4 changes: 2 additions & 2 deletions test/libvlc/media.c
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit cdeea03

Please sign in to comment.