Commit c58cece6 authored by Laurent Aimar's avatar Laurent Aimar

Fixed race condition with input ressource and input_Control.

parent 26d5c931
...@@ -444,10 +444,9 @@ input_resource_t *input_DetachResource( input_thread_t *p_input ) ...@@ -444,10 +444,9 @@ input_resource_t *input_DetachResource( input_thread_t *p_input )
{ {
assert( p_input->b_dead ); assert( p_input->b_dead );
input_resource_t *p_resource = p_input->p->p_resource; input_resource_SetInput( p_input->p->p_resource, NULL );
input_resource_SetInput( p_resource, NULL );
p_input->p->p_resource = NULL; input_resource_t *p_resource = input_resource_Detach( p_input->p->p_resource );
p_input->p->p_sout = NULL; p_input->p->p_sout = NULL;
return p_resource; return p_resource;
......
...@@ -70,6 +70,15 @@ static void DestroySout( input_resource_t *p_resource ) ...@@ -70,6 +70,15 @@ static void DestroySout( input_resource_t *p_resource )
#endif #endif
p_resource->p_sout = NULL; p_resource->p_sout = NULL;
} }
static sout_instance_t *DetachSout( input_resource_t *p_resource )
{
sout_instance_t *p_sout = p_resource->p_sout;
p_resource->p_sout = NULL;
return p_sout;
}
static sout_instance_t *RequestSout( input_resource_t *p_resource, static sout_instance_t *RequestSout( input_resource_t *p_resource,
sout_instance_t *p_sout, const char *psz_sout ) sout_instance_t *p_sout, const char *psz_sout )
{ {
...@@ -135,6 +144,15 @@ static void DestroyVout( input_resource_t *p_resource ) ...@@ -135,6 +144,15 @@ static void DestroyVout( input_resource_t *p_resource )
p_resource->p_vout_free = NULL; p_resource->p_vout_free = NULL;
} }
static vout_thread_t *DetachVout( input_resource_t *p_resource )
{
assert( p_resource->i_vout == 0 );
vout_thread_t *p_vout = p_resource->p_vout_free;
p_resource->p_vout_free = NULL;
return p_vout;
}
static void DisplayVoutTitle( input_resource_t *p_resource, static void DisplayVoutTitle( input_resource_t *p_resource,
vout_thread_t *p_vout ) vout_thread_t *p_vout )
{ {
...@@ -303,6 +321,14 @@ static void DestroyAout( input_resource_t *p_resource ) ...@@ -303,6 +321,14 @@ static void DestroyAout( input_resource_t *p_resource )
vlc_object_release( p_resource->p_aout ); vlc_object_release( p_resource->p_aout );
p_resource->p_aout = NULL; p_resource->p_aout = NULL;
} }
static aout_instance_t *DetachAout( input_resource_t *p_resource )
{
aout_instance_t *p_aout = p_resource->p_aout;
p_resource->p_aout = NULL;
return p_aout;
}
static aout_instance_t *RequestAout( input_resource_t *p_resource, aout_instance_t *p_aout ) static aout_instance_t *RequestAout( input_resource_t *p_resource, aout_instance_t *p_aout )
{ {
assert( p_resource->p_input ); assert( p_resource->p_input );
...@@ -392,6 +418,22 @@ void input_resource_SetInput( input_resource_t *p_resource, input_thread_t *p_in ...@@ -392,6 +418,22 @@ void input_resource_SetInput( input_resource_t *p_resource, input_thread_t *p_in
vlc_mutex_unlock( &p_resource->lock ); vlc_mutex_unlock( &p_resource->lock );
} }
input_resource_t *input_resource_Detach( input_resource_t *p_resource )
{
input_resource_t *p_ret = input_resource_New();
if( !p_ret )
return NULL;
vlc_mutex_lock( &p_resource->lock );
assert( !p_resource->p_input );
p_ret->p_sout = DetachSout( p_resource );
p_ret->p_vout_free = DetachVout( p_resource );
p_ret->p_aout = DetachAout( p_resource );
vlc_mutex_unlock( &p_resource->lock );
return p_ret;
}
vout_thread_t *input_resource_RequestVout( input_resource_t *p_resource, vout_thread_t *input_resource_RequestVout( input_resource_t *p_resource,
vout_thread_t *p_vout, video_format_t *p_fmt, bool b_recycle ) vout_thread_t *p_vout, video_format_t *p_fmt, bool b_recycle )
{ {
......
...@@ -40,6 +40,13 @@ input_resource_t *input_resource_New( void ); ...@@ -40,6 +40,13 @@ input_resource_t *input_resource_New( void );
*/ */
void input_resource_SetInput( input_resource_t *, input_thread_t * ); void input_resource_SetInput( input_resource_t *, input_thread_t * );
/**
* This function return a input_resource_t with all resources detach from the
* given input_resource_t.
* It must not be associated to an input.
*/
input_resource_t *input_resource_Detach( input_resource_t * );
/** /**
* This function handles sout request. * This function handles sout request.
*/ */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment