Skip to content

Commit

Permalink
input_decoder: move astream check up
Browse files Browse the repository at this point in the history
Fix a potential crash when the aout is failing to initialize.
  • Loading branch information
tguillem authored and jbkempf committed Nov 22, 2022
1 parent a621913 commit caa1eaa
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions src/input/decoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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 );
}

/* */
Expand All @@ -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 )
{
Expand Down

0 comments on commit caa1eaa

Please sign in to comment.