[vlc-devel] [PATCH 6/9] preparser: add playlist_preparser_Cancel
Rémi Denis-Courmont
remi at remlab.net
Wed Jun 1 16:25:21 CEST 2016
Le 2016-06-01 13:24, Thomas Guillem a écrit :
> ---
> src/playlist/preparser.c | 23 +++++++++++++++++++++++
> src/playlist/preparser.h | 8 ++++++++
> 2 files changed, 31 insertions(+)
>
> diff --git a/src/playlist/preparser.c b/src/playlist/preparser.c
> index a5751c5..13d5d3c 100644
> --- a/src/playlist/preparser.c
> +++ b/src/playlist/preparser.c
> @@ -116,6 +116,29 @@ void playlist_preparser_fetcher_Push(
> playlist_preparser_t *p_preparser,
> playlist_fetcher_Push( p_preparser->p_fetcher, p_item,
> i_options );
> }
>
> +void playlist_preparser_Cancel( playlist_preparser_t *p_preparser,
> + input_item_t *p_item )
> +{
> + vlc_mutex_lock( &p_preparser->lock );
> + /* Remove the item from the queue (if present) */
> + for( unsigned int i = 0; i < p_preparser->i_waiting; ++i )
> + {
> + preparser_entry_t *p_entry = p_preparser->pp_waiting[0];
> + if( p_entry->p_item == p_item )
> + {
> + vlc_gc_decref( p_entry->p_item );
> + free( p_entry );
> + REMOVE_ELEM( p_preparser->pp_waiting,
> p_preparser->i_waiting, i );
> + break;
> + }
> + }
> + /* Stop the input_thread reading the item (if any) */
> + if( p_preparser->input != NULL
> + && input_GetItem( p_preparser->input ) == p_item )
> + input_Stop( p_preparser->input );
> + vlc_mutex_unlock( &p_preparser->lock );
> +}
> +
Items are reference counted, so you can have a situation where more
than one something wants to preparse the same item. So, you can't just
cancel it like that.
> void playlist_preparser_Delete( playlist_preparser_t *p_preparser )
> {
> vlc_mutex_lock( &p_preparser->lock );
> diff --git a/src/playlist/preparser.h b/src/playlist/preparser.h
> index fabb57b..996756b 100644
> --- a/src/playlist/preparser.h
> +++ b/src/playlist/preparser.h
> @@ -55,6 +55,14 @@ void playlist_preparser_fetcher_Push(
> playlist_preparser_t *, input_item_t *,
>
> input_item_meta_request_option_t );
>
> /**
> + * This function cancel the preparsing for a given input item.
> + *
> + * This does nothing if the input item is already processed or if it
> was not
> + * added with playlist_preparser_Push()
> + */
> +void playlist_preparser_Cancel( playlist_preparser_t *, input_item_t
> * );
> +
> +/**
> * This function destroys the preparser object and thread.
> *
> * All pending input items will be released.
--
Rémi Denis-Courmont
http://www.remlab.net/
More information about the vlc-devel
mailing list