[vlc-devel] [PATCH 1/5] input: add a new flag to control the state from demuxers
Thomas Guillem
thomas at gllm.fr
Thu Jul 19 15:50:16 CEST 2018
This will be used by the chromecast demux filter.
---
include/vlc_demux.h | 4 ++++
src/input/input.c | 27 +++++++++++++++++++++++++++
2 files changed, 31 insertions(+)
diff --git a/include/vlc_demux.h b/include/vlc_demux.h
index 26328c7268..7a5081adff 100644
--- a/include/vlc_demux.h
+++ b/include/vlc_demux.h
@@ -51,6 +51,10 @@
#define INPUT_UPDATE_META 0x0040
#define INPUT_UPDATE_TITLE_LIST 0x0100
+#define INPUT_UPDATE_PAUSE 0x0200
+#define INPUT_UPDATE_PLAY 0x0400
+#define INPUT_UPDATE_STATE (INPUT_UPDATE_PAUSE|INPUT_UPDATE_PLAY)
+
/* demux_meta_t is returned by "meta reader" module to the demuxer */
typedef struct demux_meta_t
{
diff --git a/src/input/input.c b/src/input/input.c
index fe622bf81f..941e3b4f2d 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -78,6 +78,7 @@ static void ControlPause( input_thread_t *, vlc_tick_t );
static int UpdateTitleSeekpointFromDemux( input_thread_t * );
static void UpdateGenericFromDemux( input_thread_t * );
static void UpdateTitleListfromDemux( input_thread_t * );
+static void UpdateStateFromDemux( input_thread_t *, bool * );
static void MRLSections( const char *, int *, int *, int *, int *);
@@ -710,6 +711,7 @@ static void MainLoop( input_thread_t *p_input, bool b_interactive )
bool b_pause_after_eof = b_interactive &&
var_InheritBool( p_input, "play-and-pause" );
bool b_paused_at_eof = false;
+ bool b_paused_from_demux = false;
demux_t *p_demux = input_priv(p_input)->master->p_demux;
const bool b_can_demux = p_demux->pf_demux != NULL;
@@ -776,6 +778,8 @@ static void MainLoop( input_thread_t *p_input, bool b_interactive )
}
}
+ UpdateStateFromDemux( p_input, &b_paused_from_demux );
+
/* Handle control */
for( ;; )
{
@@ -797,6 +801,12 @@ static void MainLoop( input_thread_t *p_input, bool b_interactive )
b_postpone = false;
}
+ /* If the input is paused from the demux, we need to query the new
+ * state regularly from the demux and not wait indefinitely from
+ * ControlPop. */
+ if( i_deadline == -1 && b_paused_from_demux )
+ i_deadline = vlc_tick_now() + VLC_TICK_FROM_MS(100);
+
int i_type;
input_control_param_t param;
@@ -2392,6 +2402,23 @@ static void UpdateTitleListfromDemux( input_thread_t *p_input )
InitTitle( p_input );
}
+static void UpdateStateFromDemux( input_thread_t *p_input, bool *p_paused )
+{
+ demux_t *p_demux = input_priv(p_input)->master->p_demux;
+ unsigned state = demux_TestAndClearFlags( p_demux, INPUT_UPDATE_STATE );
+ if( state & INPUT_UPDATE_STATE )
+ {
+ if( state == INPUT_UPDATE_STATE )
+ return; /* Play and Pause, so do nothing */
+
+ vlc_value_t val = {
+ .i_int = ( state & INPUT_UPDATE_PAUSE ) ? PAUSE_S : PLAYING_S
+ };
+ input_ControlPushHelper( p_input, INPUT_CONTROL_SET_STATE, &val );
+ *p_paused = ( state & INPUT_UPDATE_PAUSE );
+ }
+}
+
static int
InputStreamHandleAnchor( input_source_t *source, stream_t **stream,
char const *anchor )
--
2.18.0
More information about the vlc-devel
mailing list