]> git.sesse.net Git - vlc/commitdiff
activex: protect calls to libvlc_playlist_isplaying().
authorJean-Paul Saman <jean-paul.saman@m2x.nl>
Tue, 24 Feb 2009 15:23:27 +0000 (16:23 +0100)
committerJean-Paul Saman <jean-paul.saman@m2x.nl>
Sat, 7 Mar 2009 15:58:02 +0000 (16:58 +0100)
projects/activex/vlccontrol.cpp
projects/activex/vlccontrol2.cpp

index 75da2de8b9c440518564d2ca4d0678955409ad8f..4f31cc944fef196c05a5d176b055377f7d5c02e5 100644 (file)
@@ -203,10 +203,12 @@ STDMETHODIMP VLCControl::get_Playing(VARIANT_BOOL *isPlaying)
         result = _p_instance->getVLC(&p_libvlc);
         if( SUCCEEDED(result) )
         {
+            libvlc_playlist_lock( p_libvlc );
             if( libvlc_playlist_isplaying(p_libvlc, NULL) )
                 *isPlaying = VARIANT_TRUE;
             else
                 *isPlaying = VARIANT_FALSE;
+            libvlc_playlist_unlock( p_libvlc );
             return NOERROR;
         }
     }
@@ -354,7 +356,11 @@ STDMETHODIMP VLCControl::fullscreen(void)
         result = _p_instance->getVLC(&p_libvlc);
         if( SUCCEEDED(result) )
         {
-            if( libvlc_playlist_isplaying(p_libvlc, NULL) )
+            bool b_playing;
+            libvlc_playlist_lock( p_libvlc );
+            b_playing = libvlc_playlist_isplaying(p_libvlc, NULL);
+            libvlc_playlist_unlock( p_libvlc );
+            if( b_playing )
             {
                 libvlc_media_player_t *p_md =
                     libvlc_playlist_get_media_player(p_libvlc, NULL);
index 3ce374c71954ce2350f2ca47de05f1d8a69c0e33..e3c6965fc08adc10c071f432c30a5304cf0d63af 100644 (file)
@@ -1706,15 +1706,18 @@ STDMETHODIMP VLCPlaylist::get_isPlaying(VARIANT_BOOL* isPlaying)
         libvlc_exception_t ex;
         libvlc_exception_init(&ex);
 
+        libvlc_playlist_lock( p_libvlc );
         *isPlaying = libvlc_playlist_isplaying(p_libvlc, &ex) ?
                                     VARIANT_TRUE: VARIANT_FALSE;
         if( libvlc_exception_raised(&ex) )
         {
+            libvlc_playlist_unlock( p_libvlc );
             _p_instance->setErrorInfo(IID_IVLCPlaylist,
                          libvlc_exception_get_message(&ex));
             libvlc_exception_clear(&ex);
             return E_FAIL;
         }
+        libvlc_playlist_unlock( p_libvlc );
         return NOERROR;
     }
     return hr;