From fa8bfb3991641a33f933af0fade9a6787cc71000 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Tue, 23 Aug 2016 14:33:11 +0300 Subject: [PATCH] player: Protect setter/getter for the configuration with a mutex --- gst-libs/gst/player/gstplayer.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/gst-libs/gst/player/gstplayer.c b/gst-libs/gst/player/gstplayer.c index a4fa976773..9995ddfca0 100644 --- a/gst-libs/gst/player/gstplayer.c +++ b/gst-libs/gst/player/gstplayer.c @@ -4080,15 +4080,19 @@ gst_player_set_config (GstPlayer * self, GstStructure * config) g_return_val_if_fail (GST_IS_PLAYER (self), FALSE); g_return_val_if_fail (config != NULL, FALSE); + g_mutex_lock (&self->lock); + if (self->app_state != GST_PLAYER_STATE_STOPPED) { GST_INFO_OBJECT (self, "can't change config while player is %s", gst_player_state_get_name (self->app_state)); + g_mutex_unlock (&self->lock); return FALSE; } if (self->config) gst_structure_free (self->config); self->config = config; + g_mutex_unlock (&self->lock); return TRUE; } @@ -4103,14 +4107,21 @@ gst_player_set_config (GstPlayer * self, GstStructure * config) * * Returns: (transfer full): a copy of the current configuration of @player. Use * gst_structure_free() after usage or gst_player_set_config(). + * * Since 1.10 */ GstStructure * gst_player_get_config (GstPlayer * self) { + GstStructure *ret; + g_return_val_if_fail (GST_IS_PLAYER (self), NULL); - return gst_structure_copy (self->config); + g_mutex_lock (&self->lock); + ret = gst_structure_copy (self->config); + g_mutex_unlock (&self->lock); + + return ret; } /**