[vlc-commits] preparser: start and wait for input thread explicitly
Rémi Denis-Courmont
git at videolan.org
Wed Oct 28 18:47:49 CET 2015
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed Oct 28 19:23:12 2015 +0200| [c53708ad344cd5da7cfff9ca6d34921248318123] | committer: Rémi Denis-Courmont
preparser: start and wait for input thread explicitly
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=c53708ad344cd5da7cfff9ca6d34921248318123
---
src/input/var.c | 7 ++-----
src/playlist/preparser.c | 49 ++++++++++++++++++++++++++++++++++------------
2 files changed, 38 insertions(+), 18 deletions(-)
diff --git a/src/input/var.c b/src/input/var.c
index 47f4b88..f5ce212 100644
--- a/src/input/var.c
+++ b/src/input/var.c
@@ -212,11 +212,8 @@ void input_ControlVarInit ( input_thread_t *p_input )
var_Create( p_input, "bit-rate", VLC_VAR_INTEGER );
var_Create( p_input, "sample-rate", VLC_VAR_INTEGER );
- if( !p_input->b_preparsing )
- {
- /* Special "intf-event" variable. */
- var_Create( p_input, "intf-event", VLC_VAR_INTEGER );
- }
+ /* Special "intf-event" variable. */
+ var_Create( p_input, "intf-event", VLC_VAR_INTEGER );
/* Add all callbacks
* XXX we put callback only in non preparsing mode. We need to create the variable
diff --git a/src/playlist/preparser.c b/src/playlist/preparser.c
index f1c1d1f..61fc0f6 100644
--- a/src/playlist/preparser.c
+++ b/src/playlist/preparser.c
@@ -139,10 +139,24 @@ void playlist_preparser_Delete( playlist_preparser_t *p_preparser )
/*****************************************************************************
* Privates functions
*****************************************************************************/
+
+static int InputEvent( vlc_object_t *obj, const char *varname,
+ vlc_value_t old, vlc_value_t cur, void *data )
+{
+ vlc_sem_t *done = data;
+ int event = cur.i_int;
+
+ if( event == INPUT_EVENT_DEAD )
+ vlc_sem_post( done );
+
+ (void) obj; (void) varname; (void) old;
+ return VLC_SUCCESS;
+}
+
/**
* This function preparses an item when needed.
*/
-static void Preparse( vlc_object_t *obj, input_item_t *p_item,
+static void Preparse( playlist_preparser_t *preparser, input_item_t *p_item,
input_item_meta_request_option_t i_options )
{
vlc_mutex_lock( &p_item->lock );
@@ -160,21 +174,31 @@ static void Preparse( vlc_object_t *obj, input_item_t *p_item,
b_preparse = true;
break;
}
- if( !b_preparse )
- {
- input_item_SetPreparsed( p_item, true );
- input_item_SignalPreparseEnded( p_item );
- return;
- }
/* Do not preparse if it is already done (like by playing it) */
- if( !input_item_IsPreparsed( p_item ) )
+ if( b_preparse && !input_item_IsPreparsed( p_item ) )
{
- input_Preparse( obj, p_item );
- input_item_SetPreparsed( p_item, true );
+ input_thread_t *input = input_CreatePreparser( preparser->object,
+ p_item );
+ if( input == NULL )
+ return;
+
+ vlc_sem_t done;
+
+ vlc_sem_init( &done, 0 );
+ var_AddCallback( input, "intf-event", InputEvent, &done );
+
+ if( input_Start( input ) == VLC_SUCCESS )
+ vlc_sem_wait( &done );
- var_SetAddress( obj, "item-change", p_item );
+ var_DelCallback( input, "intf-event", InputEvent, &done );
+ vlc_sem_destroy( &done );
+ input_Close( input );
+
+ var_SetAddress( preparser->object, "item-change", p_item );
}
+
+ input_item_SetPreparsed( p_item, true );
input_item_SignalPreparseEnded( p_item );
}
@@ -225,7 +249,6 @@ static void Art( playlist_preparser_t *p_preparser, input_item_t *p_item )
static void *Thread( void *data )
{
playlist_preparser_t *p_preparser = data;
- vlc_object_t *obj = p_preparser->object;
for( ;; )
{
@@ -253,7 +276,7 @@ static void *Thread( void *data )
if( !p_current )
break;
- Preparse( obj, p_current, i_options );
+ Preparse( p_preparser, p_current, i_options );
Art( p_preparser, p_current );
vlc_gc_decref(p_current);
More information about the vlc-commits
mailing list