mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-26 19:51:11 +00:00
ptpclock: Use a system clock for the time observations instead of gst_util_get_timestamp()
They don't necessarily use the same underlying clocks (e.g. on Windows), or might be configured to a different clock type (monotonic vs. real time clock). We need the values a clean system clock returns, as those are the values used by the internal clocks.
This commit is contained in:
parent
bf62a96549
commit
42b16c9e3c
1 changed files with 16 additions and 4 deletions
|
@ -233,6 +233,7 @@ static GMainContext *main_context;
|
|||
static GMainLoop *main_loop;
|
||||
static GIOChannel *stdin_channel, *stdout_channel;
|
||||
static GRand *delay_req_rand;
|
||||
static GstClock *observation_system_clock;
|
||||
static PtpClockIdentity ptp_clock_id = { GST_PTP_CLOCK_ID_NONE, 0 };
|
||||
|
||||
typedef struct
|
||||
|
@ -968,7 +969,8 @@ send_delay_req_timeout (PtpPendingSync * sync)
|
|||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
|
||||
sync->delay_req_send_time_local = gst_util_get_timestamp ();
|
||||
sync->delay_req_send_time_local =
|
||||
gst_clock_get_time (observation_system_clock);
|
||||
|
||||
status =
|
||||
g_io_channel_write_chars (stdout_channel,
|
||||
|
@ -997,7 +999,7 @@ send_delay_req_timeout (PtpPendingSync * sync)
|
|||
static gboolean
|
||||
send_delay_req (PtpDomainData * domain, PtpPendingSync * sync)
|
||||
{
|
||||
GstClockTime now = gst_util_get_timestamp ();
|
||||
GstClockTime now = gst_clock_get_time (observation_system_clock);
|
||||
guint timeout;
|
||||
GSource *timeout_source;
|
||||
|
||||
|
@ -1765,7 +1767,7 @@ have_stdin_data_cb (GIOChannel * channel, GIOCondition condition,
|
|||
switch (header.type) {
|
||||
case TYPE_EVENT:
|
||||
case TYPE_GENERAL:{
|
||||
GstClockTime receive_time = gst_util_get_timestamp ();
|
||||
GstClockTime receive_time = gst_clock_get_time (observation_system_clock);
|
||||
PtpMessage msg;
|
||||
|
||||
if (parse_ptp_message (&msg, (const guint8 *) buffer, header.size)) {
|
||||
|
@ -1801,7 +1803,7 @@ have_stdin_data_cb (GIOChannel * channel, GIOCondition condition,
|
|||
static gboolean
|
||||
cleanup_cb (gpointer data)
|
||||
{
|
||||
GstClockTime now = gst_util_get_timestamp ();
|
||||
GstClockTime now = gst_clock_get_time (observation_system_clock);
|
||||
GList *l, *m, *n;
|
||||
|
||||
for (l = domain_data; l; l = l->next) {
|
||||
|
@ -2074,6 +2076,9 @@ gst_ptp_init (guint64 clock_id, gchar ** interfaces)
|
|||
g_io_channel_set_buffered (stdout_channel, FALSE);
|
||||
|
||||
delay_req_rand = g_rand_new ();
|
||||
observation_system_clock =
|
||||
g_object_new (GST_TYPE_SYSTEM_CLOCK, "name", "ptp-observation-clock",
|
||||
NULL);
|
||||
|
||||
initted = TRUE;
|
||||
|
||||
|
@ -2125,6 +2130,10 @@ done:
|
|||
if (delay_req_rand)
|
||||
g_rand_free (delay_req_rand);
|
||||
delay_req_rand = NULL;
|
||||
|
||||
if (observation_system_clock)
|
||||
gst_object_unref (observation_system_clock);
|
||||
observation_system_clock = NULL;
|
||||
}
|
||||
|
||||
g_mutex_unlock (&ptp_lock);
|
||||
|
@ -2180,6 +2189,9 @@ gst_ptp_deinit (void)
|
|||
if (delay_req_rand)
|
||||
g_rand_free (delay_req_rand);
|
||||
delay_req_rand = NULL;
|
||||
if (observation_system_clock)
|
||||
gst_object_unref (observation_system_clock);
|
||||
observation_system_clock = NULL;
|
||||
|
||||
for (l = domain_data; l; l = l->next) {
|
||||
PtpDomainData *domain = l->data;
|
||||
|
|
Loading…
Reference in a new issue