[vlc-devel] commit: No need to lock the playlist for meta fetch and preparsing ( Rémi Denis-Courmont )

git version control git at videolan.org
Tue Feb 9 20:22:30 CET 2010


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Tue Feb  9 19:08:13 2010 +0200| [3863d8b088c06aa4f536bf334351e558bf5dc01b] | committer: Rémi Denis-Courmont 

No need to lock the playlist for meta fetch and preparsing

The previous fix made the fetcher and preparser persistent throughout
the lifetime of the playlist. So we don't need to protect the pointers
anymore. Also, they are internally thread-safe (with their own lock).

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=3863d8b088c06aa4f536bf334351e558bf5dc01b
---

 include/vlc_playlist.h            |    4 ++--
 modules/gui/macosx/playlist.m     |    4 ++--
 modules/gui/macosx/playlistinfo.m |    4 ++--
 modules/gui/qt4/input_manager.cpp |    2 +-
 src/control/media.c               |    4 ++--
 src/playlist/control.c            |   10 ++--------
 src/playlist/item.c               |    2 +-
 src/playlist/thread.c             |    2 +-
 8 files changed, 13 insertions(+), 19 deletions(-)

diff --git a/include/vlc_playlist.h b/include/vlc_playlist.h
index 233c731..6854b9f 100644
--- a/include/vlc_playlist.h
+++ b/include/vlc_playlist.h
@@ -300,10 +300,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 *, bool b_locked ) );
+VLC_EXPORT( int, playlist_PreparseEnqueue, (playlist_t *, input_item_t * ) );
 
 /** Request the art for an input item to be fetched */
-VLC_EXPORT( int, playlist_AskForArtEnqueue, (playlist_t *, input_item_t *, bool b_locked ) );
+VLC_EXPORT( int, playlist_AskForArtEnqueue, (playlist_t *, input_item_t * ) );
 
 /* Playlist sorting */
 VLC_EXPORT( int,  playlist_TreeMove, ( playlist_t *, playlist_item_t *, playlist_item_t *, int ) );
diff --git a/modules/gui/macosx/playlist.m b/modules/gui/macosx/playlist.m
index 2d10202..515205e 100644
--- a/modules/gui/macosx/playlist.m
+++ b/modules/gui/macosx/playlist.m
@@ -959,7 +959,7 @@
         {
             if( p_item->i_children == -1 )
             {
-                playlist_PreparseEnqueue( p_playlist, p_item->p_input, pl_Unlocked );
+                playlist_PreparseEnqueue( p_playlist, p_item->p_input );
             }
             else
             {
@@ -995,7 +995,7 @@
 
         if( p_item && p_item->i_children == -1 )
         {
-            playlist_AskForArtEnqueue( p_playlist, p_item->p_input, pl_Unlocked );
+            playlist_AskForArtEnqueue( p_playlist, p_item->p_input );
         }
     }
     pl_Release( p_intf );
diff --git a/modules/gui/macosx/playlistinfo.m b/modules/gui/macosx/playlistinfo.m
index 1ec680b..07e53b2 100644
--- a/modules/gui/macosx/playlistinfo.m
+++ b/modules/gui/macosx/playlistinfo.m
@@ -253,7 +253,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, pl_Unlocked );
+            playlist_PreparseEnqueue( p_playlist, p_item );
             pl_Release( VLCIntf );
         }
 
@@ -404,7 +404,7 @@ error:
 - (IBAction)downloadCoverArt:(id)sender
 {
     playlist_t * p_playlist = pl_Hold( VLCIntf );
-    if( p_item) playlist_AskForArtEnqueue( p_playlist, p_item, pl_Unlocked );
+    if( p_item) playlist_AskForArtEnqueue( p_playlist, p_item );
     pl_Release( VLCIntf );
 }
 
