From 1022827bbae184a03b9dca82012f849d59a9710a Mon Sep 17 00:00:00 2001 From: =?utf8?q?R=C3=A9mi=20Denis-Courmont?= Date: Thu, 4 Aug 2011 16:51:07 +0300 Subject: [PATCH] aout: privatize the lock --- include/vlc_aout.h | 2 -- src/audio_output/aout_internal.h | 8 ++++++-- src/audio_output/common.c | 5 ++--- src/audio_output/input.c | 9 ++++----- src/audio_output/output.c | 20 ++++++++++---------- 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/include/vlc_aout.h b/include/vlc_aout.h index a0791f8e51..5a978c9459 100644 --- a/include/vlc_aout.h +++ b/include/vlc_aout.h @@ -163,8 +163,6 @@ struct audio_output { VLC_COMMON_MEMBERS - vlc_mutex_t lock; - audio_sample_format_t format; /**< Output format (plugin can modify it only when succesfully probed and not afterward) */ diff --git a/src/audio_output/aout_internal.h b/src/audio_output/aout_internal.h index ab2eb1efad..2b53fd7cc7 100644 --- a/src/audio_output/aout_internal.h +++ b/src/audio_output/aout_internal.h @@ -92,6 +92,7 @@ struct aout_input_t typedef struct { + vlc_mutex_t lock; module_t *module; /**< Output plugin (or NULL if inactive) */ aout_input_t *input; @@ -205,13 +206,13 @@ void aout_unlock_check (unsigned); static inline void aout_lock( audio_output_t *p_aout ) { aout_lock_check( OUTPUT_LOCK ); - vlc_mutex_lock( &p_aout->lock ); + vlc_mutex_lock( &aout_owner(p_aout)->lock ); } static inline void aout_unlock( audio_output_t *p_aout ) { aout_unlock_check( OUTPUT_LOCK ); - vlc_mutex_unlock( &p_aout->lock ); + vlc_mutex_unlock( &aout_owner(p_aout)->lock ); } static inline void aout_lock_volume( audio_output_t *p_aout ) @@ -226,6 +227,9 @@ static inline void aout_unlock_volume( audio_output_t *p_aout ) vlc_mutex_unlock( &aout_owner(p_aout)->volume.lock ); } +#define aout_assert_locked( aout ) \ + vlc_assert_locked( &aout_owner(aout)->lock ) + /* Helpers */ /** diff --git a/src/audio_output/common.c b/src/audio_output/common.c index 560be14196..190b7fb732 100644 --- a/src/audio_output/common.c +++ b/src/audio_output/common.c @@ -57,14 +57,13 @@ audio_output_t *aout_New( vlc_object_t * p_parent ) aout_owner_t *owner = aout_owner (aout); + vlc_mutex_init (&owner->lock); owner->module = NULL; owner->input = NULL; vlc_mutex_init (&owner->volume.lock); owner->volume.multiplier = 1.0; owner->volume.mixer = NULL; - vlc_mutex_init (&aout->lock); - aout_VolumeNoneInit (aout); vlc_object_set_destructor (aout, aout_Destructor); var_Create (aout, "intf-change", VLC_VAR_VOID); @@ -81,7 +80,7 @@ static void aout_Destructor (vlc_object_t *obj) aout_owner_t *owner = aout_owner (aout); vlc_mutex_destroy (&owner->volume.lock); - vlc_mutex_destroy (&aout->lock); + vlc_mutex_destroy (&owner->lock); } #ifdef AOUT_DEBUG diff --git a/src/audio_output/input.c b/src/audio_output/input.c index d9edfd61b3..4cbc596aea 100644 --- a/src/audio_output/input.c +++ b/src/audio_output/input.c @@ -48,8 +48,6 @@ #include "aout_internal.h" -#define AOUT_ASSERT_LOCKED vlc_assert_locked( &p_aout->lock ) - static void inputFailure( audio_output_t *, aout_input_t *, const char * ); static void inputDrop( aout_input_t *, aout_buffer_t * ); static void inputResamplingStop( aout_input_t *p_input ); @@ -430,7 +428,7 @@ int aout_InputNew( audio_output_t * p_aout, aout_input_t * p_input, const aout_r *****************************************************************************/ int aout_InputDelete( audio_output_t * p_aout, aout_input_t * p_input ) { - AOUT_ASSERT_LOCKED; + aout_assert_locked( p_aout ); if ( p_input->b_error ) return 0; @@ -458,7 +456,7 @@ int aout_InputDelete( audio_output_t * p_aout, aout_input_t * p_input ) *****************************************************************************/ void aout_InputCheckAndRestart( audio_output_t * p_aout, aout_input_t * p_input ) { - AOUT_ASSERT_LOCKED; + aout_assert_locked( p_aout ); if( !p_input->b_restart ) return; @@ -483,7 +481,8 @@ block_t *aout_InputPlay( audio_output_t *p_aout, aout_input_t *p_input, block_t *p_buffer, int i_input_rate ) { mtime_t start_date; - AOUT_ASSERT_LOCKED; + + aout_assert_locked( p_aout ); if( i_input_rate != INPUT_RATE_DEFAULT && p_input->p_playback_rate_filter == NULL ) { diff --git a/src/audio_output/output.c b/src/audio_output/output.c index 34233cbffc..2a356157ad 100644 --- a/src/audio_output/output.c +++ b/src/audio_output/output.c @@ -48,7 +48,7 @@ int aout_OutputNew( audio_output_t *p_aout, { aout_owner_t *owner = aout_owner (p_aout); - vlc_assert_locked( &p_aout->lock ); + aout_assert_locked( p_aout ); p_aout->format = *p_format; /* Retrieve user defaults. */ @@ -206,7 +206,7 @@ void aout_OutputDelete( audio_output_t * p_aout ) { aout_owner_t *owner = aout_owner (p_aout); - vlc_assert_locked( &p_aout->lock ); + aout_assert_locked( p_aout ); if (owner->module == NULL) return; @@ -226,7 +226,7 @@ void aout_OutputPlay (audio_output_t *aout, block_t *block) { aout_owner_t *owner = aout_owner (aout); - vlc_assert_locked (&aout->lock); + aout_assert_locked (aout); aout_FiltersPlay (owner->filters, owner->nb_filters, &block); if (block == NULL) @@ -247,7 +247,7 @@ void aout_OutputPlay (audio_output_t *aout, block_t *block) */ void aout_OutputPause( audio_output_t *aout, bool pause, mtime_t date ) { - vlc_assert_locked( &aout->lock ); + aout_assert_locked( aout ); if( aout->pf_pause != NULL ) aout->pf_pause( aout, pause, date ); } @@ -260,7 +260,7 @@ void aout_OutputPause( audio_output_t *aout, bool pause, mtime_t date ) */ void aout_OutputFlush( audio_output_t *aout, bool wait ) { - vlc_assert_locked( &aout->lock ); + aout_assert_locked( aout ); if( aout->pf_flush != NULL ) aout->pf_flush( aout, wait ); @@ -287,7 +287,7 @@ void aout_VolumeNoneInit (audio_output_t *aout) { /* aout_New() -safely- calls this function without the lock, before any * other thread knows of this audio output instance. - vlc_assert_locked (&aout->lock); */ + aout_assert_locked (aout); */ aout->pf_volume_set = aout_VolumeNoneSet; } @@ -298,7 +298,7 @@ static int aout_VolumeSoftSet (audio_output_t *aout, float volume, bool mute) { aout_owner_t *owner = aout_owner (aout); - vlc_assert_locked (&aout->lock); + aout_assert_locked (aout); /* Cubic mapping from software volume to amplification factor. * This provides a good tradeoff between low and high volume ranges. @@ -326,7 +326,7 @@ void aout_VolumeSoftInit (audio_output_t *aout) audio_volume_t volume = var_InheritInteger (aout, "volume"); bool mute = var_InheritBool (aout, "mute"); - vlc_assert_locked (&aout->lock); + aout_assert_locked (aout); aout->pf_volume_set = aout_VolumeSoftSet; aout_VolumeSoftSet (aout, volume / (float)AOUT_VOLUME_DEFAULT, mute); } @@ -338,7 +338,7 @@ void aout_VolumeSoftInit (audio_output_t *aout) */ void aout_VolumeHardInit (audio_output_t *aout, aout_volume_cb setter) { - vlc_assert_locked (&aout->lock); + aout_assert_locked (aout); aout->pf_volume_set = setter; } @@ -442,7 +442,7 @@ static block_t *aout_OutputSlice (audio_output_t *p_aout) const unsigned samples = p->samples; assert( samples > 0 ); - vlc_assert_locked( &p_aout->lock ); + aout_assert_locked( p_aout ); /* Retrieve the date of the next buffer. */ date_t exact_start_date = p->fifo.end_date; -- 2.39.5