[vlc-devel] [PATCH 2/3] preparser: Don't ignore input_preparser_Push errors

Hugo Beauzée-Luyssen hugo at beauzee.fr
Fri Nov 13 14:07:03 CET 2020


---
 src/libvlc.c              | 5 ++---
 src/preparser/preparser.c | 9 +++++----
 src/preparser/preparser.h | 5 ++++-
 3 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/src/libvlc.c b/src/libvlc.c
index c1dcde276d..b4d0758325 100644
--- a/src/libvlc.c
+++ b/src/libvlc.c
@@ -461,9 +461,8 @@ int vlc_MetadataRequest(libvlc_int_t *libvlc, input_item_t *item,
     if (unlikely(priv->parser == NULL))
         return VLC_ENOMEM;
 
-    input_preparser_Push( priv->parser, item, i_options, cbs, cbs_userdata, timeout, id );
-    return VLC_SUCCESS;
-
+    return input_preparser_Push( priv->parser, item, i_options, cbs,
+                                 cbs_userdata, timeout, id );
 }
 
 /**
diff --git a/src/preparser/preparser.c b/src/preparser/preparser.c
index 0dbd4853d5..5692e354e0 100644
--- a/src/preparser/preparser.c
+++ b/src/preparser/preparser.c
@@ -333,13 +333,13 @@ input_preparser_t* input_preparser_New( vlc_object_t *parent )
     return preparser;
 }
 
-void input_preparser_Push( input_preparser_t *preparser,
+int input_preparser_Push( input_preparser_t *preparser,
     input_item_t *item, input_item_meta_request_option_t i_options,
     const input_preparser_callbacks_t *cbs, void *cbs_userdata,
     int timeout_ms, void *id )
 {
     if( atomic_load( &preparser->deactivated ) )
-        return;
+        return VLC_EGENERIC;
 
     vlc_mutex_lock( &item->lock );
     enum input_item_type_e i_type = item->i_type;
@@ -360,7 +360,7 @@ void input_preparser_Push( input_preparser_t *preparser,
         default:
             if (cbs && cbs->on_preparse_ended)
                 cbs->on_preparse_ended(item, ITEM_PREPARSE_SKIPPED, cbs_userdata);
-            return;
+            return VLC_SUCCESS;
     }
 
     vlc_tick_t timeout = timeout_ms == -1 ? preparser->default_timeout
@@ -368,11 +368,12 @@ void input_preparser_Push( input_preparser_t *preparser,
     struct task *task =
         TaskNew(preparser, item, i_options, cbs, cbs_userdata, id, timeout);
     if( !task )
-        return;
+        return VLC_ENOMEM;
 
     PreparserAddTask(preparser, task);
 
     vlc_executor_Submit(preparser->executor, &task->runnable);
+    return VLC_SUCCESS;
 }
 
 void input_preparser_fetcher_Push( input_preparser_t *preparser,
diff --git a/src/preparser/preparser.h b/src/preparser/preparser.h
index 92c65eeff5..f0dc8e03c5 100644
--- a/src/preparser/preparser.h
+++ b/src/preparser/preparser.h
@@ -50,8 +50,11 @@ input_preparser_t *input_preparser_New( vlc_object_t * );
  * indefinitely. If > 0, the timeout will be used (in milliseconds).
  * @param id unique id provided by the caller. This is can be used to cancel
  * the request with input_preparser_Cancel()
+ * @returns VLC_SUCCESS if the item was scheduled for preparsing, an error code
+ * otherwise
+ * If this returns an error, the on_preparse_ended will *not* be invoked
  */
-void input_preparser_Push( input_preparser_t *, input_item_t *,
+int input_preparser_Push( input_preparser_t *, input_item_t *,
                            input_item_meta_request_option_t,
                            const input_preparser_callbacks_t *cbs,
                            void *cbs_userdata,
-- 
2.29.2



More information about the vlc-devel mailing list