[vlc-commits] [Git][videolan/vlc][master] 6 commits: player: add missing doc warning
Steve Lhomme (@robUx4)
gitlab at videolan.org
Tue Oct 1 14:55:14 UTC 2024
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
62efff32 by Thomas Guillem at 2024-10-01T14:38:36+00:00
player: add missing doc warning
- - - - -
a0f4a9a3 by Thomas Guillem at 2024-10-01T14:38:36+00:00
player: timer.on_discontinuity is not mandatory anymore
The documentation will be updated in a future commit.
- - - - -
fbf91025 by Thomas Guillem at 2024-10-01T14:38:36+00:00
dbus: use timer.on_seek callback
To signal when the player seek.
- - - - -
9b03cf9e by Thomas Guillem at 2024-10-01T14:38:36+00:00
player: rework timer.on_discontinuity callback
Signaling discontinuity had 2 purposes:
- To handle seek requests, but it could not really work, hence the new
on_seek() callback.
- Signal when the player is paused or stopping
Therefore, replace this event with on_paused().
- - - - -
10a6eba4 by Thomas Guillem at 2024-10-01T14:38:36+00:00
player: document if callbacks need to be implemented
- - - - -
2a4fe7dd by Thomas Guillem at 2024-10-01T14:38:36+00:00
libvlc: rework player timer on_discontinuity callback
- - - - -
8 changed files:
- include/vlc/libvlc_media_player.h
- include/vlc_player.h
- lib/media_player.c
- lib/media_player_internal.h
- modules/control/dbus/dbus.c
- modules/gui/qt/player/player_controller.cpp
- src/player/timer.c
- test/src/player/player.c
Changes:
=====================================
include/vlc/libvlc_media_player.h
=====================================
@@ -2947,11 +2947,16 @@ typedef void (*libvlc_media_player_watch_time_on_update)(
const libvlc_media_player_time_point_t *value, void *data);
/**
- * Callback prototype that notify when the player is paused or a discontinuity
- * occurred.
+ * Callback prototype that notify when the timer is paused.
*
- * Likely caused by seek from the user or because the playback is stopped. The
- * player user should stop its "interpolate" timer.
+ * This event is sent when the player is paused or stopping. The player
+ * user should stop its "interpolate" timer.
+ *
+ * \note libvlc_media_player_watch_time_on_update() can be called when paused
+ * for those 2 reasons:
+ * - playback is resumed (libvlc_media_player_time_point_t.system_date is valid)
+ * - a track, likely video (next-frame) is outputted when paused
+ * (libvlc_media_player_time_point_t.system_date = INT64_MAX)
*
* \warning It is forbidden to call any Media Player functions from here.
*
@@ -2960,7 +2965,7 @@ typedef void (*libvlc_media_player_watch_time_on_update)(
* date in order to get the last paused ts/position.
* \param data opaque pointer set by libvlc_media_player_watch_time()
*/
-typedef void (*libvlc_media_player_watch_time_on_discontinuity)(
+typedef void (*libvlc_media_player_watch_time_on_paused)(
int64_t system_date_us, void *data);
/**
@@ -2988,8 +2993,7 @@ typedef void (*libvlc_media_player_watch_time_on_seek)(
* updates, use it to avoid flood from too many source updates, set it to 0 to
* receive all updates.
* \param on_update callback to listen to update events (must not be NULL)
- * \param on_discontinuity callback to listen to discontinuity events (can be
- * be NULL)
+ * \param on_paused callback to listen to paused events (can be NULL)
* \param cbs_data opaque pointer used by the callbacks
* \return 0 on success, -1 on error (allocation error, or if already watching)
* \version LibVLC 4.0.0 or later
@@ -2998,7 +3002,7 @@ LIBVLC_API int
libvlc_media_player_watch_time(libvlc_media_player_t *p_mi,
int64_t min_period_us,
libvlc_media_player_watch_time_on_update on_update,
- libvlc_media_player_watch_time_on_discontinuity on_discontinuity,
+ libvlc_media_player_watch_time_on_paused on_paused,
libvlc_media_player_watch_time_on_seek on_seek,
void *cbs_data);
=====================================
include/vlc_player.h
=====================================
@@ -3341,7 +3341,7 @@ struct vlc_player_timer_smpte_timecode
struct vlc_player_timer_cbs
{
/**
- * Called when the state or the time changed.
+ * Called when the state or the time changed (mandatory).
*
* Get notified when the time is updated by the input or output source. The
* input source is the 'demux' or the 'access_demux'. The output source are
@@ -3361,19 +3361,31 @@ struct vlc_player_timer_cbs
void (*on_update)(const struct vlc_player_timer_point *value, void *data);
/**
- * The player is paused or a discontinuity occurred, likely caused by seek
- * from the user or because the playback is stopped. The player user should
- * stop its "interpolate" timer.
+ * The player timer is paused (can be NULL).
*
- * @param system_date system date of this event, only valid when paused. It
+ * This event is sent when the player is paused or stopping. The player
+ * user should stop its "interpolate" timer.
+ *
+ * @note on_update() can be called when paused for those 2 reasons:
+ * - playback is resumed (vlc_player_timer_point.system_date is valid)
+ * - a track, likely video (next-frame) is outputted when paused
+ * (vlc_player_timer_point.system_date = INT64_MAX)
+ *
+ * @warning The player is not locked from this callback. It is forbidden
+ * to call any player functions from here.
+ *
+ * @param system_date system date of this event, not valid when stopped. It
* can be used to interpolate the last updated point to this date in order
* to get the last paused ts/position.
* @param data opaque pointer set by vlc_player_AddTimer()
*/
- void (*on_discontinuity)(vlc_tick_t system_date, void *data);
+ void (*on_paused)(vlc_tick_t system_date, void *data);
/**
- * Called when the player is seeking or finished seeking
+ * Called when the player is seeking or finished seeking (can be NULL).
+ *
+ * @warning The player is not locked from this callback. It is forbidden
+ * to call any player functions from here.
*
* @param value point of the seek request or NULL when seeking is finished
* value.system_date = VLC_TICK_MAX in that case
=====================================
lib/media_player.c
=====================================
@@ -2267,15 +2267,14 @@ static void player_timer_on_update(const struct vlc_player_timer_point *point,
p_mi->timer.on_update(&libpoint, p_mi->timer.cbs_data);
}
-static void player_timer_on_discontinuity(vlc_tick_t system_date, void *data)
+static void player_timer_on_paused(vlc_tick_t system_date, void *data)
{
libvlc_media_player_t *p_mi = data;
- if (p_mi->timer.on_discontinuity == NULL)
+ if (p_mi->timer.on_paused == NULL)
return;
- p_mi->timer.on_discontinuity(US_FROM_VLC_TICK(system_date),
- p_mi->timer.cbs_data);
+ p_mi->timer.on_paused(US_FROM_VLC_TICK(system_date), p_mi->timer.cbs_data);
}
static void player_timer_on_seek(const struct vlc_player_timer_point *point,
@@ -2299,7 +2298,7 @@ int
libvlc_media_player_watch_time(libvlc_media_player_t *p_mi,
int64_t min_period_us,
libvlc_media_player_watch_time_on_update on_update,
- libvlc_media_player_watch_time_on_discontinuity on_discontinuity,
+ libvlc_media_player_watch_time_on_paused on_paused,
libvlc_media_player_watch_time_on_seek on_seek,
void *cbs_data)
{
@@ -2307,7 +2306,7 @@ libvlc_media_player_watch_time(libvlc_media_player_t *p_mi,
static const struct vlc_player_timer_cbs player_timer_cbs = {
.on_update = player_timer_on_update,
- .on_discontinuity = player_timer_on_discontinuity,
+ .on_paused = player_timer_on_paused,
.on_seek = player_timer_on_seek,
};
@@ -2323,7 +2322,7 @@ libvlc_media_player_watch_time(libvlc_media_player_t *p_mi,
}
p_mi->timer.on_update = on_update;
- p_mi->timer.on_discontinuity = on_discontinuity;
+ p_mi->timer.on_paused = on_paused;
p_mi->timer.on_seek = on_seek;
p_mi->timer.cbs_data = cbs_data;
=====================================
lib/media_player_internal.h
=====================================
@@ -50,7 +50,7 @@ struct libvlc_media_player_t
struct {
vlc_player_timer_id *id;
libvlc_media_player_watch_time_on_update on_update;
- libvlc_media_player_watch_time_on_discontinuity on_discontinuity;
+ libvlc_media_player_watch_time_on_paused on_paused;
libvlc_media_player_watch_time_on_seek on_seek;
void *cbs_data;
} timer;
=====================================
modules/control/dbus/dbus.c
=====================================
@@ -163,7 +163,7 @@ static void player_aout_on_volume_changed(audio_output_t *, float, void *);
static void player_aout_on_mute_changed(audio_output_t *, bool, void *);
static void player_vout_on_fullscreen_changed(vout_thread_t *, bool, void *);
-static void player_timer_on_discontinuity(vlc_tick_t system_dae, void *data);
+static void player_timer_on_seek(const struct vlc_player_timer_point *, void *);
static void player_timer_on_update(const struct vlc_player_timer_point *, void *);
/*****************************************************************************
@@ -318,7 +318,7 @@ static int Open( vlc_object_t *p_this )
static struct vlc_player_timer_cbs const player_timer_cbs =
{
.on_update = player_timer_on_update,
- .on_discontinuity = player_timer_on_discontinuity,
+ .on_seek = player_timer_on_seek,
};
p_sys->player_timer =
vlc_player_AddTimer(player, VLC_TICK_FROM_SEC(1), &player_timer_cbs, p_intf);
@@ -1271,16 +1271,12 @@ player_timer_on_update(const struct vlc_player_timer_point *value, void *data)
}
static void
-player_timer_on_discontinuity(vlc_tick_t system_date, void *data)
+player_timer_on_seek(const struct vlc_player_timer_point *value, void *data)
{
+ (void) value;
intf_thread_t *intf = data;
- intf_sys_t *sys = intf->p_sys;
-
- bool stopping = sys->i_playing_state == PLAYBACK_STATE_STOPPED;
- bool paused = system_date != VLC_TICK_INVALID;
- if( !paused && !stopping )
- add_event_signal(intf, &(callback_info_t){ .signal = SIGNAL_SEEK });
+ add_event_signal(intf, &(callback_info_t){ .signal = SIGNAL_SEEK });
}
/*****************************************************************************
=====================================
modules/gui/qt/player/player_controller.cpp
=====================================
@@ -954,7 +954,7 @@ static void on_player_timer_update(const struct vlc_player_timer_point *point,
});
}
-static void on_player_timer_discontinuity(vlc_tick_t system_date, void *data)
+static void on_player_timer_paused(vlc_tick_t system_date, void *data)
{
PlayerControllerPrivate* that = static_cast<PlayerControllerPrivate*>(data);
that->callAsync([that,system_date](){
@@ -1083,7 +1083,7 @@ static const vlc_player_aout_cbs player_aout_cbs = []{
static const vlc_player_timer_cbs player_timer_cbs = []{
struct vlc_player_timer_cbs cbs {};
cbs.on_update = on_player_timer_update;
- cbs.on_discontinuity = on_player_timer_discontinuity;
+ cbs.on_paused = on_player_timer_paused;
cbs.on_seek = on_player_timer_seek;
return cbs;
}();
=====================================
src/player/timer.c
=====================================
@@ -216,10 +216,6 @@ vlc_player_UpdateTimerEvent(vlc_player_t *player, vlc_es_id_t *es_source,
/* signal discontinuity only on best source */
if (bestsource->es == es_source)
{
- /* And only once */
- if (source->point.system_date != VLC_TICK_INVALID)
- notify = true;
-
/* There can be several discontinuities on the same source
* for one seek request, hence the need of the
* 'timer.seeking' variable to notify only once the end of
@@ -247,6 +243,7 @@ vlc_player_UpdateTimerEvent(vlc_player_t *player, vlc_es_id_t *es_source,
case VLC_PLAYER_TIMER_EVENT_STOPPING:
player->timer.stopping = true;
+ notify = true;
break;
default:
@@ -263,7 +260,8 @@ vlc_player_UpdateTimerEvent(vlc_player_t *player, vlc_es_id_t *es_source,
vlc_list_foreach(timer, &bestsource->listeners, node)
{
timer->last_update_date = VLC_TICK_INVALID;
- timer->cbs->on_discontinuity(system_date, timer->data);
+ if (timer->cbs->on_paused != NULL)
+ timer->cbs->on_paused(system_date, timer->data);
}
vlc_mutex_unlock(&player->timer.lock);
=====================================
test/src/player/player.c
=====================================
@@ -168,13 +168,13 @@ struct report_timer
{
REPORT_TIMER_POINT,
REPORT_TIMER_TC,
- REPORT_TIMER_DISCONTINUITY,
+ REPORT_TIMER_PAUSED,
} type;
union
{
struct vlc_player_timer_point point;
struct vlc_player_timer_smpte_timecode tc;
- vlc_tick_t discontinuity_date;
+ vlc_tick_t paused_date;
};
};
typedef struct VLC_VECTOR(struct report_timer) vec_report_timer;
@@ -2343,13 +2343,13 @@ timers_on_update(const struct vlc_player_timer_point *point, void *data)
}
static void
-timers_on_discontinuity(vlc_tick_t system_date, void *data)
+timers_on_paused(vlc_tick_t system_date, void *data)
{
struct timer_state *timer = data;
struct report_timer report =
{
- .type = REPORT_TIMER_DISCONTINUITY,
- .discontinuity_date = system_date,
+ .type = REPORT_TIMER_PAUSED,
+ .paused_date = system_date,
};
bool success = vlc_vector_push(&timer->vec, report);
assert(success);
@@ -2523,8 +2523,8 @@ test_timers_playback(struct ctx *ctx, struct timer_state timers[],
}
else
{
- assert(report->type == REPORT_TIMER_DISCONTINUITY);
- assert(report->discontinuity_date == VLC_TICK_INVALID);
+ assert(report->type == REPORT_TIMER_PAUSED);
+ assert(report->paused_date == VLC_TICK_INVALID);
}
}
}
@@ -2613,7 +2613,7 @@ test_timers(struct ctx *ctx)
static const struct vlc_player_timer_cbs cbs =
{
.on_update = timers_on_update,
- .on_discontinuity = timers_on_discontinuity,
+ .on_paused = timers_on_paused,
};
static const struct vlc_player_timer_smpte_cbs smpte_cbs =
{
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/8b78a74aa27eb048543f1ef3284b5332bb8b02cd...2a4fe7dd8832d183a40c5b610b04699da7d03f02
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/8b78a74aa27eb048543f1ef3284b5332bb8b02cd...2a4fe7dd8832d183a40c5b610b04699da7d03f02
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