[vlc-commits] spu: split attach/detach functions

Rémi Denis-Courmont git at videolan.org
Sun Dec 2 17:57:59 CET 2018


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Dec  2 17:59:02 2018 +0200| [87e4fd08fc45a525a3ac2c06e60d6a047bae3d6f] | committer: Rémi Denis-Courmont

spu: split attach/detach functions

They have no code in common as they are currently written.

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

 src/video_output/video_output.c     |  8 ++++----
 src/video_output/vout_internal.h    |  3 ++-
 src/video_output/vout_subpictures.c | 37 +++++++++++++++++++------------------
 3 files changed, 25 insertions(+), 23 deletions(-)

diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index 0925eb5de1..b04e449d97 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -222,7 +222,7 @@ static vout_thread_t *VoutCreate(vlc_object_t *object,
 
     vout->p->input = input;
     if (vout->p->input)
-        spu_Attach(vout->p->spu, input, true);
+        spu_Attach(vout->p->spu, input);
 
     return vout;
 }
@@ -238,10 +238,10 @@ vout_thread_t *vout_Request(vlc_object_t *object,
     if (vout) {
         if (vout->p->input != input) {
             if (vout->p->input)
-                spu_Attach(vout->p->spu, vout->p->input, false);
+                spu_Detach(vout->p->spu);
             vout->p->input = input;
             if (vout->p->input)
-                spu_Attach(vout->p->spu, vout->p->input, true);
+                spu_Attach(vout->p->spu, vout->p->input);
         }
 
         vout_control_cmd_t cmd;
@@ -269,7 +269,7 @@ void vout_Close(vout_thread_t *vout)
     assert(vout);
 
     if (vout->p->input)
-        spu_Attach(vout->p->spu, vout->p->input, false);
+        spu_Detach(vout->p->spu);
 
     vout_snapshot_End(&vout->p->snapshot);
 
diff --git a/src/video_output/vout_internal.h b/src/video_output/vout_internal.h
index 8fb36a69db..189d32e9ab 100644
--- a/src/video_output/vout_internal.h
+++ b/src/video_output/vout_internal.h
@@ -222,7 +222,8 @@ void vout_ManageWrapper(vout_thread_t *);
 
 /* */
 int spu_ProcessMouse(spu_t *, const vlc_mouse_t *, const video_format_t *);
-void spu_Attach( spu_t *, input_thread_t *input, bool );
+void spu_Attach( spu_t *, input_thread_t *input );
+void spu_Detach( spu_t * );
 void spu_ChangeMargin(spu_t *, int);
 void spu_SetHighlight(spu_t *, const vlc_spu_highlight_t*);
 
diff --git a/src/video_output/vout_subpictures.c b/src/video_output/vout_subpictures.c
index 74cefe604d..fefe77a154 100644
--- a/src/video_output/vout_subpictures.c
+++ b/src/video_output/vout_subpictures.c
@@ -1395,29 +1395,30 @@ void spu_Destroy(spu_t *spu)
 }
 
 /**
- * Attach/Detach the SPU from any input
- *
- * \param p_this the object in which to destroy the subpicture unit
- * \param b_attach to select attach or detach
+ * Attach the SPU to an input
  */
-void spu_Attach(spu_t *spu, input_thread_t *input, bool attach)
+void spu_Attach(spu_t *spu, input_thread_t *input)
 {
-    if (attach) {
-        UpdateSPU(spu, NULL);
+    UpdateSPU(spu, NULL);
 
-        vlc_mutex_lock(&spu->p->lock);
-        spu->p->input = input;
+    vlc_mutex_lock(&spu->p->lock);
+    spu->p->input = input;
 
-        if (spu->p->text)
-            FilterRelease(spu->p->text);
-        spu->p->text = SpuRenderCreateAndLoadText(spu);
+    if (spu->p->text)
+        FilterRelease(spu->p->text);
+    spu->p->text = SpuRenderCreateAndLoadText(spu);
 
-        vlc_mutex_unlock(&spu->p->lock);
-    } else {
-        vlc_mutex_lock(&spu->p->lock);
-        spu->p->input = NULL;
-        vlc_mutex_unlock(&spu->p->lock);
-    }
+    vlc_mutex_unlock(&spu->p->lock);
+}
+
+/**
+ * Detach the SPU from its attached input
+ */
+void spu_Detach(spu_t *spu)
+{
+    vlc_mutex_lock(&spu->p->lock);
+    spu->p->input = NULL;
+    vlc_mutex_unlock(&spu->p->lock);
 }
 
 /**



More information about the vlc-commits mailing list