Commit 1022827b authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

aout: privatize the lock

parent 4cc93968
......@@ -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) */
......
......@@ -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 */
/**
......
......@@ -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
......
......@@ -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 )
{
......
......@@ -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;
......
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