]> git.sesse.net Git - vlc/commitdiff
* include/vlc_playlist.h, src/playlist/playlist.c, src/video_output/video_output...
authorGildas Bazin <gbazin@videolan.org>
Tue, 26 Apr 2005 14:16:14 +0000 (14:16 +0000)
committerGildas Bazin <gbazin@videolan.org>
Tue, 26 Apr 2005 14:16:14 +0000 (14:16 +0000)
include/vlc_playlist.h
src/playlist/playlist.c
src/video_output/video_output.c

index 7c65e5543bbf11cecaee865c9e1f6732536ab85c..b097ae678b4c9cdaeda386de272ed46949e785a3 100644 (file)
@@ -210,6 +210,8 @@ struct playlist_t
 
     playlist_preparse_t     *p_preparse;
 
+    vlc_mutex_t gc_lock;         /**< Lock to protect the garbage collection */
+
     /*@}*/
 };
 
index b92b120c958719b740097db801cb0a2b846c5c96..b6c98d25f157652b08f67e3b2e6a4ea0543dda70 100644 (file)
@@ -107,6 +107,7 @@ playlist_t * __playlist_Create ( vlc_object_t *p_parent )
     var_CreateGetBool( p_playlist, "loop" );
 
     /* Initialise data structures */
+    vlc_mutex_init( p_playlist, &p_playlist->gc_lock );
     p_playlist->i_last_id = 0;
     p_playlist->b_go_next = VLC_TRUE;
     p_playlist->p_input = NULL;
@@ -127,8 +128,9 @@ playlist_t * __playlist_Create ( vlc_object_t *p_parent )
 
     p_view = playlist_ViewFind( p_playlist, VIEW_CATEGORY );
 
-    p_playlist->p_general = playlist_NodeCreate( p_playlist, VIEW_CATEGORY,
-                                        _( "General" ), p_view->p_root );
+    p_playlist->p_general =
+        playlist_NodeCreate( p_playlist, VIEW_CATEGORY,
+                             _( "General" ), p_view->p_root );
     p_playlist->p_general->i_flags |= PLAYLIST_RO_FLAG;
 
     /* Set startup status
@@ -228,6 +230,7 @@ int playlist_Destroy( playlist_t * p_playlist )
         free( p_view );
     }
 
+    vlc_mutex_destroy( &p_playlist->gc_lock );
     vlc_object_destroy( p_playlist->p_preparse );
     vlc_object_destroy( p_playlist );
 
@@ -451,6 +454,7 @@ static mtime_t ObjectGarbageCollector( playlist_t *p_playlist, int i_type,
     }
     else
     {
+        vlc_mutex_lock( &p_playlist->gc_lock );
         while( ( p_obj = vlc_object_find( p_playlist, i_type, FIND_CHILD ) ) )
         {
             if( p_obj->p_parent != (vlc_object_t*)p_playlist )
@@ -472,6 +476,7 @@ static mtime_t ObjectGarbageCollector( playlist_t *p_playlist, int i_type,
                 sout_DeleteInstance( (sout_instance_t*)p_obj );
             }
         }
+        vlc_mutex_unlock( &p_playlist->gc_lock );
         return 0;
     }
 }
index ac977bae7bbd1d7b3a42aef85c2e53e41934fc4c..2aba8a65c07f9072139941a27983b0b39758438c 100644 (file)
@@ -41,6 +41,7 @@
 #include "video_output.h"
 #include "vlc_spu.h"
 #include <vlc/input.h>                 /* for input_thread_t and i_pts_delay */
+#include "vlc_playlist.h"
 
 #if defined( SYS_DARWIN )
 #include "darwin_specific.h"
@@ -117,12 +118,13 @@ vout_thread_t *__vout_Request( vlc_object_t *p_this, vout_thread_t *p_vout,
 
         if( !p_vout )
         {
-            vlc_object_t *p_playlist;
+            playlist_t *p_playlist;
 
             p_playlist = vlc_object_find( p_this,
                                           VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
             if( p_playlist )
             {
+                vlc_mutex_lock( &p_playlist->gc_lock );
                 p_vout = vlc_object_find( p_playlist,
                                           VLC_OBJECT_VOUT, FIND_CHILD );
                 /* only first children of p_input for unused vout */
@@ -131,6 +133,7 @@ vout_thread_t *__vout_Request( vlc_object_t *p_this, vout_thread_t *p_vout,
                     vlc_object_release( p_vout );
                     p_vout = NULL;
                 }
+                vlc_mutex_unlock( &p_playlist->gc_lock );
                 vlc_object_release( p_playlist );
             }
         }