summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backends/alsa/alsa-backend.c10
-rw-r--r--backends/alsa/alsa-device.c2
-rw-r--r--backends/alsa/alsa-toggle.c4
-rw-r--r--backends/oss/oss-backend.c1
-rw-r--r--libmatemixer/matemixer-toggle.c45
5 files changed, 36 insertions, 26 deletions
diff --git a/backends/alsa/alsa-backend.c b/backends/alsa/alsa-backend.c
index 6bac691..2493d45 100644
--- a/backends/alsa/alsa-backend.c
+++ b/backends/alsa/alsa-backend.c
@@ -363,10 +363,12 @@ read_device (AlsaBackend *alsa, const gchar *card)
static void
add_device (AlsaBackend *alsa, AlsaDevice *device)
{
- alsa->priv->devices = g_list_insert_sorted_with_data (alsa->priv->devices,
- device,
- (GCompareDataFunc) compare_devices,
- NULL);
+ /* Takes reference of device */
+ alsa->priv->devices =
+ g_list_insert_sorted_with_data (alsa->priv->devices,
+ device,
+ (GCompareDataFunc) compare_devices,
+ NULL);
/* Keep track of device identifiers */
g_hash_table_add (alsa->priv->devices_ids, g_strdup (ALSA_DEVICE_GET_ID (device)));
diff --git a/backends/alsa/alsa-device.c b/backends/alsa/alsa-device.c
index f7f705e..03dd7c0 100644
--- a/backends/alsa/alsa-device.c
+++ b/backends/alsa/alsa-device.c
@@ -230,7 +230,7 @@ alsa_device_finalize (GObject *object)
close_mixer (device);
- G_OBJECT_CLASS (alsa_device_parent_class)->dispose (object);
+ G_OBJECT_CLASS (alsa_device_parent_class)->finalize (object);
}
AlsaDevice *
diff --git a/backends/alsa/alsa-toggle.c b/backends/alsa/alsa-toggle.c
index a7958c9..c843985 100644
--- a/backends/alsa/alsa-toggle.c
+++ b/backends/alsa/alsa-toggle.c
@@ -92,8 +92,8 @@ alsa_toggle_new (const gchar *name,
"label", label,
"flags", MATE_MIXER_SWITCH_TOGGLE,
"role", role,
- "state-option-on", on,
- "state-option-off", off,
+ "on-state-option", on,
+ "off-state-option", off,
NULL);
toggle->priv->type = type;
diff --git a/backends/oss/oss-backend.c b/backends/oss/oss-backend.c
index 23d265b..bf9a694 100644
--- a/backends/oss/oss-backend.c
+++ b/backends/oss/oss-backend.c
@@ -461,6 +461,7 @@ read_device_label_sndstat (OssBackend *oss,
static void
add_device (OssBackend *oss, OssDevice *device)
{
+ /* Takes reference of device */
oss->priv->devices =
g_list_insert_sorted_with_data (oss->priv->devices,
device,
diff --git a/libmatemixer/matemixer-toggle.c b/libmatemixer/matemixer-toggle.c
index 43bb8ce..869807a 100644
--- a/libmatemixer/matemixer-toggle.c
+++ b/libmatemixer/matemixer-toggle.c
@@ -15,7 +15,6 @@
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
-#include <string.h>
#include <glib.h>
#include <glib-object.h>
@@ -38,8 +37,8 @@ struct _MateMixerTogglePrivate
enum {
PROP_0,
PROP_STATE,
- PROP_STATE_OPTION_ON,
- PROP_STATE_OPTION_OFF,
+ PROP_ON_STATE_OPTION,
+ PROP_OFF_STATE_OPTION,
N_PROPERTIES
};
@@ -89,8 +88,8 @@ mate_mixer_toggle_class_init (MateMixerToggleClass *klass)
G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS);
- properties[PROP_STATE_OPTION_ON] =
- g_param_spec_object ("state-option-on",
+ properties[PROP_ON_STATE_OPTION] =
+ g_param_spec_object ("on-state-option",
"State option for on",
"Option corresponding to the 'on' value of the toggle",
MATE_MIXER_TYPE_SWITCH_OPTION,
@@ -98,8 +97,8 @@ mate_mixer_toggle_class_init (MateMixerToggleClass *klass)
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS);
- properties[PROP_STATE_OPTION_OFF] =
- g_param_spec_object ("state-option-off",
+ properties[PROP_OFF_STATE_OPTION] =
+ g_param_spec_object ("off-state-option",
"State option for off",
"Option corresponding to the 'off' value of the toggle",
MATE_MIXER_TYPE_SWITCH_OPTION,
@@ -126,10 +125,10 @@ mate_mixer_toggle_get_property (GObject *object,
case PROP_STATE:
g_value_set_boolean (value, mate_mixer_toggle_get_state (toggle));
break;
- case PROP_STATE_OPTION_ON:
+ case PROP_ON_STATE_OPTION:
g_value_set_object (value, toggle->priv->on);
break;
- case PROP_STATE_OPTION_OFF:
+ case PROP_OFF_STATE_OPTION:
g_value_set_object (value, toggle->priv->off);
break;
@@ -150,11 +149,11 @@ mate_mixer_toggle_set_property (GObject *object,
toggle = MATE_MIXER_TOGGLE (object);
switch (param_id) {
- case PROP_STATE_OPTION_ON:
+ case PROP_ON_STATE_OPTION:
/* Construct-only object */
toggle->priv->on = g_value_dup_object (value);
break;
- case PROP_STATE_OPTION_OFF:
+ case PROP_OFF_STATE_OPTION:
/* Construct-only object */
toggle->priv->off = g_value_dup_object (value);
break;
@@ -181,11 +180,10 @@ mate_mixer_toggle_dispose (GObject *object)
toggle = MATE_MIXER_TOGGLE (object);
if (toggle->priv->options != NULL) {
- g_list_free_full (toggle->priv->options, g_object_unref);
+ g_list_free (toggle->priv->options);
toggle->priv->options = NULL;
}
- /* FIXME: crashes on ALSA without the polling thread */
g_clear_object (&toggle->priv->on);
g_clear_object (&toggle->priv->off);
@@ -204,6 +202,9 @@ mate_mixer_toggle_get_state (MateMixerToggle *toggle)
g_return_val_if_fail (MATE_MIXER_IS_TOGGLE (toggle), FALSE);
active = mate_mixer_switch_get_active_option (MATE_MIXER_SWITCH (toggle));
+ if G_UNLIKELY (active == NULL)
+ return FALSE;
+
if (active == toggle->priv->on)
return TRUE;
else
@@ -243,6 +244,9 @@ mate_mixer_toggle_set_state (MateMixerToggle *toggle, gboolean state)
else
active = toggle->priv->off;
+ if G_UNLIKELY (active == NULL)
+ return FALSE;
+
return mate_mixer_switch_set_active_option (MATE_MIXER_SWITCH (toggle), active);
}
@@ -252,12 +256,13 @@ mate_mixer_toggle_get_option (MateMixerSwitch *swtch, const gchar *name)
MateMixerToggle *toggle;
g_return_val_if_fail (MATE_MIXER_IS_TOGGLE (swtch), NULL);
+ g_return_val_if_fail (name != NULL, NULL);
toggle = MATE_MIXER_TOGGLE (swtch);
- if (strcmp (name, mate_mixer_switch_option_get_name (toggle->priv->on)) == 0)
+ if (g_strcmp0 (name, mate_mixer_switch_option_get_name (toggle->priv->on)) == 0)
return toggle->priv->on;
- if (strcmp (name, mate_mixer_switch_option_get_name (toggle->priv->off)) == 0)
+ if (g_strcmp0 (name, mate_mixer_switch_option_get_name (toggle->priv->off)) == 0)
return toggle->priv->off;
return NULL;
@@ -273,10 +278,12 @@ mate_mixer_toggle_list_options (MateMixerSwitch *swtch)
toggle = MATE_MIXER_TOGGLE (swtch);
if (toggle->priv->options == NULL) {
- toggle->priv->options = g_list_prepend (toggle->priv->options,
- toggle->priv->off);
- toggle->priv->options = g_list_prepend (toggle->priv->options,
- toggle->priv->on);
+ if G_LIKELY (toggle->priv->off != NULL)
+ toggle->priv->options = g_list_prepend (toggle->priv->options,
+ toggle->priv->off);
+ if G_LIKELY (toggle->priv->on != NULL)
+ toggle->priv->options = g_list_prepend (toggle->priv->options,
+ toggle->priv->on);
}
return toggle->priv->options;
}