[vlc-devel] [PATCH 1/3] [RFC] input: add input_RequestUpdateOutput() to notify the output config changed
Steve Lhomme
robux4 at videolabs.io
Tue Apr 26 15:10:55 CEST 2016
This allows changing the display/rendering and continue more or less at the
same point, transparently using ES_OUT_RESTART_ES on all es_out.
---
include/vlc_input.h | 7 +++++++
src/input/input.c | 37 +++++++++++++++++++++++++++++++++++++
src/input/input_internal.h | 1 +
src/libvlccore.sym | 1 +
4 files changed, 46 insertions(+)
diff --git a/include/vlc_input.h b/include/vlc_input.h
index 0bda6d4..202edd3 100644
--- a/include/vlc_input.h
+++ b/include/vlc_input.h
@@ -557,6 +557,13 @@ static inline input_state_e input_GetState( input_thread_t * p_input )
}
/**
+ * Update the output chain while playback is running
+ *
+ * For example when switching from "sout" to "vout+aout"
+ */
+VLC_API void input_RequestUpdateOutput( input_thread_t * );
+
+/**
* Return one of the video output (if any). If possible, you should use
* INPUT_GET_VOUTS directly and process _all_ video outputs instead.
* @param p_input an input thread from which to get a video output
diff --git a/src/input/input.c b/src/input/input.c
index 8e510ca..cf4f0d9 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -81,6 +81,9 @@ static input_source_t *InputSourceNew( input_thread_t *, const char *,
bool b_in_can_fail );
static void InputSourceDestroy( input_source_t * );
static void InputSourceMeta( input_thread_t *, input_source_t *, vlc_meta_t * );
+#ifdef ENABLE_SOUT
+static int InitSout( input_thread_t * p_input );
+#endif
/* TODO */
//static void InputGetAttachments( input_thread_t *, input_source_t * );
@@ -266,6 +269,11 @@ input_item_t *input_GetItem( input_thread_t *p_input )
return p_input->p->p_item;
}
+void input_RequestUpdateOutput( input_thread_t * p_input )
+{
+ atomic_store( &p_input->p->b_restart_output, true );
+}
+
/*****************************************************************************
* This function creates a new input, and returns a pointer
* to its description. On error, it returns NULL.
@@ -400,6 +408,7 @@ static input_thread_t *Create( vlc_object_t *p_parent, input_item_t *p_item,
/* Create Objects variables for public Get and Set */
input_ControlVarInit( p_input );
+ atomic_init( &p_input->p->b_restart_output, false );
/* */
if( !p_input->b_preparsing )
@@ -681,6 +690,34 @@ static void MainLoop( input_thread_t *p_input, bool b_interactive )
{
mtime_t i_wakeup = -1;
bool b_paused = p_input->p->i_state == PAUSE_S;
+
+ if ( atomic_exchange( &p_input->p->b_restart_output, false ) )
+ {
+ double f_restart_position;
+ input_Control( p_input, INPUT_GET_POSITION, &f_restart_position );
+
+#ifdef ENABLE_SOUT
+ if( InitSout( p_input ) )
+ break; /* TODO */
+#endif
+
+ es_out_Control( p_input->p->p_es_out, ES_OUT_RESTART_ES, NULL );
+
+ if ( p_input->p->p_sout == NULL )
+ input_resource_TerminateSout( p_input->p->p_resource );
+
+ if( !p_input->b_preparsing && p_input->p->p_sout )
+ {
+ p_input->p->b_out_pace_control = (p_input->p->p_sout->i_out_pace_nocontrol > 0);
+
+ msg_Dbg( p_input, "starting in %s mode",
+ p_input->p->b_out_pace_control ? "async" : "sync" );
+ }
+
+ if ( f_restart_position != -1.0 )
+ input_Control( p_input, INPUT_SET_POSITION, f_restart_position);
+ }
+
/* FIXME if p_input->p->i_state == PAUSE_S the access/access_demux
* is paused -> this may cause problem with some of them
* The same problem can be seen when seeking while paused */
diff --git a/src/input/input_internal.h b/src/input/input_internal.h
index b68bec7..3a96619 100644
--- a/src/input/input_internal.h
+++ b/src/input/input_internal.h
@@ -92,6 +92,7 @@ struct input_thread_private_t
bool is_stopped;
bool b_recording;
int i_rate;
+ atomic_bool b_restart_output;
/* Playtime configuration and state */
int64_t i_start; /* :start-time,0 by default */
diff --git a/src/libvlccore.sym b/src/libvlccore.sym
index 32dbaad..4a0ab48 100644
--- a/src/libvlccore.sym
+++ b/src/libvlccore.sym
@@ -171,6 +171,7 @@ input_DecoderDecode
input_DecoderDrain
input_DecoderFlush
input_GetItem
+input_RequestUpdateOutput
input_item_AddInfo
input_item_AddOption
input_item_AddOptions
--
2.7.0
More information about the vlc-devel
mailing list