]> git.sesse.net Git - vlc/commitdiff
Reimplemented vout_RegisterSubpictureChannel.
authorLaurent Aimar <fenrir@videolan.org>
Tue, 25 May 2010 21:50:05 +0000 (23:50 +0200)
committerLaurent Aimar <fenrir@videolan.org>
Tue, 25 May 2010 21:52:07 +0000 (23:52 +0200)
 This avoids the potential deadlock introduced by
[38ed2e8ef37df763e187c1dca6b6a6c1da4887c4] when it is called inside
an event emited by the vout.

src/video_output/video_output.c
src/video_output/vout_internal.h

index aa359ed50507bb9bc00b3273661d56729baeb680..2cc823d9f0787ffdfe7df98c90918392fc6227ec 100644 (file)
@@ -126,6 +126,7 @@ static vout_thread_t *VoutCreate(vlc_object_t *object,
     /* Initialize locks */
     vlc_mutex_init(&vout->p->picture_lock);
     vlc_mutex_init(&vout->p->vfilter_lock);
+    vlc_mutex_init(&vout->p->spu_lock);
 
     /* Attach the new object now so we can use var inheritance below */
     vlc_object_attach(vout, object);
@@ -235,7 +236,10 @@ void vout_Close(vout_thread_t *vout)
     vout_control_PushVoid(&vout->p->control, VOUT_CONTROL_CLEAN);
     vlc_join(vout->p->thread, NULL);
 
+    vlc_mutex_lock(&vout->p->spu_lock);
     spu_Destroy(vout->p->p_spu);
+    vout->p->p_spu = NULL;
+    vlc_mutex_unlock(&vout->p->spu_lock);
 }
 
 /* */
@@ -249,6 +253,7 @@ static void VoutDestructor(vlc_object_t *object)
     free(vout->p->splitter_name);
 
     /* Destroy the locks */
+    vlc_mutex_destroy(&vout->p->spu_lock);
     vlc_mutex_destroy(&vout->p->picture_lock);
     vlc_mutex_destroy(&vout->p->vfilter_lock);
     vout_control_Clean(&vout->p->control);
@@ -356,7 +361,14 @@ void vout_PutSubpicture( vout_thread_t *vout, subpicture_t *subpic )
 }
 int vout_RegisterSubpictureChannel( vout_thread_t *vout )
 {
-    return spu_RegisterChannel(vout->p->p_spu);
+    int channel = SPU_DEFAULT_CHANNEL;
+
+    vlc_mutex_lock(&vout->p->spu_lock);
+    if (vout->p->p_spu)
+        channel = spu_RegisterChannel(vout->p->p_spu);
+    vlc_mutex_unlock(&vout->p->spu_lock);
+
+    return channel;
 }
 void vout_FlushSubpictureChannel( vout_thread_t *vout, int channel )
 {
index 860299750433f4983368e9640200567b97a931f9..951a9d1643cedb0a8ffdb1deea4395269ab9bb79 100644 (file)
@@ -68,6 +68,7 @@ struct vout_thread_sys_t
     vout_statistic_t statistic;
 
     /* Subpicture unit */
+    vlc_mutex_t     spu_lock;
     spu_t           *p_spu;
 
     /* Monitor Pixel Aspect Ratio */