[vlc-commits] input: Add input_item_parser_id_Interrupt

Hugo Beauzée-Luyssen git at videolan.org
Fri Jun 21 13:55:11 CEST 2019


vlc | branch: master | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Thu Jun 20 14:34:50 2019 +0200| [3fdba3030b1b2a473ac2f619e030e365caf0d581] | committer: Hugo Beauzée-Luyssen

input: Add input_item_parser_id_Interrupt

This effectively split input_item_parser_id_Release in 2 functions,
allowing an asynchronous cancellation to occur.
Otherwise, the input thread would invoke the callback synchronously
while the thread cancelling the preparser is blocked joining the input
thread. Both those thread are very likely to be called with a mutex
held, which would cause a deadlock.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=3fdba3030b1b2a473ac2f619e030e365caf0d581
---

 include/vlc_input_item.h | 14 +++++++++++++-
 src/input/item.c         |  8 +++++++-
 src/libvlccore.sym       |  1 +
 3 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/include/vlc_input_item.h b/include/vlc_input_item.h
index b68c24dc49..1e94b842a2 100644
--- a/include/vlc_input_item.h
+++ b/include/vlc_input_item.h
@@ -421,7 +421,7 @@ typedef struct input_item_parser_cbs_t
  * Parse an item asynchronously
  *
  * @note The parsing is done asynchronously. The user can call
- * input_item_parser_id_Release() before receiving the on_ended() event in
+ * input_item_parser_id_Interrupt() before receiving the on_ended() event in
  * order to interrupt it.
  *
  * @param item the item to parse
@@ -437,6 +437,18 @@ input_item_Parse(input_item_t *item, vlc_object_t *parent,
                  const input_item_parser_cbs_t *cbs, void *userdata) VLC_USED;
 
 /**
+ * Interrupts & cancels the parsing
+ *
+ * @note The parser still needs to be released with input_item_parser_id_Release
+ * afterward.
+ * @note Calling this function will cause the on_ended callback to be invoked.
+ *
+ * @param the parser to interrupt
+ */
+VLC_API void
+input_item_parser_id_Interrupt(input_item_parser_id_t *parser);
+
+/**
  * Release (and interrupt if needed) a parser
  *
  * @param parser the parser returned by input_item_Parse
diff --git a/src/input/item.c b/src/input/item.c
index ac79336540..b1b92cdf9b 100644
--- a/src/input/item.c
+++ b/src/input/item.c
@@ -1405,9 +1405,15 @@ input_item_Parse(input_item_t *item, vlc_object_t *obj,
 }
 
 void
-input_item_parser_id_Release(input_item_parser_id_t *parser)
+input_item_parser_id_Interrupt(input_item_parser_id_t *parser)
 {
     input_Stop(parser->input);
+}
+
+void
+input_item_parser_id_Release(input_item_parser_id_t *parser)
+{
+    input_item_parser_id_Interrupt(parser);
     input_Close(parser->input);
     free(parser);
 }
diff --git a/src/libvlccore.sym b/src/libvlccore.sym
index 6c59e1b6fc..64a6c0123b 100644
--- a/src/libvlccore.sym
+++ b/src/libvlccore.sym
@@ -204,6 +204,7 @@ input_item_slave_GetType
 input_item_slave_New
 input_item_AddSlave
 input_item_Parse
+input_item_parser_id_Interrupt
 input_item_parser_id_Release
 input_resource_New
 input_resource_Release



More information about the vlc-commits mailing list