[vlc-devel] commit: Input: attach before any variable access so that inheritance works ( Rémi Denis-Courmont )

git version control git at videolan.org
Mon Jan 18 19:13:43 CET 2010

vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon Jan 18 20:06:27 2010 +0200| [b09cb1971566c92cbbb52ce672070ddcd3543f07] | committer: Rémi Denis-Courmont 

Input: attach before any variable access so that inheritance works

So far, the input was attached after it inherited quite a bunch of
variables. This did not quite work. The problem lies in the dual use
of object attachment: variables inheritance and tree search.

Nowadays, the input object should not be looked for before it is
initialized. Only children objects use vlc_object_find anymore, and
they can only exist while the input is fully initialized. Other code
paths use playlist_CurrentInput() or such, which only ever return an
already initialized input (from input.c:Create()).

(N.B.: I wonder if there aren't similar issues in VOUT and AOUT)

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

 src/input/input.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/src/input/input.c b/src/input/input.c
index 0f09556..2269ead 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -312,6 +312,8 @@ static input_thread_t *Create( vlc_object_t *p_parent, input_item_t *p_item,
     if( p_input == NULL )
         return NULL;
+    vlc_object_attach( p_input, p_parent );
     /* Construct a nice name for the input timer */
     char psz_timer_name[255];
     char * psz_name = input_item_GetName( p_item );
@@ -478,9 +480,6 @@ static input_thread_t *Create( vlc_object_t *p_parent, input_item_t *p_item,
     /* Set the destructor when we are sure we are initialized */
     vlc_object_set_destructor( p_input, (vlc_destructor_t)Destructor );
-    /* Attach only once we are ready */
-    vlc_object_attach( p_input, p_parent );
     return p_input;

More information about the vlc-devel mailing list