[vlc-commits] Fix mixer leak (and crash at exit) when audio output fails
Rémi Denis-Courmont
git at videolan.org
Wed Mar 7 20:04:00 CET 2012
vlc/vlc-2.0 | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed Mar 7 19:07:57 2012 +0200| [29317fb1d45bbf7159fc1cf98b3348fbdbfd7d75] | committer: Rémi Denis-Courmont
Fix mixer leak (and crash at exit) when audio output fails
(cherry picked from commit 4f292d82afc5c069855572f0d00919edfb394cf8)
> http://git.videolan.org/gitweb.cgi/vlc/vlc-2.0.git/?a=commit;h=29317fb1d45bbf7159fc1cf98b3348fbdbfd7d75
---
src/audio_output/dec.c | 15 ++++++++++++---
1 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/src/audio_output/dec.c b/src/audio_output/dec.c
index 7d0316f..ab61214 100644
--- a/src/audio_output/dec.c
+++ b/src/audio_output/dec.c
@@ -97,7 +97,7 @@ int aout_DecNew( audio_output_t *p_aout,
aout_Shutdown (p_aout);
}
#endif
- int ret = -1;
+ int ret = 0;
/* TODO: reduce lock scope depending on decoder's real need */
aout_lock( p_aout );
@@ -110,7 +110,10 @@ int aout_DecNew( audio_output_t *p_aout,
owner->input_format = *p_format;
vlc_atomic_set (&owner->restart, 0);
if( aout_OutputNew( p_aout, p_format ) < 0 )
+ {
+ ret = -1;
goto error;
+ }
/* Allocate a software mixer */
assert (owner->volume.mixer == NULL);
@@ -129,9 +132,15 @@ int aout_DecNew( audio_output_t *p_aout,
owner->input = aout_InputNew (p_aout, p_format, &owner->mixer_format,
p_request_vout);
if (owner->input == NULL)
+ {
+ struct audio_mixer *mixer = owner->volume.mixer;
+
+ owner->volume.mixer = NULL;
aout_OutputDelete (p_aout);
- else
- ret = 0;
+ aout_unlock (p_aout);
+ aout_MixerDelete (mixer);
+ return -1;
+ }
error:
aout_unlock( p_aout );
return ret;
More information about the vlc-commits
mailing list