]> git.sesse.net Git - vlc/commitdiff
Gives the input_thread_t to use to vout_Request().
authorLaurent Aimar <fenrir@videolan.org>
Fri, 21 May 2010 19:01:36 +0000 (21:01 +0200)
committerLaurent Aimar <fenrir@videolan.org>
Fri, 21 May 2010 19:27:18 +0000 (21:27 +0200)
This removes a dangerous vlc_object_find(PARENT) and potentially
invalids var_DelCallback().
It also avoids useless callback destructions and so fixes some dvd menus.

include/vlc_vout.h
src/audio_output/input.c
src/input/resource.c
src/video_output/video_output.c
src/video_output/vout_internal.h
src/video_output/vout_subpictures.c

index aa144d509add70cafba2b3b0120535e72c76ca3b..f42d319481be83c02e287ea68a5866e14acd5c3f 100644 (file)
@@ -52,6 +52,7 @@
  */
 typedef struct {
     vout_thread_t        *vout;
+    vlc_object_t         *input;
     const video_format_t *fmt;
 } vout_configuration_t;
 
index 2f4d2168486dc806d53e0abc143e4789e60e1892..85d439bbcbb254e9c9afa6947e75d6628b663e07 100644 (file)
@@ -816,8 +816,9 @@ static vout_thread_t *RequestVout( void *p_private,
     aout_instance_t *p_aout = p_private;
     VLC_UNUSED(b_recycle);
     vout_configuration_t cfg = {
-        .vout = p_vout,
-        .fmt  = p_fmt,
+        .vout  = p_vout,
+        .input = NULL,
+        .fmt   = p_fmt,
     };
     return vout_Request( p_aout, &cfg );
 }
index f4ae531fb1ef3d0a91046b7609073096d0a0b268..b015be8fba1cd7b9d9236a7ca90ad6de98167414 100644 (file)
@@ -243,8 +243,9 @@ static vout_thread_t *RequestVout( input_resource_t *p_resource,
 
         /* */
         vout_configuration_t cfg = {
-            .vout = p_vout,
-            .fmt  = p_fmt,
+            .vout  = p_vout,
+            .input = VLC_OBJECT(p_resource->p_input),
+            .fmt   = p_fmt,
         };
         p_vout = vout_Request( p_resource->p_input, &cfg );
         if( !p_vout )
@@ -279,7 +280,12 @@ static vout_thread_t *RequestVout( input_resource_t *p_resource,
             vout_Flush( p_vout, 1 );
             vout_FlushSubpictureChannel( p_vout, -1 );
 
-            p_resource->p_vout_free = p_vout;
+            vout_configuration_t cfg = {
+                .vout  = p_vout,
+                .input = NULL,
+                .fmt   = p_fmt,
+            };
+            p_resource->p_vout_free = vout_Request( p_resource->p_input, &cfg );
         }
         return NULL;
     }
index cb17af39d47505407bbc24470f39447d71138e4e..d827b41db8816593d6fbed133a6c463cdfc116fd 100644 (file)
@@ -157,7 +157,6 @@ static vout_thread_t *VoutCreate(vlc_object_t *object,
         vlc_object_release(vout);
         return NULL;
     }
-    spu_Attach(vout->p->p_spu, VLC_OBJECT(vout), true);
 
     vout_control_WaitEmpty(&vout->p->control);
 
@@ -167,6 +166,10 @@ static vout_thread_t *VoutCreate(vlc_object_t *object,
         return NULL;
     }
 
+    vout->p->input = cfg->input;
+    if (vout->p->input)
+        spu_Attach(vout->p->p_spu, vout->p->input, true);
+
     return vout;
 }
 
@@ -182,10 +185,16 @@ vout_thread_t *(vout_Request)(vlc_object_t *object,
 
     /* If a vout is provided, try reusing it */
     if (vout) {
-        spu_Attach(vout->p->p_spu, VLC_OBJECT(vout), false);
         vlc_object_detach(vout);
         vlc_object_attach(vout, object);
-        spu_Attach(vout->p->p_spu, VLC_OBJECT(vout), true);
+
+        if (vout->p->input != cfg->input) {
+            if (vout->p->input)
+                spu_Attach(vout->p->p_spu, vout->p->input, false);
+            vout->p->input = cfg->input;
+            if (vout->p->input)
+                spu_Attach(vout->p->p_spu, vout->p->input, true);
+        }
 
         vout_control_cmd_t cmd;
         vout_control_cmd_Init(&cmd, VOUT_CONTROL_REINIT);
@@ -216,7 +225,8 @@ void vout_Close(vout_thread_t *vout)
 {
     assert(vout);
 
-    spu_Attach(vout->p->p_spu, VLC_OBJECT(vout), false);
+    if (vout->p->input)
+        spu_Attach(vout->p->p_spu, vout->p->input, false);
     vlc_object_detach(vout->p->p_spu);
 
     vout_snapshot_End(&vout->p->snapshot);
index c5e6d965f6bce8fd32e72b71adc701164f2bed53..0caa9156664ffb604fd6e7f6e76cd5fb72b3de61 100644 (file)
@@ -46,8 +46,11 @@ struct vout_thread_sys_t
     /* Splitter module if used */
     char            *splitter_name;
 
+    /* Input thread for dvd menu interactions */
+    vlc_object_t    *input;
+
     /* */
-    video_format_t  original; /* Original format ie coming from the decoder */
+    video_format_t  original;   /* Original format ie coming from the decoder */
 
     /* Snapshot interface */
     vout_snapshot_t snapshot;
@@ -153,7 +156,7 @@ void vout_DisplayWrapper(vout_thread_t *, picture_t *);
 
 /* */
 int spu_ProcessMouse(spu_t *, const vlc_mouse_t *, const video_format_t *);
-void spu_Attach( spu_t *, vlc_object_t *, bool );
+void spu_Attach( spu_t *, vlc_object_t *input, bool );
 
 #endif
 
index ee608b907e6ca3da2505340ade3a54cfe4ca0659..123d4da3e18856a9d6149eeb0ddc8c1931586329 100644 (file)
@@ -274,14 +274,8 @@ void spu_Destroy( spu_t *p_spu )
  * \param p_this the object in which to destroy the subpicture unit
  * \param b_attach to select attach or detach
  */
-void spu_Attach( spu_t *p_spu, vlc_object_t *p_this, bool b_attach )
+void spu_Attach( spu_t *p_spu, vlc_object_t *p_input, bool b_attach )
 {
-    vlc_object_t *p_input;
-
-    p_input = vlc_object_find( p_this, VLC_OBJECT_INPUT, FIND_PARENT );
-    if( !p_input )
-        return;
-
     if( b_attach )
     {
         UpdateSPU( p_spu, VLC_OBJECT(p_input) );
@@ -292,8 +286,6 @@ void spu_Attach( spu_t *p_spu, vlc_object_t *p_this, bool b_attach )
         vlc_mutex_lock( &p_spu->p->lock );
         p_spu->p->i_margin = var_GetInteger( p_input, "sub-margin" );
         vlc_mutex_unlock( &p_spu->p->lock );
-
-        vlc_object_release( p_input );
     }
     else
     {
@@ -301,7 +293,6 @@ void spu_Attach( spu_t *p_spu, vlc_object_t *p_this, bool b_attach )
         var_DelCallback( p_input, "sub-margin", MarginCallback, p_spu->p );
         var_DelCallback( p_input, "highlight", CropCallback, p_spu );
         var_Destroy( p_input, "highlight" );
-        vlc_object_release( p_input );
     }
 }