Fixed preparsing/art fetching locking.
authorLaurent Aimar <fenrir@videolan.org>
Tue, 23 Dec 2008 15:26:51 +0000 (16:26 +0100)
committerLaurent Aimar <fenrir@videolan.org>
Mon, 5 Jan 2009 19:49:11 +0000 (20:49 +0100)
include/vlc_playlist.h
modules/gui/macosx/playlist.m
modules/gui/macosx/playlistinfo.m
modules/gui/qt4/components/interface_widgets.cpp
modules/gui/qt4/components/interface_widgets.hpp
modules/gui/wxwidgets/dialogs/playlist.cpp
src/control/media.c
src/playlist/control.c
src/playlist/item.c
src/playlist/thread.c

index 11cf3e6..1b0d348 100644 (file)
@@ -264,10 +264,10 @@ VLC_EXPORT( input_thread_t *, playlist_CurrentInput, ( playlist_t *p_playlist )
 VLC_EXPORT( void,  playlist_Clear, ( playlist_t *, bool ) );
 
 /** Enqueue an input item for preparsing */
-VLC_EXPORT( int, playlist_PreparseEnqueue, (playlist_t *, input_item_t *) );
+VLC_EXPORT( int, playlist_PreparseEnqueue, (playlist_t *, input_item_t *, bool b_locked ) );
 
 /** Request the art for an input item to be fetched */
-VLC_EXPORT( int, playlist_AskForArtEnqueue, (playlist_t *, input_item_t *) );
+VLC_EXPORT( int, playlist_AskForArtEnqueue, (playlist_t *, input_item_t *, bool b_locked ) );
 
 /* Playlist sorting */
 VLC_EXPORT( int,  playlist_TreeMove, ( playlist_t *, playlist_item_t *, playlist_item_t *, int ) );
index 1ab42bb..e47cd30 100644 (file)
         {
             if( p_item->i_children == -1 )
             {
-                playlist_PreparseEnqueue( p_playlist, p_item->p_input );
+                playlist_PreparseEnqueue( p_playlist, p_item->p_input, pl_Unlocked );
             }
             else
             {
 
         if( p_item && p_item->i_children == -1 )
         {
-            playlist_AskForArtEnqueue( p_playlist, p_item->p_input );
+            playlist_AskForArtEnqueue( p_playlist, p_item->p_input, pl_Unlocked );
         }
     }
     vlc_object_release( p_playlist );
index 8822305..a32e6da 100644 (file)
@@ -249,7 +249,7 @@ static VLCInfo *_o_sharedInstance = nil;
         if( !input_item_IsPreparsed( p_item ) )
         {
             playlist_t * p_playlist = pl_Hold( VLCIntf );
-            playlist_PreparseEnqueue( p_playlist, p_item );
+            playlist_PreparseEnqueue( p_playlist, p_item, pl_Unlocked );
             pl_Release( VLCIntf );
         }
 
@@ -428,7 +428,7 @@ error:
 - (IBAction)downloadCoverArt:(id)sender
 {
     playlist_t * p_playlist = pl_Hold( VLCIntf );
-    if( p_item) playlist_AskForArtEnqueue( p_playlist, p_item );
+    if( p_item) playlist_AskForArtEnqueue( p_playlist, p_item, pl_Unlocked );
     pl_Release( VLCIntf );
 }
 
index 2d47104..69b2ace 100644 (file)
@@ -447,12 +447,22 @@ CoverArtLabel::CoverArtLabel( QWidget *parent,
     doUpdate();
 }
 
+CoverArtLabel::~CoverArtLabel()
+{
+    playlist_t *p_playlist = pl_Hold( p_this );
+    var_DelCallback( p_playlist, "item-change", downloadCoverCallback, this );
+    pl_Release( p_this );
+
+    if( p_input )
+        vlc_gc_decref( p_input );
+};
+
 void CoverArtLabel::downloadCover()
 {
     if( p_input )
     {
         playlist_t *p_playlist = pl_Hold( p_this );
-        playlist_AskForArtEnqueue( p_playlist, p_input );
+        playlist_AskForArtEnqueue( p_playlist, p_input, pl_Unlocked );
         pl_Release( p_this );
     }
 }
index 09ec267..746b147 100644 (file)
@@ -196,8 +196,8 @@ public:
     CoverArtLabel( QWidget *parent,
                    vlc_object_t *p_this,
                    input_item_t *p_input = NULL );
-    virtual ~CoverArtLabel()
-    { if( p_input ) vlc_gc_decref( p_input ); }
+    virtual ~CoverArtLabel();
+
 private:
     input_item_t *p_input;
     vlc_object_t *p_this;
index e72387d..d819a19 100644 (file)
@@ -1511,7 +1511,7 @@ void Playlist::Preparse()
     {
         if( p_popup_item->i_children == -1 )
         {
-            playlist_PreparseEnqueue( p_playlist, p_popup_item->p_input );
+            playlist_PreparseEnqueue( p_playlist, p_popup_item->p_input, pl_Unlocked );
         }
         else
         {
index 0192227..34f61aa 100644 (file)
@@ -216,7 +216,7 @@ static void preparse_if_needed( libvlc_media_t *p_md )
     {
         playlist_PreparseEnqueue(
                 libvlc_priv (p_md->p_libvlc_instance->p_libvlc_int)->p_playlist,
-                p_md->p_input_item );
+                p_md->p_input_item, pl_Unlocked );
         p_md->b_preparsed = true;
     }
 }
@@ -436,7 +436,7 @@ char * libvlc_media_get_meta( libvlc_media_t *p_md,
     {
         playlist_AskForArtEnqueue(
                 libvlc_priv(p_md->p_libvlc_instance->p_libvlc_int)->p_playlist,
-                p_md->p_input_item );
+                p_md->p_input_item, pl_Unlocked );
     }
 
     /* Should be integrated in core */
index 8aa5760..f340d58 100644 (file)
@@ -186,27 +186,27 @@ static int PlaylistVAControl( playlist_t * p_playlist, int i_query, va_list args
  *****************************************************************************/
 /** Enqueue an item for preparsing */
 int playlist_PreparseEnqueue( playlist_t *p_playlist,
-                              input_item_t *p_item )
+                              input_item_t *p_item, bool b_locked )
 {
     playlist_private_t *p_sys = pl_priv(p_playlist);
 
-    PL_LOCK;
+    PL_LOCK_IF( !b_locked );
     if( p_sys->p_preparser )
         playlist_preparser_Push( p_sys->p_preparser, p_item );
-    PL_UNLOCK;
+    PL_UNLOCK_IF( !b_locked );
 
     return VLC_SUCCESS;
 }
 
 int playlist_AskForArtEnqueue( playlist_t *p_playlist,
-                               input_item_t *p_item )
+                               input_item_t *p_item, bool b_locked )
 {
     playlist_private_t *p_sys = pl_priv(p_playlist);
 
-    PL_LOCK;
+    PL_LOCK_IF( !b_locked );
     if( p_sys->p_fetcher )
         playlist_fetcher_Push( p_sys->p_fetcher, p_item );
-    PL_UNLOCK;
+    PL_UNLOCK_IF( !b_locked );
 
     return VLC_SUCCESS;
 }
index 28ad321..55ed4da 100644 (file)
@@ -849,7 +849,7 @@ static void GoAndPreparse( playlist_t *p_playlist, int i_mode,
           ( i_mode & PLAYLIST_SPREPARSE &&
             ( EMPTY_STR( psz_artist ) || ( EMPTY_STR( psz_album ) ) )
           ) ) )
-        playlist_PreparseEnqueue( p_playlist, p_item_cat->p_input );
+        playlist_PreparseEnqueue( p_playlist, p_item_cat->p_input, pl_Locked );
     /* If we already have it, signal it */
     else if( !EMPTY_STR( psz_artist ) && !EMPTY_STR( psz_album ) )
         input_item_SetPreparsed( p_item_cat->p_input, true );
index f05bcee..f7d8dde 100644 (file)
@@ -298,7 +298,7 @@ static int PlayItem( playlist_t *p_playlist, playlist_item_t *p_item )
         if( !b_has_art || strncmp( psz_arturl, "attachment://", 13 ) )
         {
             PL_DEBUG( "requesting art for %s", psz_name );
-            playlist_AskForArtEnqueue( p_playlist, p_input );
+            playlist_AskForArtEnqueue( p_playlist, p_input, pl_Locked );
         }
         free( psz_arturl );
         free( psz_name );