[vlc-commits] [Git][videolan/vlc][master] 10 commits: qt: use on_preparse_ended callback to wait for art

Steve Lhomme (@robUx4) gitlab at videolan.org
Fri Oct 11 17:21:13 UTC 2024



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
45b7aa0e by Thomas Guillem at 2024-10-11T17:08:24+00:00
qt: use on_preparse_ended callback to wait for art

This callback is always sent at the end of parsing and/or fetching.

- - - - -
2aeafe0f by Thomas Guillem at 2024-10-11T17:08:24+00:00
preparser: remove on_art_fetch_ended

Use on_preparse_ended instead (cf. previous commit).

- - - - -
7848170e by Thomas Guillem at 2024-10-11T17:08:24+00:00
input_item: add GetType()

- - - - -
60e82f1c by Thomas Guillem at 2024-10-11T17:08:24+00:00
media_tree: always parse

The items are parsed while the user is parsing, so he wants it to be
parsed, no matter what.

- - - - -
dd369957 by Thomas Guillem at 2024-10-11T17:08:24+00:00
playlist: check if the item should be auto-preparsed

- - - - -
396471df by Thomas Guillem at 2024-10-11T17:08:24+00:00
lib: media: adapt for future scope rework

- - - - -
e0a892ee by Thomas Guillem at 2024-10-11T17:08:24+00:00
preparser: remove item skip handling

And rework input_item_meta_request_option_t:
 - META_REQUEST_OPTION_SCOPE_LOCAL and META_REQUEST_OPTION_SCOPE_NETWORK
   are merged into META_REQUEST_OPTION_PARSE

A preparser API that does not preparse item is weird...

- - - - -
1b159867 by Thomas Guillem at 2024-10-11T17:08:24+00:00
preparse: use int for status

This will allow to use the same struct of callbacks for preparser and
parser.

The VLC_ETIMEOUT usage will be documented in next commits.

- - - - -
eff41fc2 by Thomas Guillem at 2024-10-11T17:08:24+00:00
input_item: document timeout in parser_cbs

- - - - -
cdeea039 by Thomas Guillem at 2024-10-11T17:08:24+00:00
preparser: use input_item_parser_cbs_t for callbacks

- - - - -


14 changed files:

- include/vlc_input_item.h
- include/vlc_media_source.h
- include/vlc_preparser.h
- lib/media.c
- modules/gui/macosx/library/media-source/VLCMediaSource.m
- modules/gui/qt/network/devicesourceprovider.cpp
- modules/gui/qt/network/mediatreelistener.cpp
- modules/gui/qt/network/mediatreelistener.hpp
- modules/gui/qt/network/networkmediamodel.cpp
- modules/gui/qt/player/player_controller.cpp
- src/media_source/media_tree.c
- src/playlist/preparse.c
- src/preparser/preparser.c
- test/libvlc/media.c


Changes:

=====================================
include/vlc_input_item.h
=====================================
@@ -395,6 +395,16 @@ VLC_API input_item_t *input_item_Hold(input_item_t *);
 /** Releases an input item, i.e. decrements its reference counter. */
 VLC_API void input_item_Release(input_item_t *);
 
+static inline enum input_item_type_e
+input_item_GetType( input_item_t *p_i, bool *is_network )
+{
+    vlc_mutex_lock( &p_i->lock );
+    enum input_item_type_e type = p_i->i_type;
+    *is_network = p_i->b_net;
+    vlc_mutex_unlock( &p_i->lock );
+    return type;
+}
+
 /**
  * Record prefix string.
  * TODO make it configurable.
@@ -424,7 +434,8 @@ typedef struct input_item_parser_cbs_t
      * @note This callback is mandatory.
      *
      * @param item the parsed item
-     * @param status VLC_SUCCESS in case of success, an error otherwise
+     * @param status VLC_SUCCESS in case of success, VLC_ETIMEOUT in case of
+     * timeout, an error otherwise
      * @param userdata user data set by input_item_Parse()
      */
     void (*on_ended)(input_item_t *item, int status, void *userdata);


