vlc | branch: master | Rémi Denis-Courmont <[email protected]> | Sat May 5 13:00:20 2018 +0300| [137bed8e314fdf5c727898e69164a9595e154a59] | committer: Rémi Denis-Courmont
Revert "aout: do not block thread changing volume/mute/device (fixes #8240)" This reverts commit f788153763bf56fda744df5b9abaa893c402378e. This is no longer necessary as aout->play() no longer blocks interface requests. > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=137bed8e314fdf5c727898e69164a9595e154a59 --- src/audio_output/aout_internal.h | 8 --- src/audio_output/output.c | 105 ++++++++------------------------------- 2 files changed, 20 insertions(+), 93 deletions(-) diff --git a/src/audio_output/aout_internal.h b/src/audio_output/aout_internal.h index d115e339fe..a960660afb 100644 --- a/src/audio_output/aout_internal.h +++ b/src/audio_output/aout_internal.h @@ -57,14 +57,6 @@ typedef struct struct { vlc_mutex_t lock; - char *device; - float volume; - signed char mute; - } req; - - struct - { - vlc_mutex_t lock; aout_dev_t *list; unsigned count; } dev; diff --git a/src/audio_output/output.c b/src/audio_output/output.c index aa61131c6c..541202d5da 100644 --- a/src/audio_output/output.c +++ b/src/audio_output/output.c @@ -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); - - char *dev = NULL; - if (id != NULL) - { - dev = strdup (id); - if (unlikely(dev == NULL)) - return -1; - } + int ret; - 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; } /** _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
