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;
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;
}

View File

@ -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;

View File

@ -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);