[vlc-devel] commit: Fixed preparsing/art fetching locking. (Laurent Aimar )
git version control
git at videolan.org
Mon Jan 5 21:26:44 CET 2009
vlc | branch: master | Laurent Aimar <fenrir at videolan.org> | Tue Dec 23 16:26:51 2008 +0100| [52157ae334127f4a20b6b4557b09fc44b4a5ed1f] | committer: Laurent Aimar
Fixed preparsing/art fetching locking.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=52157ae334127f4a20b6b4557b09fc44b4a5ed1f
---
include/vlc_playlist.h | 4 ++--
modules/gui/macosx/playlist.m | 4 ++--
modules/gui/macosx/playlistinfo.m | 4 ++--
modules/gui/qt4/components/interface_widgets.cpp | 12 +++++++++++-
modules/gui/qt4/components/interface_widgets.hpp | 4 ++--
modules/gui/wxwidgets/dialogs/playlist.cpp | 2 +-
src/control/media.c | 4 ++--
src/playlist/control.c | 12 ++++++------
src/playlist/item.c | 2 +-
src/playlist/thread.c | 2 +-
10 files changed, 30 insertions(+), 20 deletions(-)
diff --git a/include/vlc_playlist.h b/include/vlc_playlist.h
index 11cf3e6..1b0d348 100644
--- a/include/vlc_playlist.h
+++ b/include/vlc_playlist.h
@@ -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 ) );
diff --git a/modules/gui/macosx/playlist.m b/modules/gui/macosx/playlist.m
index 1ab42bb..e47cd30 100644
--- a/modules/gui/macosx/playlist.m
+++ b/modules/gui/macosx/playlist.m
@@ -836,7 +836,7 @@
{
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
{
@@ -872,7 +872,7 @@
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 );
diff --git a/modules/gui/macosx/playlistinfo.m b/modules/gui/macosx/playlistinfo.m
index 8822305..a32e6da 100644
--- a/modules/gui/macosx/playlistinfo.m
+++ b/modules/gui/macosx/playlistinfo.m
@@ -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 );
}
diff --git a/modules/gui/qt4/components/interface_widgets.cpp b/modules/gui/qt4/components/interface_widgets.cpp
index 2d47104..69b2ace 100644
--- a/modules/gui/qt4/components/interface_widgets.cpp
+++ b/modules/gui/qt4/components/interface_widgets.cpp
@@ -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 );
}
}
diff --git a/modules/gui/qt4/components/interface_widgets.hpp b/modules/gui/qt4/components/interface_widgets.hpp
index 09ec267..746b147 100644
--- a/modules/gui/qt4/components/interface_widgets.hpp
+++ b/modules/gui/qt4/components/interface_widgets.hpp
@@ -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;
diff --git a/modules/gui/wxwidgets/dialogs/playlist.cpp b/modules/gui/wxwidgets/dialogs/playlist.cpp
index e72387d..d819a19 100644
--- a/modules/gui/wxwidgets/dialogs/playlist.cpp
+++ b/modules/gui/wxwidgets/dialogs/playlist.cpp
@@ -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
{
diff --git a/src/control/media.c b/src/control/media.c
index 0192227..34f61aa 100644
--- a/src/control/media.c
+++ b/src/control/media.c
@@ -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 */
diff --git a/src/playlist/control.c b/src/playlist/control.c
index 8aa5760..f340d58 100644
--- a/src/playlist/control.c
+++ b/src/playlist/control.c
@@ -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;
}
diff --git a/src/playlist/item.c b/src/playlist/item.c
index 28ad321..55ed4da 100644
--- a/src/playlist/item.c
+++ b/src/playlist/item.c
@@ -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 );
diff --git a/src/playlist/thread.c b/src/playlist/thread.c
index f05bcee..f7d8dde 100644
--- a/src/playlist/thread.c
+++ b/src/playlist/thread.c
@@ -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 );
More information about the vlc-devel
mailing list