Commit 7e4e3a43 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

aout: de-inline the locking functions

parent 296debcc
......@@ -120,6 +120,8 @@ void aout_OutputPlay(audio_output_t *, block_t *);
void aout_OutputPause( audio_output_t * p_aout, bool, mtime_t );
void aout_OutputFlush( audio_output_t * p_aout, bool );
void aout_OutputDelete( audio_output_t * p_aout );
void aout_OutputLock(audio_output_t *);
void aout_OutputUnlock(audio_output_t *);
/* From common.c : */
......@@ -149,18 +151,4 @@ static inline void aout_InputRequestRestart(audio_output_t *aout)
aout_RequestRestart(aout, AOUT_RESTART_FILTERS);
}
/* Audio output locking */
static inline void aout_lock( audio_output_t *p_aout )
{
vlc_mutex_lock( &aout_owner(p_aout)->lock );
}
static inline void aout_unlock( audio_output_t *p_aout )
{
vlc_mutex_unlock( &aout_owner(p_aout)->lock );
}
#define aout_assert_locked( aout ) \
vlc_assert_locked( &aout_owner(aout)->lock )
#endif /* !LIBVLC_AOUT_INTERNAL_H */
......@@ -68,7 +68,7 @@ int aout_DecNew( audio_output_t *p_aout,
aout_owner_t *owner = aout_owner(p_aout);
/* TODO: reduce lock scope depending on decoder's real need */
aout_lock( p_aout );
aout_OutputLock (p_aout);
var_Destroy( p_aout, "stereo-mode" );
......@@ -90,14 +90,14 @@ int aout_DecNew( audio_output_t *p_aout,
aout_OutputDelete (p_aout);
error:
aout_volume_Delete (owner->volume);
aout_unlock (p_aout);
aout_OutputUnlock (p_aout);
return -1;
}
owner->sync.end = VLC_TS_INVALID;
owner->sync.resamp_type = AOUT_RESAMPLING_NONE;
owner->sync.discontinuity = true;
aout_unlock( p_aout );
aout_OutputUnlock (p_aout);
atomic_init (&owner->buffers_lost, 0);
return 0;
......@@ -110,14 +110,14 @@ void aout_DecDelete (audio_output_t *aout)
{
aout_owner_t *owner = aout_owner (aout);
aout_lock (aout);
aout_OutputLock (aout);
if (owner->mixer_format.i_format)
{
aout_FiltersDelete (aout);
aout_OutputDelete (aout);
}
aout_volume_Delete (owner->volume);
aout_unlock (aout);
aout_OutputUnlock (aout);
var_Destroy (aout, "stereo-mode");
}
......@@ -125,8 +125,6 @@ static int aout_CheckReady (audio_output_t *aout)
{
aout_owner_t *owner = aout_owner (aout);
aout_assert_locked (aout);
int restart = atomic_exchange (&owner->restart, 0);
if (unlikely(restart))
{
......@@ -365,7 +363,7 @@ int aout_DecPlay (audio_output_t *aout, block_t *block, int input_rate)
block->i_length = CLOCK_FREQ * block->i_nb_samples
/ owner->input_format.i_rate;
aout_lock (aout);
aout_OutputLock (aout);
if (unlikely(aout_CheckReady (aout)))
goto drop; /* Pipeline is unrecoverably broken :-( */
......@@ -401,7 +399,7 @@ int aout_DecPlay (audio_output_t *aout, block_t *block, int input_rate)
owner->sync.discontinuity = false;
aout_OutputPlay (aout, block);
out:
aout_unlock (aout);
aout_OutputUnlock (aout);
return 0;
drop:
owner->sync.discontinuity = true;
......@@ -421,7 +419,7 @@ void aout_DecChangePause (audio_output_t *aout, bool paused, mtime_t date)
{
aout_owner_t *owner = aout_owner (aout);
aout_lock (aout);
aout_OutputLock (aout);
if (owner->sync.end != VLC_TS_INVALID)
{
if (paused)
......@@ -431,18 +429,18 @@ void aout_DecChangePause (audio_output_t *aout, bool paused, mtime_t date)
}
if (owner->mixer_format.i_format)
aout_OutputPause (aout, paused, date);
aout_unlock (aout);
aout_OutputUnlock (aout);
}
void aout_DecFlush (audio_output_t *aout)
{
aout_owner_t *owner = aout_owner (aout);
aout_lock (aout);
aout_OutputLock (aout);
owner->sync.end = VLC_TS_INVALID;
if (owner->mixer_format.i_format)
aout_OutputFlush (aout, false);
aout_unlock (aout);
aout_OutputUnlock (aout);
}
bool aout_DecIsEmpty (audio_output_t *aout)
......@@ -451,7 +449,7 @@ bool aout_DecIsEmpty (audio_output_t *aout)
mtime_t now = mdate ();
bool empty = true;
aout_lock (aout);
aout_OutputLock (aout);
if (owner->sync.end != VLC_TS_INVALID)
empty = owner->sync.end <= now;
if (empty && owner->mixer_format.i_format)
......@@ -459,6 +457,6 @@ bool aout_DecIsEmpty (audio_output_t *aout)
* buffer should be empty or almost. Thus draining should be fast
* and will not block the caller too long. */
aout_OutputFlush (aout, true);
aout_unlock (aout);
aout_OutputUnlock (aout);
return empty;
}
......@@ -33,6 +33,13 @@
#include "aout_internal.h"
/* Local functions */
static void aout_OutputAssertLocked (audio_output_t *aout)
{
aout_owner_t *owner = aout_owner (aout);
vlc_assert_locked (&owner->lock);
}
static void aout_Destructor( vlc_object_t * p_this );
static int var_Copy (vlc_object_t *src, const char *name, vlc_value_t prev,
......@@ -83,7 +90,7 @@ static int aout_GainNotify (audio_output_t *aout, float gain)
{
aout_owner_t *owner = aout_owner (aout);
aout_assert_locked (aout);
aout_OutputAssertLocked (aout);
aout_volume_SetVolume (owner->volume, gain);
/* XXX: ideally, return -1 if format cannot be amplified */
return 0;
......@@ -239,12 +246,12 @@ void aout_Destroy (audio_output_t *aout)
{
aout_owner_t *owner = aout_owner (aout);
aout_lock (aout);
aout_OutputLock (aout);
module_unneed (aout, owner->module);
/* Protect against late call from intf.c */
aout->volume_set = NULL;
aout->mute_set = NULL;
aout_unlock (aout);
aout_OutputUnlock (aout);
var_DelCallback (aout, "mute", var_Copy, aout->p_parent);
var_SetFloat (aout, "volume", -1.f);
......@@ -282,10 +289,10 @@ int aout_VolumeSet (audio_output_t *aout, float vol)
{
int ret = -1;
aout_lock (aout);
aout_OutputLock (aout);
if (aout->volume_set != NULL)
ret = aout->volume_set (aout, vol);
aout_unlock (aout);
aout_OutputUnlock (aout);
return ret;
}
......@@ -306,10 +313,10 @@ int aout_MuteSet (audio_output_t *aout, bool mute)
{
int ret = -1;
aout_lock (aout);
aout_OutputLock (aout);
if (aout->mute_set != NULL)
ret = aout->mute_set (aout, mute);
aout_unlock (aout);
aout_OutputUnlock (aout);
return ret;
}
......@@ -332,10 +339,10 @@ int aout_DeviceSet (audio_output_t *aout, const char *id)
{
int ret = -1;
aout_lock (aout);
aout_OutputLock (aout);
if (aout->device_select != NULL)
ret = aout->device_select (aout, id);
aout_unlock (aout);
aout_OutputUnlock (aout);
return ret;
}
......@@ -354,10 +361,10 @@ int aout_DevicesList (audio_output_t *aout, char ***ids, char ***names)
{
int ret = -1;
aout_lock (aout);
aout_OutputLock (aout);
if (aout->device_enum != NULL)
ret = aout->device_enum (aout, ids, names);
aout_unlock (aout);
aout_OutputUnlock (aout);
return ret;
}
......@@ -369,7 +376,7 @@ int aout_DevicesList (audio_output_t *aout, char ***ids, char ***names)
*/
int aout_OutputNew (audio_output_t *aout, audio_sample_format_t *restrict fmt)
{
aout_assert_locked (aout);
aout_OutputAssertLocked (aout);
/* Ideally, the audio filters would be created before the audio output,
* and the ideal audio format would be the output of the filters chain.
......@@ -462,7 +469,7 @@ int aout_OutputNew (audio_output_t *aout, audio_sample_format_t *restrict fmt)
*/
void aout_OutputDelete (audio_output_t *aout)
{
aout_assert_locked (aout);
aout_OutputAssertLocked (aout);
var_DelCallback (aout, "stereo-mode", aout_ChannelsRestart, NULL);
if (aout->stop != NULL)
......@@ -471,7 +478,7 @@ void aout_OutputDelete (audio_output_t *aout)
int aout_OutputTimeGet (audio_output_t *aout, mtime_t *delay)
{
aout_assert_locked (aout);
aout_OutputAssertLocked (aout);
if (aout->time_get == NULL)
return -1;
......@@ -485,7 +492,7 @@ int aout_OutputTimeGet (audio_output_t *aout, mtime_t *delay)
*/
void aout_OutputPlay (audio_output_t *aout, block_t *block)
{
aout_assert_locked (aout);
aout_OutputAssertLocked (aout);
aout->play (aout, block);
}
......@@ -505,7 +512,7 @@ static void PauseDefault (audio_output_t *aout, bool pause, mtime_t date)
*/
void aout_OutputPause( audio_output_t *aout, bool pause, mtime_t date )
{
aout_assert_locked (aout);
aout_OutputAssertLocked (aout);
((aout->pause != NULL) ? aout->pause : PauseDefault) (aout, pause, date);
}
......@@ -519,6 +526,20 @@ void aout_OutputPause( audio_output_t *aout, bool pause, mtime_t date )
*/
void aout_OutputFlush( audio_output_t *aout, bool wait )
{
aout_assert_locked( aout );
aout_OutputAssertLocked( aout );
aout->flush (aout, wait);
}
void aout_OutputLock (audio_output_t *aout)
{
aout_owner_t *owner = aout_owner (aout);
vlc_mutex_lock (&owner->lock);
}
void aout_OutputUnlock (audio_output_t *aout)
{
aout_owner_t *owner = aout_owner (aout);
vlc_mutex_unlock (&owner->lock);
}
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