[vlc-devel] [V3 PATCH 2/3] dec: fix pause/rate not handled
Thomas Guillem
thomas at gllm.fr
Tue Jul 3 11:15:51 CEST 2018
This could happen when the aout or the vout were not yet created (or were
restarting) when pause/rate commands were handled.
---
src/input/decoder.c | 38 +++++++++++++++++++++++++++++++-------
1 file changed, 31 insertions(+), 7 deletions(-)
diff --git a/src/input/decoder.c b/src/input/decoder.c
index ed6af7d0d0..27dbfba50d 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -1486,9 +1486,10 @@ static void DecoderProcessFlush( decoder_t *p_dec )
vlc_mutex_unlock( &p_owner->lock );
}
-static void OutputChangePause( decoder_t *p_dec, bool paused, vlc_tick_t date )
+static int OutputChangePause( decoder_t *p_dec, bool paused, vlc_tick_t date )
{
struct decoder_owner *p_owner = dec_get_owner( p_dec );
+ int ret = VLC_EGENERIC;
msg_Dbg( p_dec, "toggling %s", paused ? "resume" : "pause" );
@@ -1497,23 +1498,33 @@ static void OutputChangePause( decoder_t *p_dec, bool paused, vlc_tick_t date )
{
case VIDEO_ES:
if( p_owner->p_vout != NULL )
+ {
vout_ChangePause( p_owner->p_vout, paused, date );
+ ret = VLC_SUCCESS;
+ }
break;
case AUDIO_ES:
if( p_owner->p_aout != NULL )
+ {
aout_DecChangePause( p_owner->p_aout, paused, date );
+ ret = VLC_SUCCESS;
+ }
break;
case SPU_ES:
+ ret = VLC_SUCCESS;
break;
default:
vlc_assert_unreachable();
}
vlc_mutex_unlock( &p_owner->lock );
+
+ return ret;
}
-static void OutputChangeRate( decoder_t *p_dec, float rate )
+static int OutputChangeRate( decoder_t *p_dec, float rate )
{
struct decoder_owner *p_owner = dec_get_owner( p_dec );
+ int ret = VLC_EGENERIC;
msg_Dbg( p_dec, "changing rate: %f", rate );
@@ -1521,17 +1532,24 @@ static void OutputChangeRate( decoder_t *p_dec, float rate )
switch( p_dec->fmt_out.i_cat )
{
case VIDEO_ES:
+ ret = VLC_SUCCESS;
break;
case AUDIO_ES:
if( p_owner->p_aout != NULL )
+ {
aout_DecChangeRate( p_owner->p_aout, rate );
+ ret = VLC_SUCCESS;
+ }
break;
case SPU_ES:
+ ret = VLC_SUCCESS;
break;
default:
vlc_assert_unreachable();
}
vlc_mutex_unlock( &p_owner->lock );
+
+ return ret;
}
/**
@@ -1576,29 +1594,35 @@ static void *DecoderThread( void *p_data )
if( paused != p_owner->paused )
{ /* Update playing/paused status of the output */
int canc = vlc_savecancel();
- vlc_tick_t date = p_owner->pause_date;
+ bool request_paused = p_owner->paused;
+ vlc_tick_t request_date = p_owner->pause_date;
- paused = p_owner->paused;
vlc_fifo_Unlock( p_owner->p_fifo );
- OutputChangePause( p_dec, paused, date );
+ bool success = OutputChangePause( p_dec, request_paused,
+ request_date ) == VLC_SUCCESS;
vlc_restorecancel( canc );
vlc_fifo_Lock( p_owner->p_fifo );
+ if (success)
+ paused = request_paused;
continue;
}
if( rate != p_owner->rate )
{
int canc = vlc_savecancel();
+ float request_rate = p_owner->rate;
- rate = p_owner->rate;
vlc_fifo_Unlock( p_owner->p_fifo );
- OutputChangeRate( p_dec, rate );
+ bool success =
+ OutputChangeRate( p_dec, request_rate ) == VLC_SUCCESS;
vlc_restorecancel( canc );
vlc_fifo_Lock( p_owner->p_fifo );
+ if (success)
+ rate = request_rate;
}
if( p_owner->paused && p_owner->frames_countdown == 0 )
--
2.18.0
More information about the vlc-devel
mailing list