=====================================
include/vlc_media_source.h
=====================================
@@ -123,8 +123,7 @@ struct vlc_media_tree_callbacks
      */
     void
     (*on_preparse_end)(vlc_media_tree_t *tree, input_item_node_t * node,
-                       enum input_item_preparse_status status,
-                       void *userdata);
+                       int status, void *userdata);
 };
 
 /**


=====================================
include/vlc_preparser.h
=====================================
@@ -46,37 +46,15 @@ typedef struct vlc_preparser_t vlc_preparser_t;
 typedef enum input_item_meta_request_option_t
 {
     META_REQUEST_OPTION_NONE          = 0x00,
-    META_REQUEST_OPTION_SCOPE_LOCAL   = 0x01,
-    META_REQUEST_OPTION_SCOPE_NETWORK = 0x02,
-    META_REQUEST_OPTION_SCOPE_ANY     =
-        META_REQUEST_OPTION_SCOPE_LOCAL|META_REQUEST_OPTION_SCOPE_NETWORK,
-    META_REQUEST_OPTION_SCOPE_FORCED  = 0x04,
-    META_REQUEST_OPTION_FETCH_LOCAL   = 0x08,
-    META_REQUEST_OPTION_FETCH_NETWORK = 0x10,
+    META_REQUEST_OPTION_PARSE         = 0x01,
+    META_REQUEST_OPTION_FETCH_LOCAL   = 0x02,
+    META_REQUEST_OPTION_FETCH_NETWORK = 0x04,
     META_REQUEST_OPTION_FETCH_ANY     =
         META_REQUEST_OPTION_FETCH_LOCAL|META_REQUEST_OPTION_FETCH_NETWORK,
-    META_REQUEST_OPTION_DO_INTERACT   = 0x20,
-    META_REQUEST_OPTION_PARSE_SUBITEMS = 0x40,
+    META_REQUEST_OPTION_DO_INTERACT   = 0x08,
+    META_REQUEST_OPTION_PARSE_SUBITEMS = 0x10,
 } input_item_meta_request_option_t;
 
-/* status of the on_preparse_ended() callback */
-enum input_item_preparse_status
-{
-    ITEM_PREPARSE_SKIPPED,
-    ITEM_PREPARSE_FAILED,
-    ITEM_PREPARSE_TIMEOUT,
-    ITEM_PREPARSE_DONE
-};
-
-struct vlc_metadata_cbs {
-    void (*on_preparse_ended)(input_item_t *, enum input_item_preparse_status status, void *userdata);
-    void (*on_art_fetch_ended)(input_item_t *, bool fetched, 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.
  *
@@ -111,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 );
 


=====================================
lib/media.c
=====================================
@@ -306,8 +306,7 @@ static void send_parsed_changed( libvlc_media_t *p_md,
  * input_item_preparse_ended (Private) (vlc event Callback)
  */
 static void input_item_preparse_ended(input_item_t *item,
-                                      enum input_item_preparse_status status,
-                                      void *user_data)
+                                      int status, void *user_data)
 {
     VLC_UNUSED(item);
     libvlc_media_t * p_md = user_data;
@@ -315,16 +314,13 @@ static void input_item_preparse_ended(input_item_t *item,
 
     switch( status )
     {
-        case ITEM_PREPARSE_SKIPPED:
-            new_status = libvlc_media_parsed_status_skipped;
-            break;
-        case ITEM_PREPARSE_FAILED:
+        case VLC_EGENERIC:
             new_status = libvlc_media_parsed_status_failed;
             break;
-        case ITEM_PREPARSE_TIMEOUT:
+        case VLC_ETIMEOUT:
             new_status = libvlc_media_parsed_status_timeout;
             break;
-        case ITEM_PREPARSE_DONE:
+        case VLC_SUCCESS:
             new_status = libvlc_media_parsed_status_done;
             break;
         default:
@@ -722,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,
 };
@@ -759,16 +755,58 @@ int libvlc_media_parse_request(libvlc_instance_t *inst, libvlc_media_t *media,
                                                   memory_order_relaxed,
                                                   memory_order_relaxed));
 
-    if (parse_flag & libvlc_media_parse_local)
-        parse_scope |= META_REQUEST_OPTION_SCOPE_LOCAL;
-    if (parse_flag & libvlc_media_parse_network)
-        parse_scope |= META_REQUEST_OPTION_SCOPE_NETWORK;
+    bool input_net;
+    enum input_item_type_e input_type = input_item_GetType(item, &input_net);
+
+    bool do_parse, do_fetch;
     if (parse_flag & libvlc_media_parse_forced)
-        parse_scope |= META_REQUEST_OPTION_SCOPE_FORCED;
+        do_parse = true;
+    else
+    {
+        if (input_net && (parse_flag & libvlc_media_parse_network) == 0)
+            do_parse = false;
+        else if (parse_flag & libvlc_media_parse_local)
+        {
+            switch (input_type)
+            {
+                case ITEM_TYPE_NODE:
+                case ITEM_TYPE_FILE:
+                case ITEM_TYPE_DIRECTORY:
+                case ITEM_TYPE_PLAYLIST:
+                    do_parse = true;
+                    break;
+                default:
+                    do_parse = false;
+                    break;
+            }
+        }
+        else
+            do_parse = false;
+    }
+
+    if (do_parse)
+        parse_scope |= META_REQUEST_OPTION_PARSE;
+
+    do_fetch = false;
     if (parse_flag & libvlc_media_fetch_local)
+    {
         parse_scope |= META_REQUEST_OPTION_FETCH_LOCAL;
+        do_fetch = true;
+    }
     if (parse_flag & libvlc_media_fetch_network)
+    {
         parse_scope |= META_REQUEST_OPTION_FETCH_NETWORK;
+        do_fetch = true;
+    }
+
+    if (!do_parse && !do_fetch)
+    {
+        send_parsed_changed( media, libvlc_media_parsed_status_skipped );
+        atomic_fetch_sub_explicit(&media->worker_count, 1,
+                                  memory_order_relaxed);
+        return 0;
+    }
+
     if (parse_flag & libvlc_media_do_interact)
         parse_scope |= META_REQUEST_OPTION_DO_INTERACT;
     parse_scope |= META_REQUEST_OPTION_PARSE_SUBITEMS;


=====================================
modules/gui/macosx/library/media-source/VLCMediaSource.m
=====================================
@@ -79,7 +79,7 @@ static void cb_children_removed(vlc_media_tree_t *p_tree,
 
 static void cb_preparse_ended(vlc_media_tree_t *p_tree,
                               input_item_node_t *p_node,
-                              enum input_item_preparse_status status,
+                              int status,
                               void *p_data)
 {
     dispatch_async(dispatch_get_main_queue(), ^{


=====================================
modules/gui/qt/network/devicesourceprovider.cpp
=====================================
@@ -27,7 +27,7 @@ struct DeviceSourceProvider::ListenerCb : public MediaTreeListener::MediaTreeLis
         , mediaSource(std::move(mediaSource))
     {}
 
-    inline void onItemPreparseEnded( MediaTreePtr, input_item_node_t *, enum input_item_preparse_status ) override final {}
+    inline void onItemPreparseEnded( MediaTreePtr, input_item_node_t *, int ) override final {}
 
     void onItemCleared( MediaTreePtr tree, input_item_node_t* node ) override
     {


=====================================
modules/gui/qt/network/mediatreelistener.cpp
=====================================
@@ -24,8 +24,7 @@ static void onItemRemoved(vlc_media_tree_t *, input_item_node_t *node,
 }
 
 static void onItemPreparseEnded(vlc_media_tree_t *, input_item_node_t * node,
-                                enum input_item_preparse_status status,
-                                void *userdata)
+                                int status, void *userdata)
 {
     auto* self = static_cast<MediaTreeListener*>( userdata );
     self->cb->onItemPreparseEnded( self->tree, node, status );


=====================================
modules/gui/qt/network/mediatreelistener.hpp
=====================================
@@ -46,7 +46,7 @@ public:
         virtual void onItemCleared( MediaTreePtr tree, input_item_node_t* node ) = 0;
         virtual void onItemAdded( MediaTreePtr tree, input_item_node_t* parent, input_item_node_t *const children[], size_t count ) = 0;
         virtual void onItemRemoved( MediaTreePtr tree, input_item_node_t* node, input_item_node_t *const children[], size_t count ) = 0;
-        virtual void onItemPreparseEnded( MediaTreePtr tree, input_item_node_t* node, enum input_item_preparse_status status ) = 0;
+        virtual void onItemPreparseEnded( MediaTreePtr tree, input_item_node_t* node, int status ) = 0;
     };
 
 public:


=====================================
modules/gui/qt/network/networkmediamodel.cpp
=====================================
@@ -476,7 +476,7 @@ struct NetworkMediaModel::ListenerCb : public MediaTreeListener::MediaTreeListen
     void onItemCleared( MediaTreePtr tree, input_item_node_t* node ) override;
     void onItemAdded( MediaTreePtr tree, input_item_node_t* parent, input_item_node_t *const children[], size_t count ) override;
     void onItemRemoved( MediaTreePtr tree, input_item_node_t * node, input_item_node_t *const children[], size_t count ) override;
-    void onItemPreparseEnded( MediaTreePtr tree, input_item_node_t* node, enum input_item_preparse_status status ) override;
+    void onItemPreparseEnded( MediaTreePtr tree, input_item_node_t* node, int status ) override;
 
     NetworkMediaModel *model;
 };
@@ -920,7 +920,7 @@ void NetworkMediaModel::ListenerCb::onItemRemoved( MediaTreePtr, input_item_node
     }, Qt::QueuedConnection);
 }
 
-void NetworkMediaModel::ListenerCb::onItemPreparseEnded(MediaTreePtr, input_item_node_t* node, enum input_item_preparse_status )
+void NetworkMediaModel::ListenerCb::onItemPreparseEnded(MediaTreePtr, input_item_node_t* node, int )
 {
     model->d_func()->m_preparseSem.release();
     SharedInputItem p_node { node->p_item };


=====================================
modules/gui/qt/player/player_controller.cpp
=====================================
@@ -1021,11 +1021,11 @@ static void on_player_timer_smpte_update(const struct vlc_player_timer_smpte_tim
 }
 
 
-static void on_art_fetch_ended_callback(input_item_t *p_item, bool fetched,
-                                     void *userdata)
+static void on_preparse_ended_callback(input_item_t *p_item,
+                                       int, void *userdata)
 {
     PlayerControllerPrivate *me = reinterpret_cast<PlayerControllerPrivate *>(userdata);
-    me->onArtFetchEnded(p_item, fetched);
+    me->onArtFetchEnded(p_item, input_item_IsArtFetched(p_item));
 }
 
 
@@ -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_art_fetch_ended = on_art_fetch_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;
 }();
 


=====================================
src/media_source/media_tree.c
=====================================
@@ -170,9 +170,7 @@ media_subtree_changed(input_item_t *media, input_item_node_t *node,
 }
 
 static void
-media_subtree_preparse_ended(input_item_t *media,
-                             enum input_item_preparse_status status,
-                             void *user_data)
+media_subtree_preparse_ended(input_item_t *media, int status, void *user_data)
 {
     vlc_media_tree_t *tree = user_data;
 
@@ -335,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
@@ -351,7 +349,7 @@ vlc_media_tree_Preparse(vlc_media_tree_t *tree, vlc_preparser_t *parser,
     VLC_UNUSED(id);
     VLC_UNUSED(preparser_callbacks);
 #else
-    vlc_preparser_Push(parser, media, META_REQUEST_OPTION_SCOPE_ANY |
+    vlc_preparser_Push(parser, media, META_REQUEST_OPTION_PARSE |
                        META_REQUEST_OPTION_DO_INTERACT |
                        META_REQUEST_OPTION_PARSE_SUBITEMS,
                        &preparser_callbacks, tree, 0, id);


=====================================
src/playlist/preparse.c
=====================================
@@ -88,13 +88,12 @@ on_subtree_added(input_item_t *media, input_item_node_t *subtree,
 }
 
 static void
-on_preparse_ended(input_item_t *media,
-                  enum input_item_preparse_status status, void *userdata)
+on_preparse_ended(input_item_t *media, int status, void *userdata)
 {
     VLC_UNUSED(media); /* retrieved by subtree->p_item */
     vlc_playlist_t *playlist = userdata;
 
-    if (status != ITEM_PREPARSE_DONE)
+    if (status != VLC_SUCCESS)
         return;
 
     vlc_playlist_Lock(playlist);
@@ -105,8 +104,8 @@ on_preparse_ended(input_item_t *media,
     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,
 };
 
@@ -133,8 +132,25 @@ vlc_playlist_AutoPreparse(vlc_playlist_t *playlist, input_item_t *input,
             default: vlc_assert_unreachable();
         }
 
+        bool input_net;
+        enum input_item_type_e input_type = input_item_GetType(input, &input_net);
+
+        if (input_net)
+            return;
+
+        switch (input_type)
+        {
+            case ITEM_TYPE_NODE:
+            case ITEM_TYPE_FILE:
+            case ITEM_TYPE_DIRECTORY:
+            case ITEM_TYPE_PLAYLIST:
+                break;
+            default:
+                return;
+        }
+
         input_item_meta_request_option_t options =
-            META_REQUEST_OPTION_SCOPE_LOCAL | META_REQUEST_OPTION_FETCH_LOCAL;
+            META_REQUEST_OPTION_PARSE | META_REQUEST_OPTION_FETCH_LOCAL;
         if (parse_subitems)
             options |= META_REQUEST_OPTION_PARSE_SUBITEMS;
 


=====================================
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);
@@ -90,7 +90,7 @@ TaskNew(vlc_preparser_t *preparser, input_item_t *item,
 
     task->parser = NULL;
     vlc_sem_init(&task->preparse_ended, 0);
-    atomic_init(&task->preparse_status, ITEM_PREPARSE_SKIPPED);
+    atomic_init(&task->preparse_status, VLC_EGENERIC);
     atomic_init(&task->interrupted, false);
 
     task->runnable.run = RunnableRun;
@@ -125,18 +125,14 @@ PreparserRemoveTask(vlc_preparser_t *preparser, struct task *task)
 static void
 NotifyPreparseEnded(struct task *task, bool art_fetched)
 {
+    (void) art_fetched;
     if (task->cbs == NULL)
         return;
 
-    if (task->options & META_REQUEST_OPTION_FETCH_ANY
-     && task->cbs->on_art_fetch_ended)
-        task->cbs->on_art_fetch_ended(task->item, art_fetched,
-                                      task->userdata);
-
-    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);
     }
 }
 
@@ -153,9 +149,7 @@ OnParserEnded(input_item_t *item, int status, void *task_)
          */
         return;
 
-    atomic_store_explicit(&task->preparse_status,
-                          status == VLC_SUCCESS ? ITEM_PREPARSE_DONE
-                                                : ITEM_PREPARSE_FAILED,
+    atomic_store_explicit(&task->preparse_status, status,
                           memory_order_relaxed);
     vlc_sem_post(&task->preparse_ended);
 }
@@ -188,7 +182,7 @@ SetItemPreparsed(struct task *task)
 {
     int status = atomic_load_explicit(&task->preparse_status,
                                       memory_order_relaxed);
-    if (status == ITEM_PREPARSE_DONE)
+    if (status == VLC_SUCCESS)
         input_item_SetPreparsed(task->item);
 }
 
@@ -230,7 +224,7 @@ Parse(struct task *task, vlc_tick_t deadline)
     task->parser = input_item_Parse(obj, task->item, &cfg);
     if (!task->parser)
     {
-        atomic_store_explicit(&task->preparse_status, ITEM_PREPARSE_FAILED,
+        atomic_store_explicit(&task->preparse_status, VLC_EGENERIC,
                               memory_order_relaxed);
         return;
     }
@@ -242,7 +236,7 @@ Parse(struct task *task, vlc_tick_t deadline)
         if (vlc_sem_timedwait(&task->preparse_ended, deadline))
         {
             atomic_store_explicit(&task->preparse_status,
-                                  ITEM_PREPARSE_TIMEOUT, memory_order_relaxed);
+                                  VLC_ETIMEOUT, memory_order_relaxed);
             atomic_store(&task->interrupted, true);
         }
 
@@ -273,8 +267,7 @@ RunnableRun(void *userdata)
     vlc_tick_t deadline = task->timeout ? vlc_tick_now() + task->timeout
                                         : VLC_TICK_INVALID;
 
-    if (task->options & (META_REQUEST_OPTION_SCOPE_ANY|
-                         META_REQUEST_OPTION_SCOPE_FORCED))
+    if (task->options & META_REQUEST_OPTION_PARSE)
     {
         if (atomic_load(&task->interrupted))
         {
@@ -309,7 +302,7 @@ Interrupt(struct task *task)
     atomic_store(&task->interrupted, true);
 
     /* Wake up the preparser cond_wait */
-    atomic_store_explicit(&task->preparse_status, ITEM_PREPARSE_TIMEOUT,
+    atomic_store_explicit(&task->preparse_status, VLC_ETIMEOUT,
                           memory_order_relaxed);
     vlc_sem_post(&task->preparse_ended);
 }
@@ -348,41 +341,14 @@ 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 ) )
         return VLC_EGENERIC;
 
-    vlc_mutex_lock( &item->lock );
-    enum input_item_type_e i_type = item->i_type;
-    int b_net = item->b_net;
-    vlc_mutex_unlock( &item->lock );
-
-    if (!(i_options & META_REQUEST_OPTION_SCOPE_FORCED))
-    {
-        switch( i_type )
-        {
-            case ITEM_TYPE_NODE:
-            case ITEM_TYPE_FILE:
-            case ITEM_TYPE_DIRECTORY:
-            case ITEM_TYPE_PLAYLIST:
-                if( !b_net || i_options & META_REQUEST_OPTION_SCOPE_NETWORK )
-                    break;
-                /* fallthrough */
-            default:
-                if( ( i_options & META_REQUEST_OPTION_FETCH_ANY ) == 0 )
-                {
-                    /* Nothing to do (no preparse and not fetch), notify it */
-                    if (cbs && cbs->on_preparse_ended)
-                        cbs->on_preparse_ended(item, ITEM_PREPARSE_SKIPPED,
-                                               cbs_userdata);
-                    return VLC_SUCCESS;
-                }
-                /* Continue without parsing (but fetching) */
-                i_options &= ~META_REQUEST_OPTION_SCOPE_ANY;
-        }
-    }
+    assert(i_options & META_REQUEST_OPTION_PARSE
+        || i_options & META_REQUEST_OPTION_FETCH_ANY);
 
     vlc_tick_t timeout = timeout_ms == -1 ? preparser->default_timeout
                                           : VLC_TICK_FROM_MS(timeout_ms);


=====================================
test/libvlc/media.c
=====================================
@@ -209,13 +209,12 @@ static void test_media_tracks(libvlc_instance_t *vlc)
 }
 
 static void input_item_preparse_timeout( input_item_t *item,
-                                         enum input_item_preparse_status status,
-                                         void *user_data )
+                                         int status, void *user_data )
 {
     VLC_UNUSED(item);
     vlc_sem_t *p_sem = user_data;
 
-    assert( status == ITEM_PREPARSE_TIMEOUT );
+    assert( status == VLC_ETIMEOUT );
     vlc_sem_post(p_sem);
 }
 
@@ -237,15 +236,15 @@ 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),
                                                 1, VLC_TICK_FROM_MS(timeout));
     assert(parser != NULL);
     i_ret = vlc_preparser_Push(parser, p_item,
-                               META_REQUEST_OPTION_SCOPE_LOCAL |
+                               META_REQUEST_OPTION_PARSE |
                                META_REQUEST_OPTION_FETCH_LOCAL,
                                &cbs, &sem, -1, parser);
     assert(i_ret == 0);



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/82df5e7f237329cfbeb9ee336a6cf61dc4700469...cdeea0392004995d437919d910d243299ca46065

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/82df5e7f237329cfbeb9ee336a6cf61dc4700469...cdeea0392004995d437919d910d243299ca46065
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list