Add missing guards for inputs to functions

This commit is contained in:
Robert Ancell 2019-03-15 09:48:04 +13:00
parent b28ae07ae1
commit 3f457453f0
3 changed files with 30 additions and 1 deletions

View File

@ -235,6 +235,9 @@ gvc_mixer_control_lookup_device_from_stream (GvcMixerControl *control,
const GList *ports; const GList *ports;
GvcMixerUIDevice *ret; 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)) if (GVC_IS_MIXER_SOURCE (stream))
devices = g_hash_table_get_values (control->priv->ui_inputs); devices = g_hash_table_get_values (control->priv->ui_inputs);
else else
@ -534,6 +537,9 @@ gvc_mixer_control_change_profile_on_selected_device (GvcMixerControl *control,
GvcMixerCardProfile *current_profile; GvcMixerCardProfile *current_profile;
GvcMixerCard *card; 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); g_object_get (G_OBJECT (device), "card", &card, NULL);
current_profile = gvc_mixer_card_get_profile (card); current_profile = gvc_mixer_card_get_profile (card);
@ -588,6 +594,9 @@ gvc_mixer_control_change_output (GvcMixerControl *control,
const GvcMixerStreamPort *active_port; const GvcMixerStreamPort *active_port;
const gchar *output_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"); g_debug ("control change output");
stream = gvc_mixer_control_get_stream_from_device (control, 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 GvcMixerStreamPort *active_port;
const gchar *input_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); stream = gvc_mixer_control_get_stream_from_device (control, input);
if (stream == NULL) { if (stream == NULL) {
gvc_mixer_control_change_profile_on_selected_device (control, gvc_mixer_control_change_profile_on_selected_device (control,
@ -908,7 +920,7 @@ dec_outstanding (GvcMixerControl *control)
GvcMixerControlState GvcMixerControlState
gvc_mixer_control_get_state (GvcMixerControl *control) 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; return control->priv->state;
} }
@ -2184,6 +2196,8 @@ gvc_mixer_control_set_headset_port (GvcMixerControl *control,
guint id, guint id,
GvcHeadsetPortChoice choice) GvcHeadsetPortChoice choice)
{ {
g_return_if_fail (GVC_IS_MIXER_CONTROL (control));
#ifdef HAVE_ALSA #ifdef HAVE_ALSA
switch (choice) { switch (choice) {
case GVC_HEADSET_PORT_CHOICE_HEADPHONES: case GVC_HEADSET_PORT_CHOICE_HEADPHONES:
@ -3730,11 +3744,13 @@ gvc_mixer_control_new (const char *name)
gdouble gdouble
gvc_mixer_control_get_vol_max_norm (GvcMixerControl *control) 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; return (gdouble) PA_VOLUME_NORM;
} }
gdouble gdouble
gvc_mixer_control_get_vol_max_amplified (GvcMixerControl *control) 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; return (gdouble) PA_VOLUME_UI_MAX;
} }

View File

@ -839,6 +839,8 @@ gvc_mixer_stream_change_is_muted (GvcMixerStream *stream,
gboolean gboolean
gvc_mixer_stream_is_running (GvcMixerStream *stream) 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) if (stream->priv->change_volume_op == NULL)
return FALSE; return FALSE;

View File

@ -339,6 +339,9 @@ gvc_mixer_ui_device_get_matching_profile (GvcMixerUIDevice *device, const gchar
GList *l; GList *l;
gchar *result = NULL; 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) { for (l = device->priv->profiles; l != NULL; l = l->next) {
gchar *canonical_name; gchar *canonical_name;
GvcMixerCardProfile* p = l->data; GvcMixerCardProfile* p = l->data;
@ -424,6 +427,8 @@ gvc_mixer_ui_device_set_profiles (GvcMixerUIDevice *device,
GHashTable *added_profiles; GHashTable *added_profiles;
const gchar *skip_prefix = device->priv->type == UIDeviceInput ? "output:" : "input:"; 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)); g_debug ("Set profiles for '%s'", gvc_mixer_ui_device_get_description(device));
if (in_profiles == NULL) if (in_profiles == NULL)
@ -462,6 +467,9 @@ gvc_mixer_ui_device_get_best_profile (GvcMixerUIDevice *device,
const gchar *skip_prefix; const gchar *skip_prefix;
gchar *canonical_name_selected; 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) if (device->priv->type == UIDeviceInput)
skip_prefix = "output:"; skip_prefix = "output:";
else else
@ -657,6 +665,8 @@ gvc_mixer_ui_device_get_gicon (GvcMixerUIDevice *device)
{ {
const char *icon_name; 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); icon_name = gvc_mixer_ui_device_get_icon_name (device);
if (icon_name != NULL) if (icon_name != NULL)
@ -700,6 +710,7 @@ gvc_mixer_ui_device_set_user_preferred_profile (GvcMixerUIDevice *device,
const gchar *profile) const gchar *profile)
{ {
g_return_if_fail (GVC_IS_MIXER_UI_DEVICE (device)); g_return_if_fail (GVC_IS_MIXER_UI_DEVICE (device));
g_return_if_fail (profile != NULL);
g_free (device->priv->user_preferred_profile); g_free (device->priv->user_preferred_profile);
device->priv->user_preferred_profile = g_strdup (profile); device->priv->user_preferred_profile = g_strdup (profile);