diff --git a/gst/flv/gstflvmux.c b/gst/flv/gstflvmux.c index 5cc5f78d44..33e4e7d849 100644 --- a/gst/flv/gstflvmux.c +++ b/gst/flv/gstflvmux.c @@ -1077,7 +1077,7 @@ gst_flv_mux_create_metadata (GstFlvMux * mux) { time_t secs; - struct tm *tm; + struct tm tm; gchar *s; static const gchar *weekdays[] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" @@ -1088,11 +1088,15 @@ gst_flv_mux_create_metadata (GstFlvMux * mux) }; secs = g_get_real_time () / G_USEC_PER_SEC; - tm = gmtime (&secs); +#ifdef HAVE_GMTIME_R + gmtime_r (&secs, &tm); +#else + tm = *gmtime (&secs); +#endif - s = g_strdup_printf ("%s %s %d %02d:%02d:%02d %d", weekdays[tm->tm_wday], - months[tm->tm_mon], tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, - tm->tm_year + 1900); + s = g_strdup_printf ("%s %s %d %02d:%02d:%02d %d", weekdays[tm.tm_wday], + months[tm.tm_mon], tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec, + tm.tm_year + 1900); _gst_buffer_new_and_alloc (2 + 12 + 1 + 2 + strlen (s), &tmp, &data); data[0] = 0; /* 12 bytes name */ diff --git a/meson.build b/meson.build index b4f338ade3..28df2fcd2f 100644 --- a/meson.build +++ b/meson.build @@ -151,6 +151,7 @@ check_functions = [ # check token HAVE_RDTSC ['HAVE_SINH', 'sinh', '#include'], # check token HAVE_WAVEFORM + ['HAVE_GMTIME_R', 'gmtime_r', '#include'], ] libm = cc.find_library('m', required : false)