From caa1eaab56c6c1eb94ad45489632f5d8ef9eff67 Mon Sep 17 00:00:00 2001 From: Thomas Guillem Date: Mon, 14 Nov 2022 16:51:31 +0100 Subject: [PATCH] input_decoder: move astream check up Fix a potential crash when the aout is failing to initialize. --- src/input/decoder.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/input/decoder.c b/src/input/decoder.c index 518b99baa038..a6c51f860a48 100644 --- a/src/input/decoder.c +++ b/src/input/decoder.c @@ -1293,6 +1293,15 @@ static int ModuleThread_PlayAudio( vlc_input_decoder_t *p_owner, vlc_frame_t *p_ } vlc_fifo_Lock(p_owner->p_fifo); + vlc_aout_stream *p_astream = p_owner->p_astream; + if( p_astream == NULL ) + { + vlc_fifo_Unlock(p_owner->p_fifo); + msg_Dbg( p_dec, "discarded audio buffer" ); + block_Release( p_audio ); + return VLC_EGENERIC; + } + if (p_owner->flushing) { vlc_fifo_Unlock(p_owner->p_fifo); @@ -1315,8 +1324,7 @@ static int ModuleThread_PlayAudio( vlc_input_decoder_t *p_owner, vlc_frame_t *p_ { msg_Dbg( p_dec, "end of audio preroll" ); - if( p_owner->p_astream ) - vlc_aout_stream_Flush( p_owner->p_astream ); + vlc_aout_stream_Flush( p_astream ); } /* */ @@ -1327,15 +1335,6 @@ static int ModuleThread_PlayAudio( vlc_input_decoder_t *p_owner, vlc_frame_t *p_ DecoderWaitUnblock( p_owner ); vlc_fifo_Unlock(p_owner->p_fifo); - vlc_aout_stream *p_astream = p_owner->p_astream; - - if( p_astream == NULL ) - { - msg_Dbg( p_dec, "discarded audio buffer" ); - block_Release( p_audio ); - return VLC_EGENERIC; - } - int status = vlc_aout_stream_Play( p_astream, p_audio ); if( status == AOUT_DEC_CHANGED ) {