[vlc-commits] commit: Reimplemented vout_RegisterSubpictureChannel. (Laurent Aimar )

git at videolan.org git at videolan.org
Tue May 25 23:52:59 CEST 2010


vlc | branch: master | Laurent Aimar <fenrir at videolan.org> | Tue May 25 23:50:05 2010 +0200| [f8d0db86464dfaa0f231edd082cf149859077176] | committer: Laurent Aimar 

Reimplemented vout_RegisterSubpictureChannel.

 This avoids the potential deadlock introduced by
[38ed2e8ef37df763e187c1dca6b6a6c1da4887c4] when it is called inside
an event emited by the vout.

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

 src/video_output/video_output.c  |   14 +++++++++++++-
 src/video_output/vout_internal.h |    1 +
 2 files changed, 14 insertions(+), 1 deletions(-)

diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index aa359ed..2cc823d 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -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 )
 {
diff --git a/src/video_output/vout_internal.h b/src/video_output/vout_internal.h
index 8602997..951a9d1 100644
--- a/src/video_output/vout_internal.h
+++ b/src/video_output/vout_internal.h
@@ -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 */



More information about the vlc-commits mailing list