[vlc-commits] [Git][videolan/vlc][master] 2 commits: input: move Control log
Steve Lhomme (@robUx4)
gitlab at videolan.org
Wed Feb 14 18:02:54 UTC 2024
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
92067e60 by Thomas Guillem at 2024-02-14T17:32:38+00:00
input: move Control log
- - - - -
eda2e960 by Thomas Guillem at 2024-02-14T17:32:38+00:00
input: process all controls asynchronously
Related to #28524
This will avoid the event callback being called from an input_ function.
- - - - -
1 changed file:
- src/input/input.c
Changes:
=====================================
src/input/input.c
=====================================
@@ -70,6 +70,8 @@ static void End ( input_thread_t *p_input );
static void MainLoop( input_thread_t *p_input, bool b_interactive );
static inline int ControlPop( input_thread_t *, int *, input_control_param_t *, vlc_tick_t i_deadline, bool b_postpone_seek );
+static int ControlPopEarly(input_thread_t *input, int *type,
+ input_control_param_t *param);
static void ControlRelease( int i_type, const input_control_param_t *p_param );
static bool ControlIsSeekRequest( int i_type );
static bool Control( input_thread_t *, int, input_control_param_t );
@@ -739,9 +741,6 @@ static void MainLoop( input_thread_t *p_input, bool b_interactive )
break; /* Wake-up time reached */
}
-#ifndef NDEBUG
- msg_Dbg( p_input, "control type=%d", i_type );
-#endif
if( Control( p_input, i_type, param ) )
{
if( ControlIsSeekRequest( i_type ) )
@@ -1310,6 +1309,16 @@ static int Init( input_thread_t * p_input )
if( priv->p_es_out == NULL )
goto error;
+ /* Handle all early controls */
+ for (;;)
+ {
+ int type;
+ input_control_param_t param;
+ if (ControlPopEarly(p_input, &type, ¶m))
+ break;
+ Control(p_input, type, param);
+ }
+
/* */
master = priv->master;
if( master == NULL )
@@ -1611,6 +1620,50 @@ static bool ControlIsSeekRequest( int i_type )
}
}
+static bool ControlTypeIsEarly(int type)
+{
+ /* These controls can and should be processed before the access/demux
+ * is created for optimization purpose. */
+ switch (type)
+ {
+ /* \warning Make sure the control implementation is not referencing the
+ * demux before adding it here. */
+ case INPUT_CONTROL_SET_PROGRAM:
+ case INPUT_CONTROL_SET_CATEGORY_DELAY:
+ case INPUT_CONTROL_SET_ES_CAT_IDS:
+ return true;
+ default:
+ return false;
+ }
+}
+
+static int ControlPopEarly(input_thread_t *input, int *type,
+ input_control_param_t *param)
+{
+ input_thread_private_t *sys = input_priv(input);
+
+ vlc_mutex_lock(&sys->lock_control);
+
+ for (size_t i = 0; i < sys->i_control; ++i)
+ {
+ if (ControlTypeIsEarly(sys->control[i].i_type))
+ {
+ *type = sys->control[i].i_type;
+ *param = sys->control[i].param;
+
+ sys->i_control--;
+ if (sys->i_control > i)
+ memmove(&sys->control[i], &sys->control[i+1],
+ sizeof(*sys->control) * sys->i_control - i);
+ vlc_mutex_unlock(&sys->lock_control);
+ return VLC_SUCCESS;
+ }
+ }
+
+ vlc_mutex_unlock(&sys->lock_control);
+ return VLC_EGENERIC;
+}
+
static void ControlRelease( int i_type, const input_control_param_t *p_param )
{
if( p_param == NULL )
@@ -1780,64 +1833,27 @@ static void ControlInsertDemuxFilter( input_thread_t* p_input, const char* psz_d
void input_SetProgramId(input_thread_t *input, int group_id)
{
- input_thread_private_t *sys = input_priv(input);
-
- if (!sys->is_running && !sys->is_stopped)
- {
- /* Not running, send the control synchronously since we are sure that
- * it won't block */
- es_out_Control(sys->p_es_out_display, ES_OUT_SET_GROUP, group_id);
- }
- else
- {
- input_ControlPushHelper(input, INPUT_CONTROL_SET_PROGRAM,
- &(vlc_value_t) { .i_int = group_id });
- }
+ input_ControlPushHelper(input, INPUT_CONTROL_SET_PROGRAM,
+ &(vlc_value_t) { .i_int = group_id });
}
int input_SetEsCatDelay(input_thread_t *input, enum es_format_category_e cat,
vlc_tick_t delay)
{
- input_thread_private_t *sys = input_priv(input);
- /* A failure can only happen in the input_ControlPush section. */
- int ret = VLC_SUCCESS;
-
- if (!sys->is_running && !sys->is_stopped)
- {
- /* Not running, send the control synchronously since we are sure that
- * it won't block */
- es_out_SetDelay(sys->p_es_out_display, cat, delay);
- }
- else
- {
- const input_control_param_t param = {
- .cat_delay = { cat, delay }
- };
- ret = input_ControlPush(input, INPUT_CONTROL_SET_CATEGORY_DELAY,
- ¶m);
- }
-
- return ret;
+ const input_control_param_t param = {
+ .cat_delay = { cat, delay }
+ };
+ return input_ControlPush(input, INPUT_CONTROL_SET_CATEGORY_DELAY,
+ ¶m);
}
void input_SetEsCatIds(input_thread_t *input, enum es_format_category_e cat,
const char *str_ids)
{
- input_thread_private_t *sys = input_priv(input);
-
- if (!sys->is_running && !sys->is_stopped)
- {
- /* Not running, send the control synchronously since we are sure that
- * it won't block */
- es_out_SetEsCatIds(sys->p_es_out_display, cat, str_ids);
- }
- else
- {
- const input_control_param_t param = {
- .cat_ids = { cat, str_ids ? strdup(str_ids) : NULL }
- };
- input_ControlPush(input, INPUT_CONTROL_SET_ES_CAT_IDS, ¶m);
- }
+ const input_control_param_t param = {
+ .cat_ids = { cat, str_ids ? strdup(str_ids) : NULL }
+ };
+ input_ControlPush(input, INPUT_CONTROL_SET_ES_CAT_IDS, ¶m);
}
static void ControlSetEsList(input_thread_t *input,
@@ -1902,6 +1918,10 @@ static bool Control( input_thread_t *p_input,
/* FIXME b_force_update is abused, it should be carefully checked */
bool b_force_update = false;
+#ifndef NDEBUG
+ msg_Dbg( p_input, "control type=%d", i_type );
+#endif
+
switch( i_type )
{
case INPUT_CONTROL_SET_POSITION:
@@ -2072,6 +2092,10 @@ static bool Control( input_thread_t *p_input,
es_out_Control( priv->p_es_out,
ES_OUT_SET_GROUP, (int)param.val.i_int );
+ if( priv->master->p_demux == NULL )
+ break; /* Possible when called early, the group will be set on
+ * the demux from InitPrograms() */
+
if( param.val.i_int == 0 )
demux_Control( priv->master->p_demux,
DEMUX_SET_GROUP_DEFAULT );
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/bf913aaf9c525c45b55a10674d7739f7b4a253d9...eda2e960f898eb6611b05963683f0cf24130121b
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/bf913aaf9c525c45b55a10674d7739f7b4a253d9...eda2e960f898eb6611b05963683f0cf24130121b
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list