[Android] Unbork audio in latest nightlies

Edward Wang git at videolan.org
Sun Mar 3 23:15:52 CET 2013


vlc-ports/android | branch: master | Edward Wang <edward.c.wang at compdigitec.com> | Sun Mar  3 17:12:11 2013 -0500| [a2256542f7ba40f2b0768ab43b0dcd90bbb3548f] | committer: Edward Wang

Unbork audio in latest nightlies

Users are noticing and wondering what happened to their audio, and it hasn't been fixed for 5 days now.

Feel free to remove after audio is fixed in vlc.git.

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

 compile.sh                                         |   10 +-
 ...-do-not-block-thread-changing-volume-mute.patch |  218 ++++++++++++++++++++
 2 files changed, 227 insertions(+), 1 deletion(-)

diff --git a/compile.sh b/compile.sh
index 21226c3..2ee9a73 100755
--- a/compile.sh
+++ b/compile.sh
@@ -78,12 +78,19 @@ NDK_TOOLCHAIN_PATH=${ANDROID_NDK}/toolchains/${PATH_HOST}-${GCCVER}/prebuilt/`un
 export PATH=${NDK_TOOLCHAIN_PATH}:${PATH}
 
 # 1/ libvlc, libvlccore and its plugins
-TESTED_HASH=7018018
+TESTED_HASH=e1b0fcc
 if [ ! -d "vlc" ]; then
     echo "VLC source not found, cloning"
     git clone git://git.videolan.org/vlc.git vlc
     cd vlc
     git checkout -B android ${TESTED_HASH}
+    echo "Applying the patches"
+    git am -3 ../patches/*.patch
+    if [ $? -ne 0 ]; then
+        git am --abort
+        echo "Applying the patches failed, aborting git-am"
+        exit 1
+    fi
 else
     echo "VLC source found"
     cd vlc
@@ -99,6 +106,7 @@ cd vlc
 git reset --hard origin
 git pull origin master
 git checkout -B android ${TESTED_HASH}
+git am -3 ../patches/*
 
 *** : This will delete any changes you made to the current branch ***
 
diff --git a/patches/0001-Revert-aout-do-not-block-thread-changing-volume-mute.patch b/patches/0001-Revert-aout-do-not-block-thread-changing-volume-mute.patch
new file mode 100644
index 0000000..7148d31
--- /dev/null
+++ b/patches/0001-Revert-aout-do-not-block-thread-changing-volume-mute.patch
@@ -0,0 +1,218 @@
+From 56809f6b8a6b3e6009f0df1784b316cf831e1608 Mon Sep 17 00:00:00 2001
+From: Edward Wang <edward.c.wang at compdigitec.com>
+Date: Thu, 28 Feb 2013 19:08:52 -0500
+Subject: [PATCH] Revert "aout: do not block thread changing
+ volume/mute/device (fixes #8240)"
+
+This reverts commit f788153763bf56fda744df5b9abaa893c402378e.
+
+Conflicts:
+
+	src/audio_output/output.c
+---
+ src/audio_output/aout_internal.h |    8 ---
+ src/audio_output/output.c        |  103 +++++++-------------------------------
+ 2 files changed, 18 insertions(+), 93 deletions(-)
+
+diff --git a/src/audio_output/aout_internal.h b/src/audio_output/aout_internal.h
+index 5c1c9dd..58d795a 100644
+--- a/src/audio_output/aout_internal.h
++++ b/src/audio_output/aout_internal.h
+@@ -54,14 +54,6 @@ typedef struct
+ 
+     struct
+     {
+-        vlc_mutex_t lock;
+-        char *device;
+-        float volume;
+-        char mute;
+-    } req;
+-
+-    struct
+-    {
+         mtime_t end; /**< Last seen PTS */
+         unsigned resamp_start_drift; /**< Resampler drift absolute value */
+         int resamp_type; /**< Resampler mode (FIXME: redundant / resampling) */
+diff --git a/src/audio_output/output.c b/src/audio_output/output.c
+index 2f92c11..5cd28f2 100644
+--- a/src/audio_output/output.c
++++ b/src/audio_output/output.c
+@@ -25,9 +25,6 @@
+ # include "config.h"
+ #endif
+ 
+-#include <stdlib.h>
+-#include <assert.h>
+-
+ #include <vlc_common.h>
+ #include <vlc_aout.h>
+ #include <vlc_modules.h>
+@@ -35,8 +32,6 @@
+ #include "libvlc.h"
+ #include "aout_internal.h"
+ 
+-static const char unset_str[1] = ""; /* Non-NULL constant string pointer */
+-
+ /* Local functions */
+ static void aout_OutputAssertLocked (audio_output_t *aout)
+ {
+@@ -117,11 +112,6 @@ 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);
+-    owner->req.device = (char *)unset_str;
+-    owner->req.volume = -1.f;
+-    owner->req.mute = -1;
+-
+     vlc_object_set_destructor (aout, aout_Destructor);
+ 
+     /* Audio output module callbacks */
+@@ -277,8 +267,6 @@ static void aout_Destructor (vlc_object_t *obj)
+     audio_output_t *aout = (audio_output_t *)obj;
+     aout_owner_t *owner = aout_owner (aout);
+ 
+-    assert (owner->req.device == unset_str);
+-    vlc_mutex_destroy (&owner->req.lock);
+     vlc_mutex_destroy (&owner->lock);
+ }
+ 
+@@ -476,46 +464,11 @@ void aout_OutputLock (audio_output_t *aout)
+     vlc_mutex_lock (&owner->lock);
+ }
+ 
+-static int aout_OutputTryLock (audio_output_t *aout)
+-{
+-    aout_owner_t *owner = aout_owner (aout);
+-
+-    return vlc_mutex_trylock (&owner->lock);
+-}
+-
+ 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);
+ }
+ 
+ /**
+@@ -531,20 +484,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;
+ }
+ 
+ /**
+@@ -558,19 +507,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;
+ }
+ 
+ /**
+@@ -586,29 +532,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;
+-    }
+-
+-    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);
++    int ret;
+ 
+-    if (aout_OutputTryLock (aout) == 0)
+-        aout_OutputUnlock (aout);
+-    return 0;
++    aout_OutputLock (aout);
++    ret = aout_OutputDeviceSet (aout, id);
++    aout_OutputUnlock (aout);
++    return ret;
+ }
+ 
+ /**
+-- 
+1.7.5.4
+



More information about the Android mailing list