Commit 3fdba303 authored by Hugo Beauzée-Luyssen's avatar 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.
parent 6c8f8195
......@@ -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
......@@ -436,6 +436,18 @@ VLC_API input_item_parser_id_t *
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
*
......
......@@ -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);
}
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment