[vlc-devel] commit: Fixed race condition with input ressource and input_Control. ( Laurent Aimar )
git version control
git at videolan.org
Sun Mar 1 16:24:23 CET 2009
vlc | branch: master | Laurent Aimar <fenrir at videolan.org> | Sun Mar 1 16:22:26 2009 +0100| [c58cece6ebf66f5cd602c03958295fccb192878d] | committer: Laurent Aimar
Fixed race condition with input ressource and input_Control.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=c58cece6ebf66f5cd602c03958295fccb192878d
---
src/input/input.c | 5 ++---
src/input/resource.c | 42 ++++++++++++++++++++++++++++++++++++++++++
src/input/resource.h | 7 +++++++
3 files changed, 51 insertions(+), 3 deletions(-)
diff --git a/src/input/input.c b/src/input/input.c
index 9f31424..e6531d6 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -444,10 +444,9 @@ input_resource_t *input_DetachResource( input_thread_t *p_input )
{
assert( p_input->b_dead );
- input_resource_t *p_resource = p_input->p->p_resource;
- input_resource_SetInput( p_resource, NULL );
+ input_resource_SetInput( p_input->p->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;
return p_resource;
diff --git a/src/input/resource.c b/src/input/resource.c
index b3e140f..3f5f3b7 100644
--- a/src/input/resource.c
+++ b/src/input/resource.c
@@ -70,6 +70,15 @@ static void DestroySout( input_resource_t *p_resource )
#endif
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,
sout_instance_t *p_sout, const char *psz_sout )
{
@@ -135,6 +144,15 @@ static void DestroyVout( input_resource_t *p_resource )
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,
vout_thread_t *p_vout )
{
@@ -303,6 +321,14 @@ static void DestroyAout( input_resource_t *p_resource )
vlc_object_release( p_resource->p_aout );
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 )
{
assert( p_resource->p_input );
@@ -392,6 +418,22 @@ void input_resource_SetInput( input_resource_t *p_resource, input_thread_t *p_in
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 *p_vout, video_format_t *p_fmt, bool b_recycle )
{
diff --git a/src/input/resource.h b/src/input/resource.h
index 97c6f32..15bc377 100644
--- a/src/input/resource.h
+++ b/src/input/resource.h
@@ -41,6 +41,13 @@ input_resource_t *input_resource_New( void );
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.
*/
sout_instance_t *input_resource_RequestSout( input_resource_t *, sout_instance_t *, const char *psz_sout );
More information about the vlc-devel
mailing list