Commit 137bed8e authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Revert "aout: do not block thread changing volume/mute/device (fixes #8240)"

This reverts commit f7881537.
This is no longer necessary as aout->play() no longer blocks interface
requests.
parent ea84982c
......@@ -54,14 +54,6 @@ typedef struct
aout_filters_t *filters;
aout_volume_t *volume;
struct
{
vlc_mutex_t lock;
char *device;
float volume;
signed char mute;
} req;
struct
{
vlc_mutex_t lock;
......
......@@ -35,8 +35,6 @@
#include "libvlc.h"
#include "aout_internal.h"
static const char unset_str[1] = ""; /* Non-NULL constant string pointer */
struct aout_dev
{
aout_dev_t *next;
......@@ -213,15 +211,13 @@ static void aout_OutputLock(audio_output_t *aout)
vlc_mutex_lock(&owner->lock);
}
static int aout_OutputTryLock(audio_output_t *aout)
static void aout_OutputUnlock(audio_output_t *aout)
{
aout_owner_t *owner = aout_owner(aout);
return vlc_mutex_trylock(&owner->lock);
vlc_mutex_unlock(&owner->lock);
}
static void aout_OutputUnlock(audio_output_t *aout);
#undef aout_New
/**
* Creates an audio output object and initializes an output module.
......@@ -238,14 +234,10 @@ audio_output_t *aout_New (vlc_object_t *parent)
aout_owner_t *owner = aout_owner (aout);
vlc_mutex_init (&owner->lock);
vlc_mutex_init (&owner->req.lock);
vlc_mutex_init (&owner->dev.lock);
vlc_mutex_init (&owner->vp.lock);
vlc_viewpoint_init (&owner->vp.value);
atomic_init (&owner->vp.update, false);
owner->req.device = (char *)unset_str;
owner->req.volume = -1.f;
owner->req.mute = -1;
vlc_object_set_destructor (aout, aout_Destructor);
......@@ -420,9 +412,7 @@ static void aout_Destructor (vlc_object_t *obj)
free (dev);
}
assert (owner->req.device == unset_str);
vlc_mutex_destroy (&owner->vp.lock);
vlc_mutex_destroy (&owner->req.lock);
vlc_mutex_destroy (&owner->lock);
}
......@@ -643,41 +633,6 @@ static int aout_OutputDeviceSet (audio_output_t *aout, const char *id)
return (aout->device_select != NULL) ? aout->device_select (aout, id) : -1;
}
static void aout_OutputUnlock(audio_output_t *aout)
{
aout_owner_t *owner = aout_owner (aout);
vlc_assert_locked (&owner->lock);
vlc_mutex_lock (&owner->req.lock);
if (owner->req.device != unset_str)
{
aout_OutputDeviceSet (aout, owner->req.device);
free (owner->req.device);
owner->req.device = (char *)unset_str;
}
if (owner->req.volume >= 0.f)
{
aout_OutputVolumeSet (aout, owner->req.volume);
owner->req.volume = -1.f;
}
if (owner->req.mute >= 0)
{
aout_OutputMuteSet (aout, owner->req.mute);
owner->req.mute = -1;
}
vlc_mutex_unlock (&owner->lock);
/* If another thread is blocked waiting for owner->req.lock at this point,
* this aout_OutputUnlock() call will not see and apply its change request.
* The other thread will need to apply the change request itself, which
* implies it is able to (try-)lock owner->lock. Therefore this thread must
* release owner->lock _before_ owner->req.lock. Do not reorder!!! */
vlc_mutex_unlock (&owner->req.lock);
}
/**
* Gets the volume of the audio output stream (independent of mute).
* \return Current audio volume (0. = silent, 1. = nominal),
......@@ -691,20 +646,16 @@ float aout_VolumeGet (audio_output_t *aout)
/**
* Sets the volume of the audio output stream.
* \note The mute status is not changed.
* \return 0 on success, -1 on failure (TODO).
* \return 0 on success, -1 on failure.
*/
int aout_VolumeSet (audio_output_t *aout, float vol)
{
aout_owner_t *owner = aout_owner (aout);
assert (vol >= 0.f);
vlc_mutex_lock (&owner->req.lock);
owner->req.volume = vol;
vlc_mutex_unlock (&owner->req.lock);
int ret;
if (aout_OutputTryLock (aout) == 0)
aout_OutputUnlock (aout);
return 0;
aout_OutputLock(aout);
ret = aout_OutputVolumeSet(aout, vol);
aout_OutputUnlock(aout);
return ret;
}
/**
......@@ -745,19 +696,16 @@ int aout_MuteGet (audio_output_t *aout)
/**
* Sets the audio output stream mute flag.
* \return 0 on success, -1 on failure (TODO).
* \return 0 on success, -1 on failure.
*/
int aout_MuteSet (audio_output_t *aout, bool mute)
{
aout_owner_t *owner = aout_owner (aout);
vlc_mutex_lock (&owner->req.lock);
owner->req.mute = mute;
vlc_mutex_unlock (&owner->req.lock);
int ret;
if (aout_OutputTryLock (aout) == 0)
aout_OutputUnlock (aout);
return 0;
aout_OutputLock(aout);
ret = aout_OutputMuteSet(aout, mute);
aout_OutputUnlock(aout);
return ret;
}
/**
......@@ -773,29 +721,16 @@ char *aout_DeviceGet (audio_output_t *aout)
/**
* Selects an audio output device.
* \param id device ID to select, or NULL for the default device
* \return zero on success, non-zero on error (TODO).
* \return zero on success, non-zero on error.
*/
int aout_DeviceSet (audio_output_t *aout, const char *id)
{
aout_owner_t *owner = aout_owner (aout);
int ret;
char *dev = NULL;
if (id != NULL)
{
dev = strdup (id);
if (unlikely(dev == NULL))
return -1;
}
vlc_mutex_lock (&owner->req.lock);
if (owner->req.device != unset_str)
free (owner->req.device);
owner->req.device = dev;
vlc_mutex_unlock (&owner->req.lock);
if (aout_OutputTryLock (aout) == 0)
aout_OutputUnlock (aout);
return 0;
aout_OutputLock(aout);
ret = aout_OutputDeviceSet(aout, id);
aout_OutputUnlock(aout);
return ret;
}
/**
......
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