[vlc-commits] Revert "aout: simplify, remove unset_str[]"

Thomas Guillem git at videolan.org
Tue Jun 27 15:53:57 CEST 2017


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Tue Jun 27 15:52:59 2017 +0200| [dd62aca4bbfe207422c423c131f5cd6ddf2d5c21] | committer: Thomas Guillem

Revert "aout: simplify, remove unset_str[]"

This broke the ability to unset an audio device.

This reverts commit 4074b544fb288b0703f4b8160c9feed6ecb8a318.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=dd62aca4bbfe207422c423c131f5cd6ddf2d5c21
---

 src/audio_output/output.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/src/audio_output/output.c b/src/audio_output/output.c
index dbf4f8169d..8a70cdfddc 100644
--- a/src/audio_output/output.c
+++ b/src/audio_output/output.c
@@ -35,6 +35,8 @@
 #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;
@@ -187,7 +189,7 @@ audio_output_t *aout_New (vlc_object_t *parent)
     vlc_mutex_init (&owner->lock);
     vlc_mutex_init (&owner->req.lock);
     vlc_mutex_init (&owner->dev.lock);
-    owner->req.device = NULL;
+    owner->req.device = (char *)unset_str;
     owner->req.volume = -1.f;
     owner->req.mute = -1;
 
@@ -355,7 +357,7 @@ static void aout_Destructor (vlc_object_t *obj)
         free (dev);
     }
 
-    assert (owner->req.device == NULL);
+    assert (owner->req.device == unset_str);
     vlc_mutex_destroy (&owner->req.lock);
     vlc_mutex_destroy (&owner->lock);
 }
@@ -562,11 +564,11 @@ void aout_OutputUnlock (audio_output_t *aout)
     vlc_assert_locked (&owner->lock);
     vlc_mutex_lock (&owner->req.lock);
 
-    if (owner->req.device != NULL)
+    if (owner->req.device != unset_str)
     {
         aout_OutputDeviceSet (aout, owner->req.device);
         free (owner->req.device);
-        owner->req.device = NULL;
+        owner->req.device = (char *)unset_str;
     }
 
     if (owner->req.volume >= 0.f)
@@ -673,7 +675,8 @@ int aout_DeviceSet (audio_output_t *aout, const char *id)
     }
 
     vlc_mutex_lock (&owner->req.lock);
-    free (owner->req.device);
+    if (owner->req.device != unset_str)
+        free (owner->req.device);
     owner->req.device = dev;
     vlc_mutex_unlock (&owner->req.lock);
 



More information about the vlc-commits mailing list