[vlc-devel] [vlc-commits] playlist/fetcher: interrupt fetcher thread on exit
Thomas Guillem
thomas at gllm.fr
Tue Apr 5 19:22:47 CEST 2016
On Mon, Apr 4, 2016, at 09:55, Thomas Guillem wrote:
> vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Tue Mar 29
> 13:47:35 2016 +0200| [7f8d972a2b0ff62ef02a9d562a9a8299dd2eb985] |
> committer: Thomas Guillem
>
> playlist/fetcher: interrupt fetcher thread on exit
>
> This unblocks playlist_fetcher_Delete if a task is blocked on I/O.
>
> This doesn't prevent a task to block all next tasks on a normal run.
>
> > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=7f8d972a2b0ff62ef02a9d562a9a8299dd2eb985
> ---
>
> src/playlist/fetcher.c | 16 ++++++++++++++++
> 1 file changed, 16 insertions(+)
>
> diff --git a/src/playlist/fetcher.c b/src/playlist/fetcher.c
> index a8b7b11..9baf3b7 100644
> --- a/src/playlist/fetcher.c
> +++ b/src/playlist/fetcher.c
> @@ -34,6 +34,7 @@
> #include <vlc_memory.h>
> #include <vlc_demux.h>
> #include <vlc_modules.h>
> +#include <vlc_interrupt.h>
>
> #include "libvlc.h"
> #include "art.h"
> @@ -75,6 +76,7 @@ struct playlist_fetcher_t
> vlc_mutex_t lock;
> vlc_cond_t wait;
> bool b_live;
> + vlc_interrupt_t *interrupt;
>
> fetcher_entry_t *p_waiting_head[PASS_COUNT];
> fetcher_entry_t *p_waiting_tail[PASS_COUNT];
> @@ -95,6 +97,12 @@ playlist_fetcher_t *playlist_fetcher_New( vlc_object_t
> *parent )
> if( !p_fetcher )
> return NULL;
>
> + p_fetcher->interrupt = vlc_interrupt_create();
> + if( unlikely(p_fetcher->interrupt == NULL) )
> + {
> + free( p_fetcher );
> + return NULL;
> + }
> p_fetcher->object = parent;
> vlc_mutex_init( &p_fetcher->lock );
> vlc_cond_init( &p_fetcher->wait );
> @@ -148,6 +156,9 @@ void playlist_fetcher_Push( playlist_fetcher_t
> *p_fetcher, input_item_t *p_item,
> void playlist_fetcher_Delete( playlist_fetcher_t *p_fetcher )
> {
> fetcher_entry_t *p_next;
> +
> + vlc_interrupt_kill(p_fetcher->interrupt);
> +
> vlc_mutex_lock( &p_fetcher->lock );
> /* Remove any left-over item, the fetcher will exit */
> for ( int i_queue=0; i_queue<PASS_COUNT; i_queue++ )
> @@ -169,6 +180,8 @@ void playlist_fetcher_Delete( playlist_fetcher_t
> *p_fetcher )
> vlc_cond_destroy( &p_fetcher->wait );
> vlc_mutex_destroy( &p_fetcher->lock );
>
> + vlc_interrupt_destroy( p_fetcher->interrupt );
> +
> playlist_album_t album;
> FOREACH_ARRAY( album, p_fetcher->albums )
> free( album.psz_album );
> @@ -437,6 +450,9 @@ static void *Thread( void *p_data )
> playlist_fetcher_t *p_fetcher = p_data;
> vlc_object_t *obj = p_fetcher->object;
> fetcher_pass_t e_pass = PASS1_LOCAL;
> +
> + vlc_interrupt_set(p_fetcher->interrupt);
> +
> for( ;; )
> {
> fetcher_entry_t *p_entry = NULL;
My commit is breaking the libvlc_media test, but it's not systematic:
test_libvlc_media: ../../src/misc/interrupt.c:99: vlc_interrupt_deinit:
Assertion `!ctx->attached' failed.
Is it wrong or have I missed something with vlc_interrupt API ?
>
> _______________________________________________
> vlc-commits mailing list
> vlc-commits at videolan.org
> https://mailman.videolan.org/listinfo/vlc-commits
More information about the vlc-devel
mailing list