From 6abed8da20eb0a2f4990d064ad923ef735056e84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Sun, 9 Feb 2014 18:19:33 +0100 Subject: [PATCH] hlsdemux: Update to non-deprecated GLib thread API --- ext/hls/gsthlsdemux.c | 26 +++++++++----------------- ext/hls/gsthlsdemux.h | 2 +- ext/hls/m3u8.c | 5 ++--- ext/hls/m3u8.h | 6 +++--- 4 files changed, 15 insertions(+), 24 deletions(-) diff --git a/ext/hls/gsthlsdemux.c b/ext/hls/gsthlsdemux.c index 32e1b7b69f..baa28e336a 100644 --- a/ext/hls/gsthlsdemux.c +++ b/ext/hls/gsthlsdemux.c @@ -41,12 +41,7 @@ # include "config.h" #endif -/* FIXME 0.11: suppress warnings for deprecated API such as GStaticRecMutex - * with newer GLib versions (>= 2.31.0) */ -#define GLIB_DISABLE_DEPRECATION_WARNINGS - #include -#include #include #include "gsthlsdemux.h" @@ -879,8 +874,8 @@ gst_hls_demux_updates_loop (GstHLSDemux * demux) /* block until the next scheduled update or the signal to quit this thread */ GST_DEBUG_OBJECT (demux, "Waiting"); - if (g_cond_timed_wait (GST_TASK_GET_COND (demux->updates_task), - &demux->updates_timed_lock, &demux->next_update)) { + if (g_cond_wait_until (GST_TASK_GET_COND (demux->updates_task), + &demux->updates_timed_lock, demux->next_update)) { GST_DEBUG_OBJECT (demux, "Unlocked"); goto quit; } @@ -1009,7 +1004,7 @@ gst_hls_demux_cache_fragments (GstHLSDemux * demux) gst_element_post_message (GST_ELEMENT (demux), gst_message_new_buffering (GST_OBJECT (demux), 100 * i / demux->fragments_cache)); - g_get_current_time (&demux->next_update); + demux->next_update = g_get_monotonic_time (); if (!gst_hls_demux_get_next_fragment (demux, TRUE)) { if (demux->end_of_playlist) break; @@ -1025,7 +1020,7 @@ gst_hls_demux_cache_fragments (GstHLSDemux * demux) gst_element_post_message (GST_ELEMENT (demux), gst_message_new_buffering (GST_OBJECT (demux), 100)); - g_get_current_time (&demux->next_update); + demux->next_update = g_get_monotonic_time (); demux->need_cache = FALSE; return TRUE; @@ -1197,11 +1192,10 @@ gst_hls_demux_schedule (GstHLSDemux * demux) /* schedule the next update using the target duration field of the * playlist */ - g_time_val_add (&demux->next_update, - gst_m3u8_client_get_target_duration (demux->client) - / GST_SECOND * G_USEC_PER_SEC * update_factor); - GST_DEBUG_OBJECT (demux, "Next update scheduled at %s", - g_time_val_to_iso8601 (&demux->next_update)); + demux->next_update += gst_m3u8_client_get_target_duration (demux->client) + / GST_SECOND * G_USEC_PER_SEC * update_factor; + GST_DEBUG_OBJECT (demux, "Next update scheduled at %" G_GINT64_FORMAT, + demux->next_update); return TRUE; } @@ -1209,7 +1203,6 @@ gst_hls_demux_schedule (GstHLSDemux * demux) static gboolean gst_hls_demux_switch_playlist (GstHLSDemux * demux) { - GTimeVal now; GstClockTime diff; gsize size; gint bitrate; @@ -1226,8 +1219,7 @@ gst_hls_demux_switch_playlist (GstHLSDemux * demux) /* compare the time when the fragment was downloaded with the time when it was * scheduled */ - g_get_current_time (&now); - diff = (GST_TIMEVAL_TO_TIME (now) - GST_TIMEVAL_TO_TIME (demux->next_update)); + diff = g_get_monotonic_time () - demux->next_update; buffer = gst_fragment_get_buffer (fragment); size = gst_buffer_get_size (buffer); bitrate = (size * 8) / ((double) diff / GST_SECOND); diff --git a/ext/hls/gsthlsdemux.h b/ext/hls/gsthlsdemux.h index 5f57aa045a..1e57ccb9fd 100644 --- a/ext/hls/gsthlsdemux.h +++ b/ext/hls/gsthlsdemux.h @@ -84,7 +84,7 @@ struct _GstHLSDemux GstTask *updates_task; GRecMutex updates_lock; GMutex updates_timed_lock; - GTimeVal next_update; /* Time of the next update */ + gint64 next_update; /* Time of the next update */ gboolean cancelled; /* Position in the stream */ diff --git a/ext/hls/m3u8.c b/ext/hls/m3u8.c index 63372239f8..ac20d6d065 100644 --- a/ext/hls/m3u8.c +++ b/ext/hls/m3u8.c @@ -25,7 +25,6 @@ #include #include -#include #include "gstfragmented.h" #include "m3u8.h" @@ -440,7 +439,7 @@ gst_m3u8_client_new (const gchar * uri) client->current = NULL; client->sequence = -1; client->update_failed_count = 0; - client->lock = g_mutex_new (); + g_mutex_init (&client->lock); gst_m3u8_set_uri (client->main, g_strdup (uri)); return client; @@ -452,7 +451,7 @@ gst_m3u8_client_free (GstM3U8Client * self) g_return_if_fail (self != NULL); gst_m3u8_free (self->main); - g_mutex_free (self->lock); + g_mutex_clear (&self->lock); g_free (self); } diff --git a/ext/hls/m3u8.h b/ext/hls/m3u8.h index 33fd500827..d035172a0f 100644 --- a/ext/hls/m3u8.h +++ b/ext/hls/m3u8.h @@ -32,8 +32,8 @@ typedef struct _GstM3U8Client GstM3U8Client; #define GST_M3U8(m) ((GstM3U8*)m) #define GST_M3U8_MEDIA_FILE(f) ((GstM3U8MediaFile*)f) -#define GST_M3U8_CLIENT_LOCK(c) g_mutex_lock (c->lock); -#define GST_M3U8_CLIENT_UNLOCK(c) g_mutex_unlock (c->lock); +#define GST_M3U8_CLIENT_LOCK(c) g_mutex_lock (&c->lock); +#define GST_M3U8_CLIENT_UNLOCK(c) g_mutex_unlock (&c->lock); struct _GstM3U8 { @@ -76,7 +76,7 @@ struct _GstM3U8Client GstM3U8 *current; guint update_failed_count; gint sequence; /* the next sequence for this client */ - GMutex *lock; + GMutex lock; };