aboutsummaryrefslogtreecommitdiff
path: root/libmm-glib/mm-call.c
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2021-07-01 22:42:45 +0200
committerAleksander Morgado <aleksander@aleksander.es>2021-07-01 23:38:04 +0200
commit132fc268b8a17bfdec787f131491ed7fb7862fe7 (patch)
treec2867d3552c2e89649c16ae6ca620f48c8f5a9bc /libmm-glib/mm-call.c
parent19b3a552308443e691f6120b07d4ba06086b887a (diff)
libmm-glib,call: use helper macros to manage the monitored properties
Diffstat (limited to 'libmm-glib/mm-call.c')
-rw-r--r--libmm-glib/mm-call.c91
1 files changed, 8 insertions, 83 deletions
diff --git a/libmm-glib/mm-call.c b/libmm-glib/mm-call.c
index f9f45fca..8091ff7c 100644
--- a/libmm-glib/mm-call.c
+++ b/libmm-glib/mm-call.c
@@ -40,9 +40,7 @@ struct _MMCallPrivate {
/* Common mutex to sync access */
GMutex mutex;
- /* Audio Format */
- guint audio_format_id;
- MMCallAudioFormat *audio_format;
+ PROPERTY_OBJECT_DECLARE (audio_format, MMCallAudioFormat)
};
/*****************************************************************************/
@@ -263,68 +261,6 @@ mm_call_dup_audio_port (MMCall *self)
/*****************************************************************************/
-static void
-audio_format_updated (MMCall *self,
- GParamSpec *pspec)
-{
- g_mutex_lock (&self->priv->mutex);
- {
- GVariant *dictionary;
-
- g_clear_object (&self->priv->audio_format);
-
- /* TODO: update existing object instead of re-creating? */
- dictionary = mm_gdbus_call_get_audio_format (MM_GDBUS_CALL (self));
- if (dictionary) {
- GError *error = NULL;
-
- self->priv->audio_format = mm_call_audio_format_new_from_dictionary (dictionary, &error);
- if (error) {
- g_warning ("Invalid audio format update received: %s", error->message);
- g_error_free (error);
- }
- }
- }
- g_mutex_unlock (&self->priv->mutex);
-}
-
-static void
-ensure_internal_audio_format (MMCall *self,
- MMCallAudioFormat **dup)
-{
- g_mutex_lock (&self->priv->mutex);
- {
- /* If this is the first time ever asking for the object, setup the
- * update listener and the initial object, if any. */
- if (!self->priv->audio_format_id) {
- GVariant *dictionary;
-
- dictionary = mm_gdbus_call_dup_audio_format (MM_GDBUS_CALL (self));
- if (dictionary) {
- GError *error = NULL;
-
- self->priv->audio_format = mm_call_audio_format_new_from_dictionary (dictionary, &error);
- if (error) {
- g_warning ("Invalid initial audio format: %s", error->message);
- g_error_free (error);
- }
- g_variant_unref (dictionary);
- }
-
- /* No need to clear this signal connection when freeing self */
- self->priv->audio_format_id =
- g_signal_connect (self,
- "notify::audio-format",
- G_CALLBACK (audio_format_updated),
- NULL);
- }
-
- if (dup && self->priv->audio_format)
- *dup = g_object_ref (self->priv->audio_format);
- }
- g_mutex_unlock (&self->priv->mutex);
-}
-
/**
* mm_call_get_audio_format:
* @self: A #MMCall.
@@ -342,16 +278,6 @@ ensure_internal_audio_format (MMCall *self,
*
* Since: 1.10
*/
-MMCallAudioFormat *
-mm_call_get_audio_format (MMCall *self)
-{
- MMCallAudioFormat *format = NULL;
-
- g_return_val_if_fail (MM_IS_CALL (self), NULL);
-
- ensure_internal_audio_format (self, &format);
- return format;
-}
/**
* mm_call_peek_audio_format:
@@ -370,14 +296,11 @@ mm_call_get_audio_format (MMCall *self)
*
* Since: 1.10
*/
-MMCallAudioFormat *
-mm_call_peek_audio_format (MMCall *self)
-{
- g_return_val_if_fail (MM_IS_CALL (self), NULL);
- ensure_internal_audio_format (self, NULL);
- return self->priv->audio_format;
-}
+PROPERTY_OBJECT_DEFINE_FAILABLE (audio_format,
+ Call, call, CALL,
+ MMCallAudioFormat,
+ mm_call_audio_format_new_from_dictionary)
/*****************************************************************************/
@@ -1017,6 +940,8 @@ mm_call_init (MMCall *self)
{
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, MM_TYPE_CALL, MMCallPrivate);
g_mutex_init (&self->priv->mutex);
+
+ PROPERTY_INITIALIZE (audio_format, "audio-format")
}
static void
@@ -1026,7 +951,7 @@ finalize (GObject *object)
g_mutex_clear (&self->priv->mutex);
- g_clear_object (&self->priv->audio_format);
+ PROPERTY_OBJECT_FINALIZE (audio_format)
G_OBJECT_CLASS (mm_call_parent_class)->finalize (object);
}