[vlc-commits] auhal: fix crash on error paths for stream format change

David Fuhrmann git at videolan.org
Mon Nov 25 19:53:42 CET 2013


vlc | branch: master | David Fuhrmann <david.fuhrmann at googlemail.com> | Mon Nov 25 19:48:40 2013 +0100| [eb72c5a30544b2c12f16200b11b79e5774849db3] | committer: David Fuhrmann

auhal: fix crash on error paths for stream format change

ref #9957

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

 modules/audio_output/auhal.c |   13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/modules/audio_output/auhal.c b/modules/audio_output/auhal.c
index 50f5411..fd1b060 100644
--- a/modules/audio_output/auhal.c
+++ b/modules/audio_output/auhal.c
@@ -1863,6 +1863,8 @@ static int AudioStreamChangeFormat(audio_output_t *p_aout, AudioStreamID i_strea
     OSStatus            err = noErr;
     UInt32              i_param_size = 0;
 
+    int retValue = true;
+
     AudioObjectPropertyAddress physicalFormatAddress = { kAudioStreamPropertyPhysicalFormat, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster };
 
     struct { vlc_mutex_t lock; vlc_cond_t cond; } w;
@@ -1878,7 +1880,8 @@ static int AudioStreamChangeFormat(audio_output_t *p_aout, AudioStreamID i_strea
     err = AudioObjectAddPropertyListener(i_stream_id, &physicalFormatAddress, StreamListener, (void *)&w);
     if (err != noErr) {
         msg_Err(p_aout, "AudioObjectAddPropertyListener for kAudioStreamPropertyPhysicalFormat failed [%4.4s]", (char *)&err);
-        return false;
+        retValue = false;
+        goto out;
     }
 
     /* change the format */
@@ -1886,7 +1889,8 @@ static int AudioStreamChangeFormat(audio_output_t *p_aout, AudioStreamID i_strea
                                      &change_format);
     if (err != noErr) {
         msg_Err(p_aout, "could not set the stream format [%4.4s]", (char *)&err);
-        return false;
+        retValue = false;
+        goto out;
     }
 
     /* The AudioStreamSetProperty is not only asynchronious (requiring the locks)
@@ -1913,11 +1917,12 @@ static int AudioStreamChangeFormat(audio_output_t *p_aout, AudioStreamID i_strea
         /* We need to check again */
     }
 
+out:
     /* Removing the property listener */
     err = AudioObjectRemovePropertyListener(i_stream_id, &physicalFormatAddress, StreamListener, (void *)&w);
     if (err != noErr) {
         msg_Err(p_aout, "AudioStreamRemovePropertyListener failed [%4.4s]", (char *)&err);
-        return false;
+        retValue = false;
     }
 
     /* Destroy the lock and condition */
@@ -1925,5 +1930,5 @@ static int AudioStreamChangeFormat(audio_output_t *p_aout, AudioStreamID i_strea
     vlc_mutex_destroy(&w.lock);
     vlc_cond_destroy(&w.cond);
 
-    return true;
+    return retValue;
 }



More information about the vlc-commits mailing list