1 --- a/gst/hls/gsthlsdemux.c
2 +++ b/gst/hls/gsthlsdemux.c
3 @@ -1116,6 +1116,8 @@ gst_hls_demux_change_playlist (GstHLSDemux * demux, guint max_bitrate)
4 GList *previous_variant, *current_variant;
5 gint old_bandwidth, new_bandwidth;
7 + GST_M3U8_CLIENT_LOCK (demux->client);
9 /* If user specifies a connection speed never use a playlist with a bandwidth
11 if (demux->connection_speed != 0 && max_bitrate > demux->connection_speed)
12 @@ -1131,11 +1133,11 @@ retry_failover_protection:
14 /* Don't do anything else if the playlist is the same */
15 if (new_bandwidth == old_bandwidth) {
16 + GST_M3U8_CLIENT_UNLOCK (demux->client);
20 demux->client->main->current_variant = current_variant;
21 - GST_M3U8_CLIENT_UNLOCK (demux->client);
23 gst_m3u8_client_set_current (demux->client, current_variant->data);
25 @@ -1152,9 +1154,9 @@ retry_failover_protection:
26 gst_message_new_element (GST_OBJECT_CAST (demux), s));
28 GList *failover = NULL;
31 GST_INFO_OBJECT (demux, "Unable to update playlist. Switching back");
32 - GST_M3U8_CLIENT_LOCK (demux->client);
34 failover = g_list_previous (current_variant);
35 if (failover && new_bandwidth == GST_M3U8 (failover->data)->bandwidth) {
36 @@ -1163,19 +1165,26 @@ retry_failover_protection:
39 demux->client->main->current_variant = previous_variant;
40 - GST_M3U8_CLIENT_UNLOCK (demux->client);
42 gst_m3u8_client_set_current (demux->client, previous_variant->data);
43 /* Try a lower bitrate (or stop if we just tried the lowest) */
45 GST_M3U8 (g_list_first (demux->client->main->lists)->data)->bandwidth)
50 - return gst_hls_demux_change_playlist (demux, new_bandwidth - 1);
51 + ret = gst_hls_demux_change_playlist (demux, new_bandwidth - 1);
53 + GST_M3U8_CLIENT_UNLOCK (demux->client);
58 /* Force typefinding since we might have changed media type */
59 demux->do_typefind = TRUE;
61 + GST_M3U8_CLIENT_UNLOCK (demux->client);
68 @@ -423,7 +423,8 @@ gst_m3u8_client_new (const gchar * uri)
69 client->current = NULL;
70 client->sequence = -1;
71 client->update_failed_count = 0;
72 - client->lock = g_mutex_new ();
73 + client->lock = g_new0 (GStaticRecMutex, 1);
74 + g_static_rec_mutex_init(client->lock);
75 gst_m3u8_set_uri (client->main, g_strdup (uri));
78 @@ -435,7 +436,9 @@ gst_m3u8_client_free (GstM3U8Client * self)
79 g_return_if_fail (self != NULL);
81 gst_m3u8_free (self->main);
82 - g_mutex_free (self->lock);
83 + g_static_rec_mutex_free (self->lock);
84 + g_free (self->lock);
91 @@ -32,8 +32,8 @@ typedef struct _GstM3U8Client GstM3U8Client;
92 #define GST_M3U8(m) ((GstM3U8*)m)
93 #define GST_M3U8_MEDIA_FILE(f) ((GstM3U8MediaFile*)f)
95 -#define GST_M3U8_CLIENT_LOCK(c) g_mutex_lock (c->lock);
96 -#define GST_M3U8_CLIENT_UNLOCK(c) g_mutex_unlock (c->lock);
97 +#define GST_M3U8_CLIENT_LOCK(c) g_static_rec_mutex_lock (c->lock);
98 +#define GST_M3U8_CLIENT_UNLOCK(c) g_static_rec_mutex_unlock (c->lock);
102 @@ -73,7 +73,7 @@ struct _GstM3U8Client
104 guint update_failed_count;
105 gint sequence; /* the next sequence for this client */
107 + GStaticRecMutex *lock;