[vlc-devel] commit: activex: take lock before accessing libvlc_playlist_items_count(). (Jean-Paul Saman )

git version control git at videolan.org
Wed Feb 11 09:52:00 CET 2009


vlc | branch: master | Jean-Paul Saman <jpsaman at videolan.org> | Wed Feb 11 09:45:52 2009 +0100| [e166ec152cd4f5add7d40b92d3ad59ca23675e77] | committer: Jean-Paul Saman 

activex: take lock before accessing libvlc_playlist_items_count().

Patch by jan-paul dinger (jpd at m2x dot nl).

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

 include/vlc/deprecated.h         |    2 ++
 projects/activex/plugin.cpp      |   12 +++++++++---
 projects/activex/vlccontrol.cpp  |    2 ++
 projects/activex/vlccontrol2.cpp |    4 ++++
 4 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/include/vlc/deprecated.h b/include/vlc/deprecated.h
index df0ba04..e3c0d56 100644
--- a/include/vlc/deprecated.h
+++ b/include/vlc/deprecated.h
@@ -173,6 +173,8 @@ VLC_DEPRECATED_API int libvlc_playlist_isplaying( libvlc_instance_t *,
 /**
  * Get the number of items in the playlist
  *
+ * Expects the playlist instance to be locked already.
+ *
  * \param p_instance the playlist instance
  * \param p_e an initialized exception pointer
  * \return the number of items
diff --git a/projects/activex/plugin.cpp b/projects/activex/plugin.cpp
index 6a8c3f8..ec8cc44 100644
--- a/projects/activex/plugin.cpp
+++ b/projects/activex/plugin.cpp
@@ -726,10 +726,16 @@ HRESULT VLCPlugin::onActivateInPlace(LPMSG lpMesg, HWND hwndParent, LPCRECT lprc
         libvlc_video_set_parent(p_libvlc,
             reinterpret_cast<libvlc_drawable_t>(_inplacewnd), NULL);
 
-        if( _b_autoplay & (libvlc_playlist_items_count(p_libvlc, NULL) > 0) )
+        if( _b_autoplay )
         {
-            libvlc_playlist_play(p_libvlc, 0, 0, NULL, NULL);
-            fireOnPlayEvent();
+            libvlc_playlist_lock(p_libvlc);
+            unsigned count = libvlc_playlist_items_count(p_libvlc, &ex);
+            if( count > 0 )
+            {
+              libvlc_playlist_play(p_libvlc, 0, 0, NULL, NULL);
+              fireOnPlayEvent();
+            }
+            libvlc_playlist_unlock(p_libvlc);
         }
     }
 
diff --git a/projects/activex/vlccontrol.cpp b/projects/activex/vlccontrol.cpp
index 298a449..75da2de 100644
--- a/projects/activex/vlccontrol.cpp
+++ b/projects/activex/vlccontrol.cpp
@@ -939,7 +939,9 @@ STDMETHODIMP VLCControl::get_PlaylistCount(int *count)
         libvlc_exception_t ex;
         libvlc_exception_init(&ex);
 
+        libvlc_playlist_lock(p_libvlc);
         *count = libvlc_playlist_items_count(p_libvlc, &ex);
+        libvlc_playlist_unlock(p_libvlc);
         if( libvlc_exception_raised(&ex) )
         {
             _p_instance->setErrorInfo(IID_IVLCControl,
diff --git a/projects/activex/vlccontrol2.cpp b/projects/activex/vlccontrol2.cpp
index 2a3c62b..8e3957d 100644
--- a/projects/activex/vlccontrol2.cpp
+++ b/projects/activex/vlccontrol2.cpp
@@ -1526,7 +1526,9 @@ STDMETHODIMP VLCPlaylistItems::get_count(long* count)
         libvlc_exception_t ex;
         libvlc_exception_init(&ex);
 
+        libvlc_playlist_lock(p_libvlc);
         *count = libvlc_playlist_items_count(p_libvlc, &ex);
+        libvlc_playlist_unlock(p_libvlc);
         if( libvlc_exception_raised(&ex) )
         {
             _p_instance->setErrorInfo(IID_IVLCPlaylistItems,
@@ -1676,7 +1678,9 @@ STDMETHODIMP VLCPlaylist::get_itemCount(long* count)
         libvlc_exception_t ex;
         libvlc_exception_init(&ex);
 
+        libvlc_playlist_lock(p_libvlc);
         *count = libvlc_playlist_items_count(p_libvlc, &ex);
+        libvlc_playlist_unlock(p_libvlc);
         if( libvlc_exception_raised(&ex) )
         {
             _p_instance->setErrorInfo(IID_IVLCPlaylist,




More information about the vlc-devel mailing list