diff --git a/modules/gui/qt4/input_manager.cpp b/modules/gui/qt4/input_manager.cpp
index ecf55e4..756b773 100644
--- a/modules/gui/qt4/input_manager.cpp
+++ b/modules/gui/qt4/input_manager.cpp
@@ -595,7 +595,7 @@ void InputManager::requestArtUpdate()
     if( hasInput() )
     {
         playlist_t *p_playlist = pl_Hold( p_intf );
-        playlist_AskForArtEnqueue( p_playlist, input_GetItem( p_input ), pl_Unlocked );
+        playlist_AskForArtEnqueue( p_playlist, input_GetItem( p_input ) );
         pl_Release( p_intf );
     }
     else
diff --git a/src/control/media.c b/src/control/media.c
index 2da4e60..0b6147e 100644
--- a/src/control/media.c
+++ b/src/control/media.c
@@ -228,7 +228,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, pl_Unlocked );
+                p_md->p_input_item );
         p_md->b_preparsed = true;
     }
 }
@@ -447,7 +447,7 @@ char *libvlc_media_get_meta( libvlc_media_t *p_md, libvlc_meta_t e_meta )
         p_md->has_asked_art = true;
         playlist_AskForArtEnqueue(
                 libvlc_priv(p_md->p_libvlc_instance->p_libvlc_int)->p_playlist,
-                p_md->p_input_item, pl_Unlocked );
+                p_md->p_input_item );
     }
 
     /* Should be integrated in core */
diff --git a/src/playlist/control.c b/src/playlist/control.c
index 3ee0f5e..b868416 100644
--- a/src/playlist/control.c
+++ b/src/playlist/control.c
@@ -216,28 +216,22 @@ static int PlaylistVAControl( playlist_t * p_playlist, int i_query, va_list args
  * Preparse control
  *****************************************************************************/
 /** Enqueue an item for preparsing */
-int playlist_PreparseEnqueue( playlist_t *p_playlist,
-                              input_item_t *p_item, bool b_locked )
+int playlist_PreparseEnqueue( playlist_t *p_playlist, input_item_t *p_item )
 {
     playlist_private_t *p_sys = pl_priv(p_playlist);
 
-    PL_LOCK_IF( !b_locked );
     if( p_sys->p_preparser )
         playlist_preparser_Push( p_sys->p_preparser, p_item );
-    PL_UNLOCK_IF( !b_locked );
 
     return VLC_SUCCESS;
 }
 
-int playlist_AskForArtEnqueue( playlist_t *p_playlist,
-                               input_item_t *p_item, bool b_locked )
+int playlist_AskForArtEnqueue( playlist_t *p_playlist, input_item_t *p_item )
 {
     playlist_private_t *p_sys = pl_priv(p_playlist);
 
-    PL_LOCK_IF( !b_locked );
     if( p_sys->p_fetcher )
         playlist_fetcher_Push( p_sys->p_fetcher, p_item );
-    PL_UNLOCK_IF( !b_locked );
 
     return VLC_SUCCESS;
 }
diff --git a/src/playlist/item.c b/src/playlist/item.c
index 1c705a3..6d971f2 100644
--- a/src/playlist/item.c
+++ b/src/playlist/item.c
@@ -726,7 +726,7 @@ static void GoAndPreparse( playlist_t *p_playlist, int i_mode,
         input_item_IsPreparsed( p_item->p_input ) == false &&
             ( EMPTY_STR( psz_artist ) || ( EMPTY_STR( psz_album ) ) )
           )
-        playlist_PreparseEnqueue( p_playlist, p_item->p_input, pl_Locked );
+        playlist_PreparseEnqueue( p_playlist, p_item->p_input );
     free( psz_artist );
     free( psz_album );
 }
diff --git a/src/playlist/thread.c b/src/playlist/thread.c
index ee29e32..25292e6 100644
--- a/src/playlist/thread.c
+++ b/src/playlist/thread.c
@@ -271,7 +271,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, pl_Locked );
+            playlist_AskForArtEnqueue( p_playlist, p_input );
         }
         free( psz_arturl );
         free( psz_name );




More information about the vlc-devel mailing list