Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
b2e4fe99 by Thomas Guillem at 2024-01-13T07:09:06+00:00
player: move seek functions to player/input.c
No functional changes.
- - - - -
cf93b5ce by Thomas Guillem at 2024-01-13T07:09:06+00:00
player: move viewpoint function to player/input.c
No functional changes.
- - - - -
80a9b2d3 by Thomas Guillem at 2024-01-13T07:09:06+00:00
player: handle navigation fallback in the player
- - - - -
c49bcbcd by Thomas Guillem at 2024-01-13T07:09:06+00:00
player: handle VLC_TICK_INVALID in vlc_player_GetTimerPoint()
Add add a way to not interpolate the last point when using VLC_TICK_INVALID.
- - - - -
867c6405 by Thomas Guillem at 2024-01-13T07:09:06+00:00
player: specify the interpolated date when getting pos/time
This allows to ask for an interpolated point or not, and this allows to
use the same time reference when getting position and time.
- - - - -
00d319d6 by Thomas Guillem at 2024-01-13T07:09:06+00:00
player: remove unused declaration
- - - - -
76e5e6a8 by Thomas Guillem at 2024-01-13T07:09:06+00:00
player: send a discontinuity to the timer after a seek
For the input source (NULL), this is needed in the unlikely case where
there are no ESes active.
- - - - -
66204d92 by Thomas Guillem at 2024-01-13T07:09:06+00:00
player: timer: use double for input_position
The rest of the code already use double precision.
- - - - -
7 changed files:
- src/input/input.c
- src/input/input_internal.h
- src/player/input.c
- src/player/osd.c
- src/player/player.c
- src/player/player.h
- src/player/timer.c
Changes:
=====================================
src/input/input.c
=====================================
@@ -1755,80 +1755,10 @@ static void ControlNav( input_thread_t *p_input, int
i_type )
- INPUT_CONTROL_NAV_ACTIVATE + DEMUX_NAV_ACTIVATE ) )
return; /* The demux handled the navigation control */
- /* Handle Up/Down/Left/Right if the demux can't navigate */
- vlc_viewpoint_t vp = {0};
- int vol_direction = 0;
- int seek_direction = 0;
- switch( i_type )
- {
- case INPUT_CONTROL_NAV_UP:
- vol_direction = 1;
- vp.pitch = -1.f;
- break;
- case INPUT_CONTROL_NAV_DOWN:
- vol_direction = -1;
- vp.pitch = 1.f;
- break;
- case INPUT_CONTROL_NAV_LEFT:
- seek_direction = -1;
- vp.yaw = -1.f;
- break;
- case INPUT_CONTROL_NAV_RIGHT:
- seek_direction = 1;
- vp.yaw = 1.f;
- break;
- case INPUT_CONTROL_NAV_ACTIVATE:
- case INPUT_CONTROL_NAV_POPUP:
- case INPUT_CONTROL_NAV_MENU:
- return;
- default:
- vlc_assert_unreachable();
- }
-
- /* Try to change the viewpoint if possible */
- vout_thread_t **pp_vout;
- size_t i_vout;
- bool b_viewpoint_ch = false;
- input_resource_HoldVouts( priv->p_resource, &pp_vout, &i_vout );
- for( size_t i = 0; i < i_vout; ++i )
- {
- if( !b_viewpoint_ch
- && var_GetBool( pp_vout[i], "viewpoint-changeable" ) )
- b_viewpoint_ch = true;
- vout_Release(pp_vout[i]);
- }
- free( pp_vout );
-
- if( b_viewpoint_ch )
- {
- priv->viewpoint_changed = true;
- priv->viewpoint.yaw += vp.yaw;
- priv->viewpoint.pitch += vp.pitch;
- priv->viewpoint.roll += vp.roll;
- priv->viewpoint.fov += vp.fov;
- ViewpointApply( p_input );
- return;
- }
-
- /* Seek or change volume if the input doesn't have navigation or viewpoint
*/
- if( seek_direction != 0 )
- {
- vlc_tick_t it = vlc_tick_from_sec( seek_direction *
var_InheritInteger( p_input, "short-jump-size" ) );
- Control( p_input, INPUT_CONTROL_JUMP_TIME, (input_control_param_t) {
- .time.b_fast_seek = false,
- .time.i_val = it
- });
- }
- else
- {
- assert( vol_direction != 0 );
- audio_output_t *p_aout = input_resource_HoldAout( priv->p_resource );
- if( p_aout )
- {
- aout_VolumeUpdate( p_aout, vol_direction, NULL );
- aout_Release(p_aout);
- }
- }
+ input_SendEvent(p_input, &(struct vlc_input_event) {
+ .type = INPUT_EVENT_NAV_FAILED,
+ .nav_type = i_type,
+ });
}
static void ControlUpdateRenderer( input_thread_t *p_input, bool b_enable )
=====================================
src/input/input_internal.h
=====================================
@@ -145,6 +145,9 @@ typedef enum input_event_type_e
/* Attachments */
INPUT_EVENT_ATTACHMENTS,
+
+ /* The demux is not able to navigate */
+ INPUT_EVENT_NAV_FAILED,
} input_event_type_e;
#define VLC_INPUT_CAPABILITIES_SEEKABLE (1<<0)
@@ -310,6 +313,8 @@ struct vlc_input_event
picture_t *thumbnail;
/* INPUT_EVENT_ATTACHMENTS */
struct vlc_input_event_attachments attachments;
+ /* INPUT_EVENT_NAV_FAILED */
+ int nav_type;
};
};
=====================================
src/player/input.c
=====================================
@@ -59,25 +59,25 @@ vlc_player_input_HandleAtoBLoop(struct vlc_player_input
*input, vlc_tick_t time,
}
vlc_tick_t
-vlc_player_input_GetTime(struct vlc_player_input *input)
+vlc_player_input_GetTime(struct vlc_player_input *input, vlc_tick_t system_now)
{
vlc_player_t *player = input->player;
vlc_tick_t ts;
if (input == player->input
- && vlc_player_GetTimerPoint(player, vlc_tick_now(), &ts, NULL) == 0)
+ && vlc_player_GetTimerPoint(player, system_now, &ts, NULL) == 0)
return ts;
return input->time;
}
double
-vlc_player_input_GetPos(struct vlc_player_input *input)
+vlc_player_input_GetPos(struct vlc_player_input *input, vlc_tick_t system_now)
{
vlc_player_t *player = input->player;
double pos;
if (input == player->input
- && vlc_player_GetTimerPoint(player, vlc_tick_now(), NULL, &pos) == 0)
+ && vlc_player_GetTimerPoint(player, system_now, NULL, &pos) == 0)
return pos;
return input->position;
}
@@ -86,8 +86,12 @@ static void
vlc_player_input_UpdateTime(struct vlc_player_input *input)
{
if (input->abloop_state[0].set && input->abloop_state[1].set)
- vlc_player_input_HandleAtoBLoop(input, vlc_player_input_GetTime(input),
- vlc_player_input_GetPos(input));
+ {
+ vlc_tick_t now = vlc_tick_now();
+ vlc_player_input_HandleAtoBLoop(input,
+ vlc_player_input_GetTime(input, now),
+ vlc_player_input_GetPos(input, now));
+ }
}
int
@@ -100,6 +104,74 @@ vlc_player_input_Start(struct vlc_player_input *input)
return ret;
}
+static inline void
+vlc_player_assert_seek_params(enum vlc_player_seek_speed speed,
+ enum vlc_player_whence whence)
+{
+ assert(speed == VLC_PLAYER_SEEK_PRECISE
+ || speed == VLC_PLAYER_SEEK_FAST);
+ assert(whence == VLC_PLAYER_WHENCE_ABSOLUTE
+ || whence == VLC_PLAYER_WHENCE_RELATIVE);
+ (void) speed; (void) whence;
+}
+
+void
+vlc_player_input_SeekByPos(struct vlc_player_input *input, double position,
+ enum vlc_player_seek_speed speed,
+ enum vlc_player_whence whence)
+{
+ vlc_player_t *player = input->player;
+ vlc_player_assert_seek_params(speed, whence);
+
+ const int type =
+ whence == VLC_PLAYER_WHENCE_ABSOLUTE ? INPUT_CONTROL_SET_POSITION
+ : INPUT_CONTROL_JUMP_POSITION;
+ int ret = input_ControlPush(input->thread, type,
+ &(input_control_param_t) {
+ .pos.f_val = position,
+ .pos.b_fast_seek = speed == VLC_PLAYER_SEEK_FAST,
+ });
+
+ if (ret == VLC_SUCCESS)
+ vlc_player_osd_Position(player, input, VLC_TICK_INVALID, position,
+ whence);
+}
+
+void
+vlc_player_input_SeekByTime(struct vlc_player_input *input, vlc_tick_t time,
+ enum vlc_player_seek_speed speed,
+ enum vlc_player_whence whence)
+{
+ vlc_player_t *player = input->player;
+ vlc_player_assert_seek_params(speed, whence);
+
+ const int type =
+ whence == VLC_PLAYER_WHENCE_ABSOLUTE ? INPUT_CONTROL_SET_TIME
+ : INPUT_CONTROL_JUMP_TIME;
+ int ret = input_ControlPush(input->thread, type,
+ &(input_control_param_t) {
+ .time.i_val = time,
+ .time.b_fast_seek = speed == VLC_PLAYER_SEEK_FAST,
+ });
+
+ if (ret == VLC_SUCCESS)
+ vlc_player_osd_Position(player, input, time, -1, whence);
+}
+
+void
+vlc_player_input_UpdateViewpoint(struct vlc_player_input *input,
+ const vlc_viewpoint_t *viewpoint,
+ enum vlc_player_whence whence)
+{
+ input_control_param_t param = { .viewpoint = *viewpoint };
+ if (whence == VLC_PLAYER_WHENCE_ABSOLUTE)
+ input_ControlPush(input->thread, INPUT_CONTROL_SET_VIEWPOINT,
+ ¶m);
+ else
+ input_ControlPush(input->thread, INPUT_CONTROL_UPDATE_VIEWPOINT,
+ ¶m);
+}
+
static bool
vlc_player_WaitRetryDelay(vlc_player_t *player)
{
@@ -723,6 +795,71 @@ vlc_player_input_HandleVoutEvent(struct vlc_player_input
*input,
}
}
+static void
+vlc_player_input_NavigationFallback(struct vlc_player_input *input, int
nav_type)
+{
+ vlc_player_t *player = input->player;
+
+ /* Handle Up/Down/Left/Right if the demux can't navigate */
+ vlc_viewpoint_t vp = { 0 };
+ int vol_direction = 0;
+ int seek_direction = 0;
+ switch (nav_type)
+ {
+ case INPUT_CONTROL_NAV_UP:
+ vol_direction = 1;
+ vp.pitch = -1.f;
+ break;
+ case INPUT_CONTROL_NAV_DOWN:
+ vol_direction = -1;
+ vp.pitch = 1.f;
+ break;
+ case INPUT_CONTROL_NAV_LEFT:
+ seek_direction = -1;
+ vp.yaw = -1.f;
+ break;
+ case INPUT_CONTROL_NAV_RIGHT:
+ seek_direction = 1;
+ vp.yaw = 1.f;
+ break;
+ case INPUT_CONTROL_NAV_ACTIVATE:
+ case INPUT_CONTROL_NAV_POPUP:
+ case INPUT_CONTROL_NAV_MENU:
+ return;
+ default:
+ vlc_assert_unreachable();
+ }
+
+ /* Try to change the viewpoint if possible */
+ bool viewpoint_ch = false;
+ size_t vout_count;
+ vout_thread_t **vouts = vlc_player_vout_HoldAll(input->player,
&vout_count);
+ for (size_t i = 0; i < vout_count; ++i)
+ {
+ if (!viewpoint_ch && var_GetBool(vouts[i], "viewpoint-changeable"))
+ viewpoint_ch = true;
+ vout_Release(vouts[i]);
+ }
+ free(vouts);
+
+ if (viewpoint_ch)
+ vlc_player_input_UpdateViewpoint(input, &vp,
VLC_PLAYER_WHENCE_RELATIVE);
+ else if (seek_direction != 0)
+ {
+ /* Seek or change volume if the input doesn't have navigation or
viewpoint */
+ vlc_tick_t it = vlc_tick_from_sec(seek_direction
+ * var_InheritInteger(player, "short-jump-size"));
+ vlc_player_input_SeekByTime(input, it, VLC_PLAYER_SEEK_PRECISE,
+ VLC_PLAYER_WHENCE_RELATIVE);
+ }
+ else
+ {
+ assert(vol_direction != 0);
+ if (input == player->input)
+ vlc_player_aout_IncrementVolume(player, vol_direction, NULL);
+ }
+}
+
static void
input_thread_Events(input_thread_t *input_thread,
const struct vlc_input_event *event, void *user_data)
@@ -853,6 +990,10 @@ input_thread_Events(input_thread_t *input_thread,
input->signal_quality,
input->signal_strength);
break;
case INPUT_EVENT_CACHE:
+ if (event->cache == 0.0f)
+ vlc_player_UpdateTimerState(player, NULL,
+
VLC_PLAYER_TIMER_STATE_DISCONTINUITY,
+ VLC_TICK_INVALID);
input->cache = event->cache;
vlc_player_SendEvent(player, on_buffering_changed, event->cache);
break;
@@ -894,6 +1035,9 @@ input_thread_Events(input_thread_t *input_thread,
event->attachments.array,
event->attachments.count);
break;
+ case INPUT_EVENT_NAV_FAILED:
+ vlc_player_input_NavigationFallback(input, event->nav_type);
+ break;
default:
break;
}
=====================================
src/player/osd.c
=====================================
@@ -121,6 +121,8 @@ vlc_player_osd_Position(vlc_player_t *player,
struct vlc_player_input *input, vlc_tick_t time,
double position, enum vlc_player_whence whence)
{
+ vlc_tick_t now = vlc_tick_now();
+
if (input->length != VLC_TICK_INVALID)
{
if (time == VLC_TICK_INVALID)
@@ -136,7 +138,7 @@ vlc_player_osd_Position(vlc_player_t *player,
{
if (whence == VLC_PLAYER_WHENCE_RELATIVE)
{
- time += vlc_player_input_GetTime(input); /* XXX: TOCTOU */
+ time += vlc_player_input_GetTime(input, now);
if (time < 0)
time = 0;
}
@@ -157,7 +159,7 @@ vlc_player_osd_Position(vlc_player_t *player,
{
if (whence == VLC_PLAYER_WHENCE_RELATIVE)
{
- position += vlc_player_input_GetPos(input); /* XXX: TOCTOU */
+ position += vlc_player_input_GetPos(input, now);
if (position < 0.f)
position = 0.f;
}
=====================================
src/player/player.c
=====================================
@@ -1378,7 +1378,7 @@ vlc_player_GetTime(vlc_player_t *player)
if (!input)
return VLC_TICK_INVALID;
- return vlc_player_input_GetTime(input);
+ return vlc_player_input_GetTime(input, vlc_tick_now());
}
double
@@ -1386,18 +1386,7 @@ vlc_player_GetPosition(vlc_player_t *player)
{
struct vlc_player_input *input = vlc_player_get_input_locked(player);
- return input ? vlc_player_input_GetPos(input) : -1.f;
-}
-
-static inline void
-vlc_player_assert_seek_params(enum vlc_player_seek_speed speed,
- enum vlc_player_whence whence)
-{
- assert(speed == VLC_PLAYER_SEEK_PRECISE
- || speed == VLC_PLAYER_SEEK_FAST);
- assert(whence == VLC_PLAYER_WHENCE_ABSOLUTE
- || whence == VLC_PLAYER_WHENCE_RELATIVE);
- (void) speed; (void) whence;
+ return input ? vlc_player_input_GetPos(input, vlc_tick_now()) : -1.f;
}
void
@@ -1406,9 +1395,11 @@ vlc_player_DisplayPosition(vlc_player_t *player)
struct vlc_player_input *input = vlc_player_get_input_locked(player);
if (!input)
return;
+
+ vlc_tick_t now = vlc_tick_now();
vlc_player_osd_Position(player, input,
- vlc_player_input_GetTime(input),
- vlc_player_input_GetPos(input),
+ vlc_player_input_GetTime(input, now),
+ vlc_player_input_GetPos(input, now),
VLC_PLAYER_WHENCE_ABSOLUTE);
}
@@ -1417,24 +1408,9 @@ vlc_player_SeekByPos(vlc_player_t *player, double
position,
enum vlc_player_seek_speed speed,
enum vlc_player_whence whence)
{
- vlc_player_assert_seek_params(speed, whence);
-
struct vlc_player_input *input = vlc_player_get_input_locked(player);
- if (!input)
- return;
-
- const int type =
- whence == VLC_PLAYER_WHENCE_ABSOLUTE ? INPUT_CONTROL_SET_POSITION
- : INPUT_CONTROL_JUMP_POSITION;
- int ret = input_ControlPush(input->thread, type,
- &(input_control_param_t) {
- .pos.f_val = position,
- .pos.b_fast_seek = speed == VLC_PLAYER_SEEK_FAST,
- });
-
- if (ret == VLC_SUCCESS)
- vlc_player_osd_Position(player, input, VLC_TICK_INVALID, position,
- whence);
+ if (input != NULL)
+ vlc_player_input_SeekByPos(input, position, speed, whence);
}
void
@@ -1442,23 +1418,9 @@ vlc_player_SeekByTime(vlc_player_t *player, vlc_tick_t
time,
enum vlc_player_seek_speed speed,
enum vlc_player_whence whence)
{
- vlc_player_assert_seek_params(speed, whence);
-
struct vlc_player_input *input = vlc_player_get_input_locked(player);
- if (!input)
- return;
-
- const int type =
- whence == VLC_PLAYER_WHENCE_ABSOLUTE ? INPUT_CONTROL_SET_TIME
- : INPUT_CONTROL_JUMP_TIME;
- int ret = input_ControlPush(input->thread, type,
- &(input_control_param_t) {
- .time.i_val = time,
- .time.b_fast_seek = speed == VLC_PLAYER_SEEK_FAST,
- });
-
- if (ret == VLC_SUCCESS)
- vlc_player_osd_Position(player, input, time, -1, whence);
+ if (input != NULL)
+ vlc_player_input_SeekByTime(input, time, speed, whence);
}
void
@@ -1612,16 +1574,8 @@ vlc_player_UpdateViewpoint(vlc_player_t *player,
enum vlc_player_whence whence)
{
struct vlc_player_input *input = vlc_player_get_input_locked(player);
- if (input)
- {
- input_control_param_t param = { .viewpoint = *viewpoint };
- if (whence == VLC_PLAYER_WHENCE_ABSOLUTE)
- input_ControlPush(input->thread, INPUT_CONTROL_SET_VIEWPOINT,
- ¶m);
- else
- input_ControlPush(input->thread, INPUT_CONTROL_UPDATE_VIEWPOINT,
- ¶m);
- }
+ if (input != NULL)
+ vlc_player_input_UpdateViewpoint(input, viewpoint, whence);
}
bool
=====================================
src/player/player.h
=====================================
@@ -220,7 +220,7 @@ struct vlc_player_timer
vlc_tick_t input_length;
vlc_tick_t input_normal_time;
vlc_tick_t last_ts;
- float input_position;
+ double input_position;
struct vlc_player_timer_source sources[VLC_PLAYER_TIMER_TYPE_COUNT];
#define best_source sources[VLC_PLAYER_TIMER_TYPE_BEST]
@@ -437,21 +437,33 @@ vlc_player_input_GetSelectedTrackStringIds(struct
vlc_player_input *input,
enum es_format_category_e cat)
VLC_MALLOC;
vlc_tick_t
-vlc_player_input_GetTime(struct vlc_player_input *input);
+vlc_player_input_GetTime(struct vlc_player_input *input, vlc_tick_t
system_now);
double
-vlc_player_input_GetPos(struct vlc_player_input *input);
+vlc_player_input_GetPos(struct vlc_player_input *input, vlc_tick_t system_now);
int
vlc_player_input_Start(struct vlc_player_input *input);
+void
+vlc_player_input_SeekByPos(struct vlc_player_input *input, double position,
+ enum vlc_player_seek_speed speed,
+ enum vlc_player_whence whence);
+
+void
+vlc_player_input_SeekByTime(struct vlc_player_input *input, vlc_tick_t time,
+ enum vlc_player_seek_speed speed,
+ enum vlc_player_whence whence);
+
+void
+vlc_player_input_UpdateViewpoint(struct vlc_player_input *input,
+ const vlc_viewpoint_t *viewpoint,
+ enum vlc_player_whence whence);
+
void
vlc_player_input_HandleState(struct vlc_player_input *, enum vlc_player_state,
vlc_tick_t state_date);
-struct vlc_player_timer_point
-vlc_player_input_GetTimerValue(struct vlc_player_input *input);
-
/*
* player_timer.c
*/
=====================================
src/player/timer.c
=====================================
@@ -35,7 +35,7 @@ vlc_player_ResetTimer(vlc_player_t *player)
player->timer.input_length = VLC_TICK_INVALID;
player->timer.input_normal_time = VLC_TICK_0;
player->timer.last_ts = VLC_TICK_INVALID;
- player->timer.input_position = 0.f;
+ player->timer.input_position = 0;
player->timer.smpte_source.smpte.last_framenum = ULONG_MAX;
vlc_mutex_unlock(&player->timer.lock);
@@ -401,15 +401,19 @@ int
vlc_player_GetTimerPoint(vlc_player_t *player, vlc_tick_t system_now,
vlc_tick_t *out_ts, double *out_pos)
{
+ int ret;
vlc_mutex_lock(&player->timer.lock);
if (player->timer.best_source.point.system_date == VLC_TICK_INVALID)
{
vlc_mutex_unlock(&player->timer.lock);
return VLC_EGENERIC;
}
- int ret =
- vlc_player_timer_point_Interpolate(&player->timer.best_source.point,
- system_now, out_ts, out_pos);
+
+ if (system_now != VLC_TICK_INVALID)
+ ret =
vlc_player_timer_point_Interpolate(&player->timer.best_source.point,
+ system_now, out_ts, out_pos);
+ else
+ ret = VLC_SUCCESS;
vlc_mutex_unlock(&player->timer.lock);
return ret;
View it on GitLab:
https://code.videolan.org/videolan/vlc/-/compare/cbc4a25619dc8169a0ce16fd2e38355010b351ad...66204d9244a96a03569492ec40262e20cb2b03f6
--
View it on GitLab:
https://code.videolan.org/videolan/vlc/-/compare/cbc4a25619dc8169a0ce16fd2e38355010b351ad...66204d9244a96a03569492ec40262e20cb2b03f6
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
_______________________________________________
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits