summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Ancell <robert.ancell@canonical.com>2019-03-15 09:48:04 +1300
committerRobert Ancell <robert.ancell@canonical.com>2019-03-18 10:58:36 +1300
commit3f457453f031a2936ff267348107e6513be3aa27 (patch)
tree2b6cfd4d468b691a5a85a34d1a9c6b549349275e
parentb28ae07ae1a96a98d4363fd8eacb69ab9bb6a806 (diff)
downloadlibgnome-volume-control-3f457453f031a2936ff267348107e6513be3aa27.tar.gz
Add missing guards for inputs to functions
-rw-r--r--gvc-mixer-control.c18
-rw-r--r--gvc-mixer-stream.c2
-rw-r--r--gvc-mixer-ui-device.c11
3 files changed, 30 insertions, 1 deletions
diff --git a/gvc-mixer-control.c b/gvc-mixer-control.c
index de1c574..f16829d 100644
--- a/gvc-mixer-control.c
+++ b/gvc-mixer-control.c
@@ -235,6 +235,9 @@ gvc_mixer_control_lookup_device_from_stream (GvcMixerControl *control,
const GList *ports;
GvcMixerUIDevice *ret;
+ g_return_val_if_fail (GVC_IS_MIXER_CONTROL (control), NULL);
+ g_return_val_if_fail (GVC_IS_MIXER_STREAM (stream), NULL);
+
if (GVC_IS_MIXER_SOURCE (stream))
devices = g_hash_table_get_values (control->priv->ui_inputs);
else
@@ -534,6 +537,9 @@ gvc_mixer_control_change_profile_on_selected_device (GvcMixerControl *control,
GvcMixerCardProfile *current_profile;
GvcMixerCard *card;
+ g_return_val_if_fail (GVC_IS_MIXER_CONTROL (control), FALSE);
+ g_return_val_if_fail (GVC_IS_MIXER_UI_DEVICE (device), FALSE);
+
g_object_get (G_OBJECT (device), "card", &card, NULL);
current_profile = gvc_mixer_card_get_profile (card);
@@ -588,6 +594,9 @@ gvc_mixer_control_change_output (GvcMixerControl *control,
const GvcMixerStreamPort *active_port;
const gchar *output_port;
+ g_return_if_fail (GVC_IS_MIXER_CONTROL (control));
+ g_return_if_fail (GVC_IS_MIXER_UI_DEVICE (output));
+
g_debug ("control change output");
stream = gvc_mixer_control_get_stream_from_device (control, output);
@@ -677,6 +686,9 @@ gvc_mixer_control_change_input (GvcMixerControl *control,
const GvcMixerStreamPort *active_port;
const gchar *input_port;
+ g_return_if_fail (GVC_IS_MIXER_CONTROL (control));
+ g_return_if_fail (GVC_IS_MIXER_UI_DEVICE (input));
+
stream = gvc_mixer_control_get_stream_from_device (control, input);
if (stream == NULL) {
gvc_mixer_control_change_profile_on_selected_device (control,
@@ -908,7 +920,7 @@ dec_outstanding (GvcMixerControl *control)
GvcMixerControlState
gvc_mixer_control_get_state (GvcMixerControl *control)
{
- g_return_val_if_fail (GVC_IS_MIXER_CONTROL (control), FALSE);
+ g_return_val_if_fail (GVC_IS_MIXER_CONTROL (control), GVC_STATE_CLOSED);
return control->priv->state;
}
@@ -2184,6 +2196,8 @@ gvc_mixer_control_set_headset_port (GvcMixerControl *control,
guint id,
GvcHeadsetPortChoice choice)
{
+ g_return_if_fail (GVC_IS_MIXER_CONTROL (control));
+
#ifdef HAVE_ALSA
switch (choice) {
case GVC_HEADSET_PORT_CHOICE_HEADPHONES:
@@ -3730,11 +3744,13 @@ gvc_mixer_control_new (const char *name)
gdouble
gvc_mixer_control_get_vol_max_norm (GvcMixerControl *control)
{
+ g_return_val_if_fail (GVC_IS_MIXER_CONTROL (control), 0);
return (gdouble) PA_VOLUME_NORM;
}
gdouble
gvc_mixer_control_get_vol_max_amplified (GvcMixerControl *control)
{
+ g_return_val_if_fail (GVC_IS_MIXER_CONTROL (control), 0);
return (gdouble) PA_VOLUME_UI_MAX;
}
diff --git a/gvc-mixer-stream.c b/gvc-mixer-stream.c
index b136a14..af13ba3 100644
--- a/gvc-mixer-stream.c
+++ b/gvc-mixer-stream.c
@@ -839,6 +839,8 @@ gvc_mixer_stream_change_is_muted (GvcMixerStream *stream,
gboolean
gvc_mixer_stream_is_running (GvcMixerStream *stream)
{
+ g_return_val_if_fail (GVC_IS_MIXER_STREAM (stream), FALSE);
+
if (stream->priv->change_volume_op == NULL)
return FALSE;
diff --git a/gvc-mixer-ui-device.c b/gvc-mixer-ui-device.c
index 9b6addc..f7dd33e 100644
--- a/gvc-mixer-ui-device.c
+++ b/gvc-mixer-ui-device.c
@@ -339,6 +339,9 @@ gvc_mixer_ui_device_get_matching_profile (GvcMixerUIDevice *device, const gchar
GList *l;
gchar *result = NULL;
+ g_return_val_if_fail (GVC_IS_MIXER_UI_DEVICE (device), NULL);
+ g_return_val_if_fail (profile != NULL, NULL);
+
for (l = device->priv->profiles; l != NULL; l = l->next) {
gchar *canonical_name;
GvcMixerCardProfile* p = l->data;
@@ -424,6 +427,8 @@ gvc_mixer_ui_device_set_profiles (GvcMixerUIDevice *device,
GHashTable *added_profiles;
const gchar *skip_prefix = device->priv->type == UIDeviceInput ? "output:" : "input:";
+ g_return_if_fail (GVC_IS_MIXER_UI_DEVICE (device));
+
g_debug ("Set profiles for '%s'", gvc_mixer_ui_device_get_description(device));
if (in_profiles == NULL)
@@ -462,6 +467,9 @@ gvc_mixer_ui_device_get_best_profile (GvcMixerUIDevice *device,
const gchar *skip_prefix;
gchar *canonical_name_selected;
+ g_return_val_if_fail (GVC_IS_MIXER_UI_DEVICE (device), NULL);
+ g_return_val_if_fail (current != NULL, NULL);
+
if (device->priv->type == UIDeviceInput)
skip_prefix = "output:";
else
@@ -657,6 +665,8 @@ gvc_mixer_ui_device_get_gicon (GvcMixerUIDevice *device)
{
const char *icon_name;
+ g_return_val_if_fail (GVC_IS_MIXER_UI_DEVICE (device), NULL);
+
icon_name = gvc_mixer_ui_device_get_icon_name (device);
if (icon_name != NULL)
@@ -700,6 +710,7 @@ gvc_mixer_ui_device_set_user_preferred_profile (GvcMixerUIDevice *device,
const gchar *profile)
{
g_return_if_fail (GVC_IS_MIXER_UI_DEVICE (device));
+ g_return_if_fail (profile != NULL);
g_free (device->priv->user_preferred_profile);
device->priv->user_preferred_profile = g_strdup (profile);