Commit eb72c5a3 authored by David Fuhrmann's avatar David Fuhrmann

auhal: fix crash on error paths for stream format change

ref #9957
parent 7e94e20b
......@@ -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;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment