[vlc-devel] [PATCHv2] Fix input variables
Pierre Ynard
linkfanel at yahoo.fr
Wed Nov 24 09:15:30 CET 2010
The input resources create a dedicated parent object, and input
variables are parsed and set on this object too.
diff --git a/src/input/input.c b/src/input/input.c
index 8a0e070..0a53028 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -321,14 +321,6 @@ static input_thread_t *Create( vlc_object_t *p_parent, input_item_t *p_item,
if( !p_input->p )
return NULL;
- /* Parse input options */
- vlc_mutex_lock( &p_item->lock );
- assert( (int)p_item->optflagc == p_item->i_options );
- for( i = 0; i < p_item->i_options; i++ )
- var_OptionParse( VLC_OBJECT(p_input), p_item->ppsz_options[i],
- !!(p_item->optflagv[i] & VLC_INPUT_OPTION_TRUSTED) );
- vlc_mutex_unlock( &p_item->lock );
-
p_input->b_preparsing = b_quick;
p_input->psz_header = psz_header ? strdup( psz_header ) : NULL;
@@ -396,6 +388,20 @@ static input_thread_t *Create( vlc_object_t *p_parent, input_item_t *p_item,
}
input_resource_SetInput( p_input->p->p_resource, p_input );
+ /* Parse input options */
+ vlc_object_t *p_obj = input_resource_GetParent( p_input->p->p_resource );
+ vlc_mutex_lock( &p_item->lock );
+ assert( (int)p_item->optflagc == p_item->i_options );
+ for( i = 0; i < p_item->i_options; i++ )
+ {
+ var_OptionParse( VLC_OBJECT(p_input), p_item->ppsz_options[i],
+ !!(p_item->optflagv[i] & VLC_INPUT_OPTION_TRUSTED) );
+ var_OptionParse( p_obj, p_item->ppsz_options[i],
+ !!(p_item->optflagv[i] & VLC_INPUT_OPTION_TRUSTED) );
+ }
+ vlc_mutex_unlock( &p_item->lock );
+ vlc_object_release( p_obj );
+
/* Init control buffer */
vlc_mutex_init( &p_input->p->lock_control );
vlc_cond_init( &p_input->p->wait_control );
diff --git a/src/input/resource.c b/src/input/resource.c
index f683e61..caede8a 100644
--- a/src/input/resource.c
+++ b/src/input/resource.c
@@ -41,6 +41,7 @@
#include "../video_output/vout_control.h"
#include "input_interface.h"
#include "resource.h"
+#include "../misc/variables.h"
struct input_resource_t
{
@@ -399,6 +400,7 @@ static void Destructor( gc_object_t *p_gc )
vlc_mutex_destroy( &p_resource->lock_hold );
vlc_mutex_destroy( &p_resource->lock );
+ vlc_object_release( p_resource->p_parent );
free( p_resource );
}
@@ -410,12 +412,19 @@ input_resource_t *input_resource_New( vlc_object_t *p_parent )
return NULL;
vlc_gc_init( p_resource, Destructor );
- p_resource->p_parent = p_parent;
+ p_resource->p_parent = vlc_object_create( p_parent, sizeof (vlc_object_t) );
+ vlc_object_attach( p_resource->p_parent, p_parent->p_libvlc );
vlc_mutex_init( &p_resource->lock );
vlc_mutex_init( &p_resource->lock_hold );
return p_resource;
}
+vlc_object_t *input_resource_GetParent( input_resource_t *p_resource )
+{
+ vlc_object_hold( p_resource->p_parent );
+ return p_resource->p_parent;
+}
+
void input_resource_Release( input_resource_t *p_resource )
{
vlc_gc_decref( p_resource );
@@ -434,6 +443,8 @@ void input_resource_SetInput( input_resource_t *p_resource, input_thread_t *p_in
if( p_resource->p_input && !p_input )
assert( p_resource->i_vout == 0 );
+ var_DestroyAll( p_resource->p_parent );
+
/* */
p_resource->p_input = p_input;
diff --git a/src/input/resource.h b/src/input/resource.h
index a5793b8..0709733 100644
--- a/src/input/resource.h
+++ b/src/input/resource.h
@@ -32,6 +32,13 @@
void input_resource_SetInput( input_resource_t *, input_thread_t * );
/**
+ * This function returns the parent object used for resources.
+ *
+ * You must call vlc_object_release on the value returned.
+ */
+vlc_object_t *input_resource_GetParent( input_resource_t *p_resource );
+
+/**
* This function handles sout request.
*/
sout_instance_t *input_resource_RequestSout( input_resource_t *, sout_instance_t *, const char *psz_sout );
diff --git a/src/input/vlm.c b/src/input/vlm.c
index 38056b4..edd88de 100644
--- a/src/input/vlm.c
+++ b/src/input/vlm.c
@@ -56,6 +56,7 @@
#include <vlc_stream.h>
#include "vlm_internal.h"
#include "vlm_event.h"
+#include "resource.h"
#include <vlc_vod.h>
#include <vlc_sout.h>
#include <vlc_url.h>
@@ -989,11 +999,13 @@ static int vlm_ControlMediaInstanceStart( vlm_t *p_vlm, int64_t id, const char *
if( p_instance->p_input )
{
var_AddCallback( p_instance->p_input, "intf-event", InputEvent, p_media );
- var_Create( p_instance->p_input, "vod-media", VLC_VAR_ADDRESS );
- var_SetAddress( p_instance->p_input, "vod-media",
- p_media->vod.p_media );
- var_Create( p_instance->p_input, "vod-session", VLC_VAR_STRING );
- var_SetString( p_instance->p_input, "vod-session", psz_id );
+ vlc_object_t *p_parent = input_resource_GetParent(
+ p_instance->p_input_resource );
+ var_Create( p_parent, "vod-media", VLC_VAR_ADDRESS );
+ var_SetAddress( p_parent, "vod-media", p_media->vod.p_media );
+ var_Create( p_parent, "vod-session", VLC_VAR_STRING );
+ var_SetString( p_parent, "vod-session", psz_id );
+ vlc_object_release( p_parent );
if( input_Start( p_instance->p_input ) != VLC_SUCCESS )
{
diff --git a/src/misc/variables.c b/src/misc/variables.c
index c91cb41..0675a54 100644
--- a/src/misc/variables.c
+++ b/src/misc/variables.c
@@ -358,6 +358,7 @@ void var_DestroyAll( vlc_object_t *obj )
vlc_object_internals_t *priv = vlc_internals( obj );
tdestroy( priv->var_root, CleanupVar );
+ priv->var_root = NULL;
}
#undef var_Change
Regards,
--
Pierre Ynard
"Une âme dans un corps, c'est comme un dessin sur une feuille de papier."
More information about the vlc-devel
mailing list