vlc | branch: master | Thomas Guillem <[email protected]> | Mon May 6 14:08:26 2019 +0200| [ad183c8ffc20b964d5b0fb66c47d2dfb3f92fb06] | committer: Thomas Guillem
input: fix vout recycling Vout recycling as keeping the same "vout display" plugin and not disabling/enabling the window. Add input_resource_StopFreeVout: Used to stop the re-used vout if there is no video following the current input. The vout is now always closed or paused from input_resource_PutVout(). Only the main vout is paused, all additional vouts will be closed. The main vout will be actually closed from input_resource_StopFreeVout(), when we are sure that the next input doesn't have video. > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=ad183c8ffc20b964d5b0fb66c47d2dfb3f92fb06 --- src/input/decoder.c | 3 --- src/input/es_out.c | 6 +++--- src/input/player.c | 2 +- src/input/resource.c | 18 ++++++++++++++++++ src/input/resource.h | 2 ++ 5 files changed, 24 insertions(+), 7 deletions(-) diff --git a/src/input/decoder.c b/src/input/decoder.c index 36b5ac8f89..e5bc84d091 100644 --- a/src/input/decoder.c +++ b/src/input/decoder.c @@ -1950,9 +1950,6 @@ static void DeleteDecoder( decoder_t * p_dec ) /* Reset the cancel state that was set before joining the decoder * thread */ vout_Cancel(vout, false); - vout_FlushAll(vout); - vout_FlushSubpictureChannel(vout, -1); - vout_Stop(vout); input_SendEventVout(p_owner->p_input, &(struct vlc_input_event_vout) { .action = VLC_INPUT_EVENT_VOUT_DELETED, diff --git a/src/input/es_out.c b/src/input/es_out.c index c527086bf3..2026fb8c22 100644 --- a/src/input/es_out.c +++ b/src/input/es_out.c @@ -46,6 +46,7 @@ #include "decoder.h" #include "es_out.h" #include "event.h" +#include "resource.h" #include "info.h" #include "item.h" @@ -748,10 +749,9 @@ static void EsOutStopFreeVout( es_out_t *out ) { es_out_sys_t *p_sys = container_of(out, es_out_sys_t, out); - /* Clean up vout after user action (in active mode only). - * FIXME it does not work well with multiple video windows */ + /* Clean up vout after user action (in active mode only). */ if( p_sys->b_active ) - input_resource_TerminateVout( input_priv(p_sys->p_input)->p_resource ); + input_resource_StopFreeVout( input_priv(p_sys->p_input)->p_resource ); } static void EsOutDecodersStopBuffering( es_out_t *out, bool b_forced ) diff --git a/src/input/player.c b/src/input/player.c index f43f9f71a5..328a7def15 100644 --- a/src/input/player.c +++ b/src/input/player.c @@ -885,7 +885,7 @@ vlc_player_destructor_Thread(void *data) const bool started = player->started; vlc_player_Unlock(player); if (!started) - input_resource_TerminateVout(player->resource); + input_resource_StopFreeVout(player->resource); if (!keep_sout) input_resource_TerminateSout(player->resource); vlc_player_Lock(player); diff --git a/src/input/resource.c b/src/input/resource.c index 23ad7426eb..14726aa063 100644 --- a/src/input/resource.c +++ b/src/input/resource.c @@ -58,6 +58,7 @@ struct input_resource_t sout_instance_t *p_sout; vout_thread_t *p_vout_free; + bool b_vout_free_paused; /* This lock is used to protect vout resources access (for hold) * It is a special case because of embed video (possible deadlock @@ -152,6 +153,7 @@ static void DestroyVout( input_resource_t *p_resource ) vout_Close( p_resource->p_vout_free ); p_resource->p_vout_free = NULL; + p_resource->b_vout_free_paused = false; } p_resource->p_vout_free = NULL; @@ -344,8 +346,11 @@ static void input_resource_PutVoutLocked(input_resource_t *p_resource, vlc_mutex_unlock(&p_resource->lock_hold); assert(p_resource->p_vout_free == NULL); + assert(!p_resource->b_vout_free_paused); msg_Dbg(p_resource->p_parent, "saving a free vout"); + vout_Pause(vout); p_resource->p_vout_free = vout; + p_resource->b_vout_free_paused = true; } else { @@ -386,6 +391,7 @@ vout_thread_t *input_resource_GetVout(input_resource_t *p_resource, cfg_buf = *cfg; cfg_buf.vout = p_resource->p_vout_free; p_resource->p_vout_free = NULL; + p_resource->b_vout_free_paused = false; cfg = &cfg_buf; if (cfg_buf.vout == NULL) { @@ -484,6 +490,18 @@ void input_resource_TerminateVout( input_resource_t *p_resource ) vlc_mutex_unlock(&p_resource->lock); } +void input_resource_StopFreeVout(input_resource_t *p_resource) +{ + vlc_mutex_lock(&p_resource->lock); + if (p_resource->p_vout_free != NULL && p_resource->b_vout_free_paused) + { + msg_Dbg(p_resource->p_vout_free, "stop free vout"); + vout_Stop(p_resource->p_vout_free); + p_resource->b_vout_free_paused = false; + } + vlc_mutex_unlock(&p_resource->lock); +} + /* */ sout_instance_t *input_resource_RequestSout( input_resource_t *p_resource, sout_instance_t *p_sout, const char *psz_sout ) { diff --git a/src/input/resource.h b/src/input/resource.h index 123018064c..5d779ca3e1 100644 --- a/src/input/resource.h +++ b/src/input/resource.h @@ -60,6 +60,8 @@ void input_resource_HoldVouts( input_resource_t *, vout_thread_t ***, size_t * ) */ void input_resource_Terminate( input_resource_t * ); +void input_resource_StopFreeVout( input_resource_t * ); + /** * This function holds the input_resource_t itself */ _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
