[vlc-commits] [Git][videolan/vlc][master] 7 commits: input_decoder: move astream check up
Jean-Baptiste Kempf (@jbk)
gitlab at videolan.org
Tue Nov 22 18:02:12 UTC 2022
Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC
Commits:
caa1eaab by Thomas Guillem at 2022-11-22T17:46:40+00:00
input_decoder: move astream check up
Fix a potential crash when the aout is failing to initialize.
- - - - -
3de5c8d6 by Thomas Guillem at 2022-11-22T17:46:40+00:00
input_decoder: merge ModuleThread_UpdateStatAudio()
No functional changes.
- - - - -
29e3b6e7 by Thomas Guillem at 2022-11-22T17:46:40+00:00
input_decoder: merge ModuleThread_UpdateStatVideo()
No functional changes.
- - - - -
facee86b by Thomas Guillem at 2022-11-22T17:46:40+00:00
input_decoder: guard vlc_aout_stream_Play()
Like it's already done for Video in 7dcc370d120266ca552433b0b419f1e65f194f5c
Fixes vlc_aout_stream functions that could be called in parallel (Play +
Drain in //), leading to assert, crashes, or undefined behavior in aout
implementations.
It was not done for audio because vlc_aout_stream_Play() was blocking.
Main aout modules are not blocking anymore, we still need to fix the
less important ones.
Refs #27508
- - - - -
fb29fc62 by Thomas Guillem at 2022-11-22T17:46:40+00:00
input_decoder: guard vlc_aout_stream_Drain()
All vlc_aout_stream calls are now guarded by the fifo lock.
Fixes #27508
- - - - -
ba95b60a by Thomas Guillem at 2022-11-22T17:46:40+00:00
input_decoder: guard ModuleThread_PlayAudio() + stats
- - - - -
2a31cef6 by Thomas Guillem at 2022-11-22T17:46:40+00:00
input_decoder: guard ModuleThread_PlayVideo() + stats
- - - - -
1 changed file:
- src/input/decoder.c
Changes:
=====================================
src/input/decoder.c
=====================================
@@ -1145,10 +1145,8 @@ static int ModuleThread_PlayVideo( vlc_input_decoder_t *p_owner, picture_t *p_pi
return VLC_EGENERIC;
}
- vlc_fifo_Lock( p_owner->p_fifo );
if (p_owner->flushing)
{
- vlc_fifo_Unlock(p_owner->p_fifo);
picture_Release(p_picture);
return VLC_SUCCESS;
}
@@ -1160,7 +1158,6 @@ static int ModuleThread_PlayVideo( vlc_input_decoder_t *p_owner, picture_t *p_pi
bool prerolled = p_owner->i_preroll_end != PREROLL_NONE;
if( prerolled && p_owner->i_preroll_end > p_picture->date )
{
- vlc_fifo_Unlock( p_owner->p_fifo );
picture_Release( p_picture );
return VLC_SUCCESS;
}
@@ -1193,7 +1190,6 @@ static int ModuleThread_PlayVideo( vlc_input_decoder_t *p_owner, picture_t *p_pi
if( p_vout == NULL )
{
picture_Release( p_picture );
- vlc_fifo_Unlock(p_owner->p_fifo);
return VLC_EGENERIC;
}
@@ -1203,26 +1199,10 @@ static int ModuleThread_PlayVideo( vlc_input_decoder_t *p_owner, picture_t *p_pi
vout_Flush( p_vout, p_picture->date );
}
vout_PutPicture( p_vout, p_picture );
- vlc_fifo_Unlock(p_owner->p_fifo);
return VLC_SUCCESS;
}
-static void ModuleThread_UpdateStatVideo( vlc_input_decoder_t *p_owner,
- bool lost )
-{
- unsigned displayed = 0;
- unsigned vout_lost = 0;
- unsigned vout_late = 0;
- if( p_owner->p_vout != NULL )
- {
- vout_GetResetStatistic( p_owner->p_vout, &displayed, &vout_lost, &vout_late );
- }
- if (lost) vout_lost++;
-
- decoder_Notify(p_owner, on_new_video_stats, 1, vout_lost, displayed, vout_late);
-}
-
static void ModuleThread_QueueVideo( decoder_t *p_dec, picture_t *p_pic )
{
assert( p_pic );
@@ -1234,9 +1214,24 @@ static void ModuleThread_QueueVideo( decoder_t *p_dec, picture_t *p_pic )
vlc_tracer_TraceStreamPTS( tracer, "DEC", p_owner->psz_id,
"OUT", p_pic->date );
}
+
+ vlc_fifo_Lock( p_owner->p_fifo );
+
int success = ModuleThread_PlayVideo( p_owner, p_pic );
- ModuleThread_UpdateStatVideo( p_owner, success != VLC_SUCCESS );
+ unsigned displayed = 0;
+ unsigned vout_lost = 0;
+ unsigned vout_late = 0;
+ if( p_owner->p_vout != NULL )
+ {
+ vout_GetResetStatistic( p_owner->p_vout, &displayed, &vout_lost, &vout_late );
+ }
+ if (success != VLC_SUCCESS)
+ vout_lost++;
+
+ vlc_fifo_Unlock(p_owner->p_fifo);
+
+ decoder_Notify(p_owner, on_new_video_stats, 1, vout_lost, displayed, vout_late);
}
static vlc_decoder_device * thumbnailer_get_device( decoder_t *p_dec )
@@ -1292,10 +1287,16 @@ static int ModuleThread_PlayAudio( vlc_input_decoder_t *p_owner, vlc_frame_t *p_
return VLC_EGENERIC;
}
- vlc_fifo_Lock(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;
+ }
+
if (p_owner->flushing)
{
- vlc_fifo_Unlock(p_owner->p_fifo);
block_Release(p_audio);
return VLC_SUCCESS;
}
@@ -1303,38 +1304,20 @@ static int ModuleThread_PlayAudio( vlc_input_decoder_t *p_owner, vlc_frame_t *p_
bool prerolled = p_owner->i_preroll_end != PREROLL_NONE;
if( prerolled && p_owner->i_preroll_end > p_audio->i_pts )
{
- vlc_fifo_Unlock(p_owner->p_fifo);
block_Release( p_audio );
return VLC_SUCCESS;
}
p_owner->i_preroll_end = PREROLL_NONE;
- vlc_fifo_Unlock(p_owner->p_fifo);
if( unlikely(prerolled) )
{
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 );
}
- /* */
- /* */
- vlc_fifo_Lock(p_owner->p_fifo);
-
- /* */
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 )
@@ -1349,21 +1332,8 @@ static int ModuleThread_PlayAudio( vlc_input_decoder_t *p_owner, vlc_frame_t *p_
* previous (failing) aout but will try to create a new one. */
atomic_store( &p_owner->reload, RELOAD_DECODER_AOUT );
}
- return VLC_SUCCESS;
-}
-static void ModuleThread_UpdateStatAudio( vlc_input_decoder_t *p_owner,
- bool lost )
-{
- unsigned played = 0;
- unsigned aout_lost = 0;
- if( p_owner->p_astream != NULL )
- {
- vlc_aout_stream_GetResetStats( p_owner->p_astream, &aout_lost, &played );
- }
- if (lost) aout_lost++;
-
- decoder_Notify(p_owner, on_new_audio_stats, 1, aout_lost, played);
+ return VLC_SUCCESS;
}
static void ModuleThread_QueueAudio( decoder_t *p_dec, vlc_frame_t *p_aout_buf )
@@ -1376,9 +1346,23 @@ static void ModuleThread_QueueAudio( decoder_t *p_dec, vlc_frame_t *p_aout_buf )
vlc_tracer_TraceStreamDTS( tracer, "DEC", p_owner->psz_id, "OUT",
p_aout_buf->i_pts, p_aout_buf->i_dts );
}
+
+ vlc_fifo_Lock(p_owner->p_fifo);
+
int success = ModuleThread_PlayAudio( p_owner, p_aout_buf );
- ModuleThread_UpdateStatAudio( p_owner, success != VLC_SUCCESS );
+ unsigned played = 0;
+ unsigned aout_lost = 0;
+ if( p_owner->p_astream != NULL )
+ {
+ vlc_aout_stream_GetResetStats( p_owner->p_astream, &aout_lost, &played );
+ }
+ if (success != VLC_SUCCESS)
+ aout_lost++;
+
+ vlc_fifo_Unlock(p_owner->p_fifo);
+
+ decoder_Notify(p_owner, on_new_audio_stats, 1, aout_lost, played);
}
static void ModuleThread_PlaySpu( vlc_input_decoder_t *p_owner, subpicture_t *p_subpic )
@@ -1807,6 +1791,7 @@ static void *DecoderThread( void *p_data )
DecoderThread_ProcessInput( p_owner, frame );
+ vlc_fifo_Lock(p_owner->p_fifo);
if( frame == NULL && p_owner->dec.fmt_in->i_cat == AUDIO_ES )
{ /* Draining: the decoder is drained and all decoded buffers are
* queued to the output at this point. Now drain the output. */
@@ -1815,7 +1800,6 @@ static void *DecoderThread( void *p_data )
}
/* TODO? Wait for draining instead of polling. */
- vlc_fifo_Lock(p_owner->p_fifo);
if( p_owner->b_draining && (frame == NULL) )
p_owner->b_draining = false;
vlc_cond_signal( &p_owner->wait_acknowledge );
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/a6219130d77157a5767c852f0e2b2253b72d6d8c...2a31cef61dec875d783cac04d08e7e326afafcc6
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/a6219130d77157a5767c852f0e2b2253b72d6d8c...2a31cef61dec875d783cac04d08e7e326afafcc6
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list