diff options
author | Michal Ratajsky <[email protected]> | 2014-08-20 18:53:26 +0200 |
---|---|---|
committer | Michal Ratajsky <[email protected]> | 2014-08-20 18:53:26 +0200 |
commit | 0325b6223a23ebd75fbd8c9244baab00facec126 (patch) | |
tree | 8547bdc4a9e875d931eddbeb81e34ec37ddfbfef | |
parent | 9956b2a9465c538c8792235c1ee02d2f90b84641 (diff) | |
download | libmatemixer-0325b6223a23ebd75fbd8c9244baab00facec126.tar.bz2 libmatemixer-0325b6223a23ebd75fbd8c9244baab00facec126.tar.xz |
Fix some refcounting and stream control parent setting issues
-rw-r--r-- | backends/pulse/pulse-backend.c | 10 | ||||
-rw-r--r-- | backends/pulse/pulse-device.c | 9 | ||||
-rw-r--r-- | backends/pulse/pulse-ext-stream.c | 12 | ||||
-rw-r--r-- | backends/pulse/pulse-port-switch.c | 20 | ||||
-rw-r--r-- | backends/pulse/pulse-sink.c | 2 | ||||
-rw-r--r-- | backends/pulse/pulse-source.c | 2 | ||||
-rw-r--r-- | libmatemixer/matemixer-stream-control.c | 30 | ||||
-rw-r--r-- | libmatemixer/matemixer-stream.c | 3 |
8 files changed, 38 insertions, 50 deletions
diff --git a/backends/pulse/pulse-backend.c b/backends/pulse/pulse-backend.c index e1b7ed5..1a1cabc 100644 --- a/backends/pulse/pulse-backend.c +++ b/backends/pulse/pulse-backend.c @@ -762,7 +762,7 @@ on_connection_card_info (PulseConnection *connection, g_hash_table_insert (pulse->priv->devices, GUINT_TO_POINTER (info->index), - device); + g_object_ref (device)); free_list_devices (pulse); g_signal_emit_by_name (G_OBJECT (pulse), @@ -814,7 +814,7 @@ on_connection_sink_info (PulseConnection *connection, free_list_streams (pulse); g_hash_table_insert (pulse->priv->sinks, GUINT_TO_POINTER (info->index), - stream); + g_object_ref (stream)); if (device != NULL) { pulse_device_add_stream (device, stream); @@ -932,7 +932,7 @@ on_connection_source_info (PulseConnection *connection, free_list_streams (pulse); g_hash_table_insert (pulse->priv->sources, GUINT_TO_POINTER (info->index), - stream); + g_object_ref (stream)); if (device != NULL) { pulse_device_add_stream (device, stream); @@ -1051,7 +1051,7 @@ on_connection_ext_stream_info (PulseConnection *connection, free_list_ext_streams (pulse); g_hash_table_insert (pulse->priv->ext_streams, g_strdup (info->name), - ext); + g_object_ref (ext)); g_signal_emit_by_name (G_OBJECT (pulse), "stored-control-added", @@ -1091,7 +1091,7 @@ on_connection_ext_stream_loaded (PulseConnection *connection, PulseBackend *puls continue; free_list_ext_streams (pulse); - g_hash_table_remove (pulse->priv->ext_streams, (gconstpointer) name); + g_hash_table_iter_remove (&iter); g_signal_emit_by_name (G_OBJECT (pulse), "stored-control-removed", diff --git a/backends/pulse/pulse-device.c b/backends/pulse/pulse-device.c index 5403712..9f33132 100644 --- a/backends/pulse/pulse-device.c +++ b/backends/pulse/pulse-device.c @@ -281,7 +281,10 @@ pulse_device_add_stream (PulseDevice *device, PulseStream *stream) free_list_streams (device); - g_hash_table_insert (device->priv->streams, g_strdup (name), stream); + g_hash_table_insert (device->priv->streams, + g_strdup (name), + g_object_ref (stream)); + g_signal_emit_by_name (G_OBJECT (device), "stream-added", name); @@ -382,7 +385,9 @@ pulse_device_load (PulseDevice *device, const pa_card_info *info) icon, info->ports[i]->priority); - g_hash_table_insert (device->priv->ports, g_strdup (name), port); + g_hash_table_insert (device->priv->ports, + g_strdup (name), + g_object_ref (port)); } #endif diff --git a/backends/pulse/pulse-ext-stream.c b/backends/pulse/pulse-ext-stream.c index 3e7490a..5d2ec75 100644 --- a/backends/pulse/pulse-ext-stream.c +++ b/backends/pulse/pulse-ext-stream.c @@ -274,7 +274,7 @@ pulse_ext_stream_set_stream (MateMixerStreamControl *mmsc, MateMixerStream *mms) g_return_val_if_fail (PULSE_IS_EXT_STREAM (mmsc), FALSE); g_return_val_if_fail (mms == NULL || PULSE_IS_STREAM (mms), FALSE); - fill_ext_stream_restore_info (PULSE_STREAM_CONTROL (mms), &info); + fill_ext_stream_restore_info (PULSE_STREAM_CONTROL (mmsc), &info); if (mms != NULL) info.device = mate_mixer_stream_get_name (mms); @@ -331,10 +331,16 @@ fill_ext_stream_restore_info (PulseStreamControl *control, info->mute = mate_mixer_stream_control_get_mute (mmsc); map = pulse_stream_control_get_channel_map (control); - info->channel_map = *map; + if G_LIKELY (map != NULL) + info->channel_map = *map; + else + pa_channel_map_init (&info->channel_map); cvolume = pulse_stream_control_get_cvolume (control); - info->volume = *cvolume; + if G_LIKELY (cvolume != NULL) + info->volume = *cvolume; + else + pa_cvolume_init (&info->volume); stream = mate_mixer_stream_control_get_stream (mmsc); if (stream != NULL) diff --git a/backends/pulse/pulse-port-switch.c b/backends/pulse/pulse-port-switch.c index 08f1543..db06a7c 100644 --- a/backends/pulse/pulse-port-switch.c +++ b/backends/pulse/pulse-port-switch.c @@ -53,7 +53,6 @@ static void pulse_port_switch_set_property (GObject *object, GParamSpec *pspec); static void pulse_port_switch_init (PulsePortSwitch *swtch); -static void pulse_port_switch_dispose (GObject *object); G_DEFINE_ABSTRACT_TYPE (PulsePortSwitch, pulse_port_switch, MATE_MIXER_TYPE_SWITCH) @@ -74,7 +73,6 @@ pulse_port_switch_class_init (PulsePortSwitchClass *klass) MateMixerSwitchClass *switch_class; object_class = G_OBJECT_CLASS (klass); - object_class->dispose = pulse_port_switch_dispose; object_class->get_property = pulse_port_switch_get_property; object_class->set_property = pulse_port_switch_set_property; @@ -129,7 +127,11 @@ pulse_port_switch_set_property (GObject *object, switch (param_id) { case PROP_STREAM: /* Construct-only object */ - swtch->priv->stream = g_value_dup_object (value); + swtch->priv->stream = g_value_get_object (value); + + if (swtch->priv->stream != NULL) + g_object_add_weak_pointer (G_OBJECT (swtch->priv->stream), + (gpointer *) &swtch->priv->stream); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec); @@ -145,18 +147,6 @@ pulse_port_switch_init (PulsePortSwitch *swtch) PulsePortSwitchPrivate); } -static void -pulse_port_switch_dispose (GObject *object) -{ - PulsePortSwitch *swtch; - - swtch = PULSE_PORT_SWITCH (object); - - g_clear_object (&swtch->priv->stream); - - G_OBJECT_CLASS (pulse_port_switch_parent_class)->dispose (object); -} - PulseStream * pulse_port_switch_get_stream (PulsePortSwitch *swtch) { diff --git a/backends/pulse/pulse-sink.c b/backends/pulse/pulse-sink.c index d2f0280..aedd5c8 100644 --- a/backends/pulse/pulse-sink.c +++ b/backends/pulse/pulse-sink.c @@ -188,7 +188,7 @@ pulse_sink_add_input (PulseSink *sink, const pa_sink_input_info *info) input = pulse_sink_input_new (sink, info); g_hash_table_insert (sink->priv->inputs, GINT_TO_POINTER (info->index), - input); + g_object_ref (input)); name = mate_mixer_stream_control_get_name (MATE_MIXER_STREAM_CONTROL (input)); g_signal_emit_by_name (G_OBJECT (sink), diff --git a/backends/pulse/pulse-source.c b/backends/pulse/pulse-source.c index 0d095a7..99c7432 100644 --- a/backends/pulse/pulse-source.c +++ b/backends/pulse/pulse-source.c @@ -183,7 +183,7 @@ pulse_source_add_output (PulseSource *source, const pa_source_output_info *info) output = pulse_source_output_new (source, info); g_hash_table_insert (source->priv->outputs, GINT_TO_POINTER (info->index), - output); + g_object_ref (output)); name = mate_mixer_stream_control_get_name (MATE_MIXER_STREAM_CONTROL (output)); g_signal_emit_by_name (G_OBJECT (source), diff --git a/libmatemixer/matemixer-stream-control.c b/libmatemixer/matemixer-stream-control.c index 80f9559..1137da8 100644 --- a/libmatemixer/matemixer-stream-control.c +++ b/libmatemixer/matemixer-stream-control.c @@ -78,7 +78,6 @@ static void mate_mixer_stream_control_set_property (GObject GParamSpec *pspec); static void mate_mixer_stream_control_init (MateMixerStreamControl *control); -static void mate_mixer_stream_control_dispose (GObject *object); static void mate_mixer_stream_control_finalize (GObject *object); G_DEFINE_ABSTRACT_TYPE (MateMixerStreamControl, mate_mixer_stream_control, G_TYPE_OBJECT) @@ -89,7 +88,6 @@ mate_mixer_stream_control_class_init (MateMixerStreamControlClass *klass) GObjectClass *object_class; object_class = G_OBJECT_CLASS (klass); - object_class->dispose = mate_mixer_stream_control_dispose; object_class->finalize = mate_mixer_stream_control_finalize; object_class->get_property = mate_mixer_stream_control_get_property; object_class->set_property = mate_mixer_stream_control_set_property; @@ -274,10 +272,9 @@ mate_mixer_stream_control_set_property (GObject *object, /* Construct-only object */ control->priv->stream = g_value_get_object (value); - if (control->priv->stream != NULL) { + if (control->priv->stream != NULL) g_object_add_weak_pointer (G_OBJECT (control->priv->stream), (gpointer *) &control->priv->stream); - } break; default: @@ -295,18 +292,6 @@ mate_mixer_stream_control_init (MateMixerStreamControl *control) } static void -mate_mixer_stream_control_dispose (GObject *object) -{ - MateMixerStreamControl *control; - - control = MATE_MIXER_STREAM_CONTROL (object); - - g_clear_object (&control->priv->stream); - - G_OBJECT_CLASS (mate_mixer_stream_control_parent_class)->dispose (object); -} - -static void mate_mixer_stream_control_finalize (GObject *object) { MateMixerStreamControl *control; @@ -923,11 +908,14 @@ _mate_mixer_stream_control_set_stream (MateMixerStreamControl *control, return; if (control->priv->stream != NULL) - g_object_unref (control->priv->stream); - - if (stream != NULL) - control->priv->stream = g_object_ref (stream); - else + g_object_remove_weak_pointer (G_OBJECT (control->priv->stream), + (gpointer *) &control->priv->stream); + + if (stream != NULL) { + control->priv->stream = stream; + g_object_add_weak_pointer (G_OBJECT (control->priv->stream), + (gpointer *) &control->priv->stream); + } else control->priv->stream = NULL; g_object_notify_by_pspec (G_OBJECT (control), properties[PROP_STREAM]); diff --git a/libmatemixer/matemixer-stream.c b/libmatemixer/matemixer-stream.c index 03902bd..aa1afd7 100644 --- a/libmatemixer/matemixer-stream.c +++ b/libmatemixer/matemixer-stream.c @@ -257,10 +257,9 @@ mate_mixer_stream_set_property (GObject *object, /* Construct-only object */ stream->priv->device = g_value_get_object (value); - if (stream->priv->device != NULL) { + if (stream->priv->device != NULL) g_object_add_weak_pointer (G_OBJECT (stream->priv->device), (gpointer *) &stream->priv->device); - } break; case PROP_DEFAULT_CONTROL: /* Construct-only object */ |