[vlc-commits] [Git][videolan/vlc][master] 2 commits: player: timer: fix paused state overridden
Steve Lhomme (@robUx4)
gitlab at videolan.org
Tue May 7 08:06:18 UTC 2024
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
06d60eb5 by Thomas Guillem at 2024-05-07T07:33:26+00:00
player: timer: fix paused state overridden
Player timer states are not really states but events. It is possible to
receive a discontinuity while paused, in that case, the paused state was
overridden causing UI timers to continue while paused. Store each events
in different variables to fix this issue. Keeping the discontinuity
event in the internal player state is useless since
1ecb283c87865d01b5f3c947c0e0912f63011d64.
Fixes #28622
- - - - -
765d6117 by Thomas Guillem at 2024-05-07T07:33:26+00:00
player: timer: rename state to event
See previous commit.
- - - - -
3 changed files:
- src/player/input.c
- src/player/player.h
- src/player/timer.c
Changes:
=====================================
src/player/input.c
=====================================
@@ -272,12 +272,12 @@ vlc_player_input_HandleState(struct vlc_player_input *input,
case VLC_PLAYER_STATE_STOPPING:
input->started = false;
- vlc_player_UpdateTimerState(player, NULL,
- VLC_PLAYER_TIMER_STATE_DISCONTINUITY,
+ vlc_player_UpdateTimerEvent(player, NULL,
+ VLC_PLAYER_TIMER_EVENT_DISCONTINUITY,
VLC_TICK_INVALID);
- vlc_player_UpdateTimerState(player, NULL,
- VLC_PLAYER_TIMER_STATE_STOPPING,
+ vlc_player_UpdateTimerEvent(player, NULL,
+ VLC_PLAYER_TIMER_EVENT_STOPPING,
VLC_TICK_INVALID);
if (input == player->input)
@@ -289,8 +289,8 @@ vlc_player_input_HandleState(struct vlc_player_input *input,
break;
case VLC_PLAYER_STATE_PLAYING:
input->pause_date = VLC_TICK_INVALID;
- vlc_player_UpdateTimerState(player, NULL,
- VLC_PLAYER_TIMER_STATE_PLAYING,
+ vlc_player_UpdateTimerEvent(player, NULL,
+ VLC_PLAYER_TIMER_EVENT_PLAYING,
input->pause_date);
/* fall through */
case VLC_PLAYER_STATE_STARTED:
@@ -304,8 +304,8 @@ vlc_player_input_HandleState(struct vlc_player_input *input,
assert(state_date != VLC_TICK_INVALID);
input->pause_date = state_date;
- vlc_player_UpdateTimerState(player, NULL,
- VLC_PLAYER_TIMER_STATE_PAUSED,
+ vlc_player_UpdateTimerEvent(player, NULL,
+ VLC_PLAYER_TIMER_EVENT_PAUSED,
input->pause_date);
break;
default:
@@ -884,8 +884,8 @@ input_thread_Events(input_thread_t *input_thread,
}
else
{
- vlc_player_UpdateTimerState(player, event->output_clock.id,
- VLC_PLAYER_TIMER_STATE_DISCONTINUITY,
+ vlc_player_UpdateTimerEvent(player, event->output_clock.id,
+ VLC_PLAYER_TIMER_EVENT_DISCONTINUITY,
VLC_TICK_INVALID);
}
return;
@@ -986,8 +986,8 @@ input_thread_Events(input_thread_t *input_thread,
break;
case INPUT_EVENT_CACHE:
if (event->cache == 0.0f)
- vlc_player_UpdateTimerState(player, NULL,
- VLC_PLAYER_TIMER_STATE_DISCONTINUITY,
+ vlc_player_UpdateTimerEvent(player, NULL,
+ VLC_PLAYER_TIMER_EVENT_DISCONTINUITY,
VLC_TICK_INVALID);
input->cache = event->cache;
vlc_player_SendEvent(player, on_buffering_changed, event->cache);
=====================================
src/player/player.h
=====================================
@@ -203,20 +203,18 @@ struct vlc_player_timer_source
};
};
-enum vlc_player_timer_state
+enum vlc_player_timer_event
{
- VLC_PLAYER_TIMER_STATE_PLAYING,
- VLC_PLAYER_TIMER_STATE_PAUSED,
- VLC_PLAYER_TIMER_STATE_DISCONTINUITY,
- VLC_PLAYER_TIMER_STATE_STOPPING,
+ VLC_PLAYER_TIMER_EVENT_PLAYING,
+ VLC_PLAYER_TIMER_EVENT_PAUSED,
+ VLC_PLAYER_TIMER_EVENT_DISCONTINUITY,
+ VLC_PLAYER_TIMER_EVENT_STOPPING,
};
struct vlc_player_timer
{
vlc_mutex_t lock;
- enum vlc_player_timer_state state;
-
vlc_tick_t input_length;
vlc_tick_t input_normal_time;
vlc_tick_t last_ts;
@@ -224,6 +222,8 @@ struct vlc_player_timer
vlc_tick_t seek_ts;
double seek_position;
+ bool paused;
+ bool stopping;
bool seeking;
struct vlc_player_timer_source sources[VLC_PLAYER_TIMER_TYPE_COUNT];
@@ -476,8 +476,8 @@ void
vlc_player_ResetTimer(vlc_player_t *player);
void
-vlc_player_UpdateTimerState(vlc_player_t *player, vlc_es_id_t *es_source,
- enum vlc_player_timer_state state,
+vlc_player_UpdateTimerEvent(vlc_player_t *player, vlc_es_id_t *es_source,
+ enum vlc_player_timer_event event,
vlc_tick_t system_date);
void
=====================================
src/player/timer.c
=====================================
@@ -31,7 +31,6 @@ vlc_player_ResetTimer(vlc_player_t *player)
{
vlc_mutex_lock(&player->timer.lock);
- player->timer.state = VLC_PLAYER_TIMER_STATE_DISCONTINUITY;
player->timer.input_length = VLC_TICK_INVALID;
player->timer.input_normal_time = VLC_TICK_0;
player->timer.last_ts = VLC_TICK_INVALID;
@@ -39,7 +38,9 @@ vlc_player_ResetTimer(vlc_player_t *player)
player->timer.smpte_source.smpte.last_framenum = ULONG_MAX;
player->timer.seek_ts = VLC_TICK_INVALID;
player->timer.seek_position = -1;
+ player->timer.paused = false;
player->timer.seeking = false;
+ player->timer.stopping = false;
vlc_mutex_unlock(&player->timer.lock);
}
@@ -190,8 +191,8 @@ vlc_player_UpdateSmpteTimerFPS(vlc_player_t *player,
}
void
-vlc_player_UpdateTimerState(vlc_player_t *player, vlc_es_id_t *es_source,
- enum vlc_player_timer_state state,
+vlc_player_UpdateTimerEvent(vlc_player_t *player, vlc_es_id_t *es_source,
+ enum vlc_player_timer_event event,
vlc_tick_t system_date)
{
vlc_mutex_lock(&player->timer.lock);
@@ -202,9 +203,9 @@ vlc_player_UpdateTimerState(vlc_player_t *player, vlc_es_id_t *es_source,
bool notify = false;
struct vlc_player_timer_source *bestsource = &player->timer.best_source;
- switch(state)
+ switch (event)
{
- case VLC_PLAYER_TIMER_STATE_DISCONTINUITY:
+ case VLC_PLAYER_TIMER_EVENT_DISCONTINUITY:
assert(system_date == VLC_TICK_INVALID);
for (size_t i = 0; i < VLC_PLAYER_TIMER_TYPE_COUNT; ++i)
{
@@ -232,24 +233,25 @@ vlc_player_UpdateTimerState(vlc_player_t *player, vlc_es_id_t *es_source,
}
break;
- case VLC_PLAYER_TIMER_STATE_PAUSED:
+ case VLC_PLAYER_TIMER_EVENT_PAUSED:
notify = true;
assert(system_date != VLC_TICK_INVALID);
+ player->timer.paused = true;
break;
- case VLC_PLAYER_TIMER_STATE_PLAYING:
+ case VLC_PLAYER_TIMER_EVENT_PLAYING:
+ assert(!player->timer.stopping);
+ player->timer.paused = false;
break;
- case VLC_PLAYER_TIMER_STATE_STOPPING:
+ case VLC_PLAYER_TIMER_EVENT_STOPPING:
+ player->timer.stopping = true;
break;
default:
vlc_assert_unreachable();
}
- if (player->timer.state != VLC_PLAYER_TIMER_STATE_STOPPING)
- player->timer.state = state;
-
if (!notify)
{
vlc_mutex_unlock(&player->timer.lock);
@@ -351,7 +353,7 @@ vlc_player_UpdateTimerBestSource(vlc_player_t *player, vlc_es_id_t *es_source,
*/
struct vlc_player_timer_source *source = &player->timer.best_source;
if (!source->es || es_source_is_master
- || (es_source && player->timer.state == VLC_PLAYER_TIMER_STATE_PAUSED))
+ || (es_source && player->timer.paused))
source->es = es_source;
/* Notify the best source */
@@ -472,14 +474,10 @@ vlc_player_UpdateTimer(vlc_player_t *player, vlc_es_id_t *es_source,
assert(point->ts != VLC_TICK_INVALID);
vlc_tick_t system_date = point->system_date;
- if (player->timer.state == VLC_PLAYER_TIMER_STATE_PAUSED)
+ if (player->timer.paused)
system_date = VLC_TICK_MAX;
- /* An update after a discontinuity means that the playback is resumed */
- if (player->timer.state == VLC_PLAYER_TIMER_STATE_DISCONTINUITY)
- player->timer.state = VLC_PLAYER_TIMER_STATE_PLAYING;
-
- if (player->timer.state != VLC_PLAYER_TIMER_STATE_STOPPING)
+ if (!player->timer.stopping)
vlc_player_UpdateTimerBestSource(player, es_source,
es_source_is_master, point, system_date,
force_update);
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/63f3e39652a7179b5d07c968471b5601810fc3a8...765d6117b30256c3ec6788fd953cd11ecc4f89ae
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/63f3e39652a7179b5d07c968471b5601810fc3a8...765d6117b30256c3ec6788fd953cd11ecc4f89ae
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