- mutex_cleanup_push( &p_preparser->lock );
-
- while( p_preparser->i_waiting == 0 )
- vlc_cond_wait( &p_preparser->wait, &p_preparser->lock );
-
- p_current = p_preparser->pp_waiting[0];
- REMOVE_ELEM( p_preparser->pp_waiting, p_preparser->i_waiting, 0 );
- vlc_cleanup_run( );
+ if( p_preparser->i_waiting > 0 )
+ {
+ p_current = p_preparser->pp_waiting[0];
+ REMOVE_ELEM( p_preparser->pp_waiting, p_preparser->i_waiting, 0 );
+ }
+ else
+ {
+ p_current = NULL;
+ p_preparser->b_live = false;
+ vlc_cond_signal( &p_preparser->wait );
+ }
+ vlc_mutex_unlock( &p_preparser->lock );