[vlc-devel] [PATCH 1/2] playlist/fetcher: interrupt fetcher thread on exit
Thomas Guillem
thomas at gllm.fr
Tue Mar 29 14:04:26 CEST 2016
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.
---
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;
--
2.8.0.rc3
More information about the vlc-devel
mailing list