[vlc-commits] aout: introduce aout_Destroy()
Rémi Denis-Courmont
git at videolan.org
Wed Aug 10 18:14:09 CEST 2011
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed Aug 10 19:14:00 2011 +0300| [32272ce5354925a084889bd074891e96cda5adc1] | committer: Rémi Denis-Courmont
aout: introduce aout_Destroy()
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=32272ce5354925a084889bd074891e96cda5adc1
---
src/audio_output/aout_internal.h | 4 ++--
src/audio_output/common.c | 5 +++++
src/input/resource.c | 23 +++++++++++++++++------
3 files changed, 24 insertions(+), 8 deletions(-)
diff --git a/src/audio_output/aout_internal.h b/src/audio_output/aout_internal.h
index 8afbdf7..fc1c7c2 100644
--- a/src/audio_output/aout_internal.h
+++ b/src/audio_output/aout_internal.h
@@ -172,9 +172,9 @@ void aout_OutputDelete( audio_output_t * p_aout );
/* From common.c : */
-/* Release with vlc_object_release() */
-audio_output_t *aout_New ( vlc_object_t * );
+audio_output_t *aout_New (vlc_object_t *);
#define aout_New(a) aout_New(VLC_OBJECT(a))
+void aout_Destroy (audio_output_t *);
void aout_FifoInit( vlc_object_t *, aout_fifo_t *, uint32_t );
mtime_t aout_FifoFirstDate( const aout_fifo_t * ) VLC_USED;
diff --git a/src/audio_output/common.c b/src/audio_output/common.c
index 1050811..d160ad0 100644
--- a/src/audio_output/common.c
+++ b/src/audio_output/common.c
@@ -168,6 +168,11 @@ audio_output_t *aout_New( vlc_object_t * p_parent )
return aout;
}
+void aout_Destroy (audio_output_t *aout)
+{
+ vlc_object_release (aout);
+}
+
/*****************************************************************************
* aout_Destructor: destroy aout structure
*****************************************************************************/
diff --git a/src/input/resource.c b/src/input/resource.c
index 34fb06d..794cef8 100644
--- a/src/input/resource.c
+++ b/src/input/resource.c
@@ -328,17 +328,27 @@ exit:
static void DestroyAout( input_resource_t *p_resource )
{
if( p_resource->p_aout )
- vlc_object_release( p_resource->p_aout );
- p_resource->p_aout = NULL;
+ {
+ aout_Destroy( p_resource->p_aout );
+ p_resource->p_aout = NULL;
+ }
}
static void ReleaseAout( input_resource_t *p_resource,
audio_output_t *p_aout )
{
- msg_Dbg( p_resource->p_parent, "releasing audio output" );
if( likely(p_aout == p_resource->p_aout) )
+ {
+ assert( p_resource->b_aout_busy );
p_resource->b_aout_busy = false;
- vlc_object_release( p_aout );
+ msg_Dbg( p_resource->p_parent, "releasing audio output" );
+ vlc_object_release( p_aout );
+ }
+ else
+ {
+ msg_Dbg( p_resource->p_parent, "destroying extra audio output" );
+ aout_Destroy( p_aout );
+ }
}
static audio_output_t *AllocateAout( input_resource_t *p_resource )
@@ -347,7 +357,7 @@ static audio_output_t *AllocateAout( input_resource_t *p_resource )
if( unlikely(p_resource->b_aout_busy) )
{
- msg_Dbg( p_resource->p_parent, "creating audio output" );
+ msg_Dbg( p_resource->p_parent, "creating extra audio output" );
return aout_New( p_resource->p_parent );
}
@@ -360,6 +370,7 @@ static audio_output_t *AllocateAout( input_resource_t *p_resource )
return NULL;
vlc_mutex_lock( &p_resource->lock_hold );
+ assert( p_resource->p_aout == NULL );
p_resource->p_aout = p_aout;
vlc_mutex_unlock( &p_resource->lock_hold );
}
@@ -406,7 +417,7 @@ static void TerminateAout( input_resource_t *p_resource )
vlc_mutex_unlock( &p_resource->lock_hold );
if( p_aout )
- vlc_object_release( p_aout );
+ aout_Destroy( p_aout );
}
static void Destructor( gc_object_t *p_gc )
More information about the vlc-commits
mailing list