[vlc-commits] chromecast: avoid too many sout/cc restart when flushing
Thomas Guillem
git at videolan.org
Mon Feb 26 17:08:01 CET 2018
vlc/vlc-3.0 | branch: master | Thomas Guillem <thomas at gllm.fr> | Mon Feb 26 17:02:48 2018 +0100| [b505a863a9759d7c7d182b43b3c5d140bdec8263] | committer: Thomas Guillem
chromecast: avoid too many sout/cc restart when flushing
Wait for all streams being flushed before sending new data.
(cherry picked from commit 81016339c1002120f184661f5d90bc57b28486dc)
Signed-off-by: Thomas Guillem <thomas at gllm.fr>
> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=b505a863a9759d7c7d182b43b3c5d140bdec8263
---
modules/stream_out/chromecast/cast.cpp | 55 ++++++++++++++++++++++++++++++----
1 file changed, 49 insertions(+), 6 deletions(-)
diff --git a/modules/stream_out/chromecast/cast.cpp b/modules/stream_out/chromecast/cast.cpp
index 18c6f14d58..f9a3663925 100644
--- a/modules/stream_out/chromecast/cast.cpp
+++ b/modules/stream_out/chromecast/cast.cpp
@@ -90,6 +90,7 @@ struct sout_stream_sys_t
, es_changed( true )
, cc_has_input( false )
, cc_reload( false )
+ , cc_flushing( false )
, has_video( false )
, out_force_reload( false )
, perf_warning_shown( false )
@@ -113,6 +114,7 @@ struct sout_stream_sys_t
const std::string &sout, int new_transcoding_state);
void stopSoutChain(sout_stream_t* p_stream);
sout_stream_id_sys_t *GetSubId( sout_stream_t*, sout_stream_id_sys_t*, bool update = true );
+ bool isFlushing( sout_stream_t* );
void setNextTranscodingState();
bool transcodingCanFallback() const;
@@ -134,6 +136,7 @@ struct sout_stream_sys_t
bool es_changed;
bool cc_has_input;
bool cc_reload;
+ bool cc_flushing;
bool has_video;
bool out_force_reload;
bool perf_warning_shown;
@@ -150,6 +153,7 @@ struct sout_stream_id_sys_t
{
es_format_t fmt;
sout_stream_id_sys_t *p_sub_id;
+ bool flushed;
};
#define SOUT_CFG_PREFIX "sout-chromecast-"
@@ -699,6 +703,7 @@ static sout_stream_id_sys_t *Add(sout_stream_t *p_stream, const es_format_t *p_f
{
es_format_Copy( &p_sys_id->fmt, p_fmt );
p_sys_id->p_sub_id = NULL;
+ p_sys_id->flushed = false;
p_sys->streams.push_back( p_sys_id );
p_sys->es_changed = true;
@@ -1149,12 +1154,42 @@ sout_stream_id_sys_t *sout_stream_sys_t::GetSubId( sout_stream_t *p_stream,
return NULL;
}
+bool sout_stream_sys_t::isFlushing( sout_stream_t *p_stream )
+{
+ (void) p_stream;
+
+ /* Make sure that all out_streams are flushed when flushing. This avoids
+ * too many sout/cc restart when a stream is sending data while one other
+ * is flushing */
+
+ if (!cc_flushing)
+ return false;
+
+ for (size_t i = 0; i < out_streams.size(); ++i)
+ {
+ if ( !out_streams[i]->flushed )
+ return true;
+ }
+
+ cc_flushing = false;
+ for (size_t i = 0; i < out_streams.size(); ++i)
+ out_streams[i]->flushed = false;
+
+ return false;
+}
+
static int Send(sout_stream_t *p_stream, sout_stream_id_sys_t *id,
block_t *p_buffer)
{
sout_stream_sys_t *p_sys = p_stream->p_sys;
vlc_mutex_locker locker(&p_sys->lock);
+ if( p_sys->isFlushing( p_stream ) )
+ {
+ block_Release( p_buffer );
+ return VLC_SUCCESS;
+ }
+
sout_stream_id_sys_t *next_id = p_sys->GetSubId( p_stream, id );
if ( next_id == NULL )
{
@@ -1177,15 +1212,23 @@ static void Flush( sout_stream_t *p_stream, sout_stream_id_sys_t *id )
sout_stream_id_sys_t *next_id = p_sys->GetSubId( p_stream, id, false );
if ( next_id == NULL )
return;
+ next_id->flushed = true;
- p_sys->access_out_live.stop();
-
- if (p_sys->cc_has_input)
+ if( !p_sys->cc_flushing )
{
- p_sys->p_intf->requestPlayerStop();
- p_sys->cc_has_input = false;
+ p_sys->cc_flushing = true;
+
+ p_sys->stopSoutChain( p_stream );
+
+ p_sys->access_out_live.stop();
+
+ if (p_sys->cc_has_input)
+ {
+ p_sys->p_intf->requestPlayerStop();
+ p_sys->cc_has_input = false;
+ }
+ p_sys->out_force_reload = p_sys->es_changed = true;
}
- p_sys->out_force_reload = p_sys->es_changed = true;
}
static void on_input_event_cb(void *data, enum cc_input_event event, union cc_input_arg arg )
More information about the vlc-commits
mailing list