Skip to content
Snippets Groups Projects
Commit 6d59542f authored by Aaron Viets's avatar Aaron Viets
Browse files

lal_insertgap: unref gst_date_time variable and some other sanity checks

parent 98e1a053
No related branches found
No related tags found
No related merge requests found
......@@ -408,6 +408,11 @@ static void *input_buffer_timer(void *void_element) {
GSTLALInsertGap *element = GSTLAL_INSERTGAP(void_element);
GstDateTime *current_gst_time;
gchar *current_utc_time;
struct tm tm;
guint64 current_time, ets_min;
while(TRUE) {
/*
* When element->wait_time > 0, this function runs continuously on a
......@@ -416,7 +421,7 @@ static void *input_buffer_timer(void *void_element) {
* input data is more than the wait time behind real time, we will
* push buffers from the source pad.
*/
naptime:
/* don't hog a billion CPUs */
if(element->block_duration < G_MAXUINT64 / 2)
sleep(element->block_duration / 1000000000.0);
......@@ -424,21 +429,24 @@ static void *input_buffer_timer(void *void_element) {
sleep(1);
/* Get the current real time as a string */
GstDateTime *current_gst_time = gst_date_time_new_now_utc();
gchar *current_utc_time = gst_date_time_to_iso8601_string(current_gst_time);
current_gst_time = gst_date_time_new_now_utc();
current_utc_time = gst_date_time_to_iso8601_string(current_gst_time);
if(current_utc_time == NULL)
goto naptime;
/* parse DateTime to gps time */
struct tm tm;
strptime(current_utc_time, "%Y-%m-%dT%H:%M:%SZ", &tm);
/* Time in nanoseconds */
guint64 current_time = (guint64) XLALUTCToGPS(&tm) * 1000000000 + (guint64) gst_date_time_get_microsecond(current_gst_time) * 1000;
current_time = (guint64) XLALUTCToGPS(&tm) * 1000000000 + (guint64) gst_date_time_get_microsecond(current_gst_time) * 1000;
gst_date_time_unref(current_gst_time);
g_free(current_utc_time);
/*
* The minimum allowable current buffer timestamp. If the input buffer
* has an earlier timestamp, we will push output buffers without waiting
* any longer for input.
*/
guint64 ets_min = current_time - element->wait_time;
ets_min = current_time - element->wait_time;
/* It needs to be a multiple of the sample period. */
ets_min = gst_util_uint64_scale_int_round(gst_util_uint64_scale_int(ets_min, element->rate, 1000000000), 1000000000, element->rate);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment