[vlc-commits] auhal: limit scope of mutex

David Fuhrmann git at videolan.org
Thu Nov 28 14:33:27 CET 2013


vlc/vlc-2.1 | branch: master | David Fuhrmann <david.fuhrmann at googlemail.com> | Wed Aug 21 19:42:41 2013 +0200| [18af443ebc9e5dd6db679120060b82b732957e43] | committer: Felix Paul Kühne

auhal: limit scope of mutex

This should suffice as the variable is only modified on this thread.
Avoids deadlock in refs #9141

(cherry picked from commit b2823701b6123b5cb1f862dec7f5a62a9d77d17f)
Signed-off-by: Felix Paul Kühne <fkuehne at videolan.org>

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

 modules/audio_output/auhal.c |    7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/modules/audio_output/auhal.c b/modules/audio_output/auhal.c
index 12828e0..0f33d0f 100644
--- a/modules/audio_output/auhal.c
+++ b/modules/audio_output/auhal.c
@@ -349,6 +349,7 @@ static int Start(audio_output_t *p_aout, audio_sample_format_t *restrict fmt)
         err = AudioObjectGetPropertyData(kAudioObjectSystemObject, &defaultDeviceAddress, 0, NULL, &propertySize, &defaultDeviceID);
         if (err != noErr) {
             msg_Err(p_aout, "could not get default audio device [%4.4s]", (char *)&err);
+            vlc_mutex_unlock(&p_sys->var_lock);
             goto error;
         }
         else
@@ -357,6 +358,7 @@ static int Start(audio_output_t *p_aout, audio_sample_format_t *restrict fmt)
         p_sys->i_selected_dev = defaultDeviceID;
         p_sys->b_selected_dev_is_digital = var_InheritBool(p_aout, "spdif");
     }
+    vlc_mutex_unlock(&p_sys->var_lock);
 
     // recheck if device still supports digital
     b_start_digital = p_sys->b_selected_dev_is_digital;
@@ -410,7 +412,6 @@ static int Start(audio_output_t *p_aout, audio_sample_format_t *restrict fmt)
             b_success = true;
         }
     }
-    vlc_mutex_unlock(&p_sys->var_lock);
 
     if (b_success) {
         p_aout->play = Play;
@@ -422,7 +423,6 @@ static int Start(audio_output_t *p_aout, audio_sample_format_t *restrict fmt)
 
 error:
     /* If we reach this, this aout has failed */
-    vlc_mutex_unlock(&p_sys->var_lock);
     msg_Err(p_aout, "opening auhal output failed");
     return VLC_EGENERIC;
 }
@@ -1056,7 +1056,6 @@ static void Stop(audio_output_t *p_aout)
         verify_noerr(AudioComponentInstanceDispose(p_sys->au_unit));
     }
 
-    vlc_mutex_lock(&p_sys->var_lock);
     if (p_sys->b_digital) {
         /* Stop device */
         err = AudioDeviceStop(p_sys->i_selected_dev,
@@ -1119,8 +1118,6 @@ static void Stop(audio_output_t *p_aout)
         msg_Warn(p_aout, "failed to remove audio device life checker [%4.4s]", (char *)&err);
     }
 
-    vlc_mutex_unlock(&p_sys->var_lock);
-
     p_sys->i_bytes_per_sample = 0;
     p_sys->b_digital = false;
 



More information about the vlc-commits mailing list