diff options
author | Michal Ratajsky <[email protected]> | 2016-01-04 20:31:14 +0100 |
---|---|---|
committer | Michal Ratajsky <[email protected]> | 2016-01-04 20:31:14 +0100 |
commit | 9772797c31ebed2417b42a9389caae1b16847e86 (patch) | |
tree | 0257271d6f8387ce89984bf8341b11186381c8d5 /backends/alsa | |
parent | d32ca3f420d036cd750fc1aad7f95da40559cc5d (diff) | |
download | libmatemixer-9772797c31ebed2417b42a9389caae1b16847e86.tar.bz2 libmatemixer-9772797c31ebed2417b42a9389caae1b16847e86.tar.xz |
Improve error checking in many places
Diffstat (limited to 'backends/alsa')
-rw-r--r-- | backends/alsa/alsa-stream-control.c | 8 | ||||
-rw-r--r-- | backends/alsa/alsa-stream-input-control.c | 16 | ||||
-rw-r--r-- | backends/alsa/alsa-stream-output-control.c | 15 | ||||
-rw-r--r-- | backends/alsa/alsa-stream.c | 8 | ||||
-rw-r--r-- | backends/alsa/alsa-switch-option.c | 3 | ||||
-rw-r--r-- | backends/alsa/alsa-toggle.c | 8 |
6 files changed, 47 insertions, 11 deletions
diff --git a/backends/alsa/alsa-stream-control.c b/backends/alsa/alsa-stream-control.c index 6e09a09..5fd643e 100644 --- a/backends/alsa/alsa-stream-control.c +++ b/backends/alsa/alsa-stream-control.c @@ -649,24 +649,32 @@ alsa_stream_control_set_fade (MateMixerStreamControl *mmsc, gfloat fade) static guint alsa_stream_control_get_min_volume (MateMixerStreamControl *mmsc) { + g_return_val_if_fail (ALSA_IS_STREAM_CONTROL (mmsc), 0); + return ALSA_STREAM_CONTROL (mmsc)->priv->data.min; } static guint alsa_stream_control_get_max_volume (MateMixerStreamControl *mmsc) { + g_return_val_if_fail (ALSA_IS_STREAM_CONTROL (mmsc), 0); + return ALSA_STREAM_CONTROL (mmsc)->priv->data.max; } static guint alsa_stream_control_get_normal_volume (MateMixerStreamControl *mmsc) { + g_return_val_if_fail (ALSA_IS_STREAM_CONTROL (mmsc), 0); + return ALSA_STREAM_CONTROL (mmsc)->priv->data.max; } static guint alsa_stream_control_get_base_volume (MateMixerStreamControl *mmsc) { + g_return_val_if_fail (ALSA_IS_STREAM_CONTROL (mmsc), 0); + return ALSA_STREAM_CONTROL (mmsc)->priv->data.max; } diff --git a/backends/alsa/alsa-stream-input-control.c b/backends/alsa/alsa-stream-input-control.c index 1954008..5f5e90e 100644 --- a/backends/alsa/alsa-stream-input-control.c +++ b/backends/alsa/alsa-stream-input-control.c @@ -25,6 +25,7 @@ #include "alsa-compat.h" #include "alsa-constants.h" #include "alsa-element.h" +#include "alsa-stream.h" #include "alsa-stream-control.h" #include "alsa-stream-input-control.h" @@ -82,6 +83,11 @@ alsa_stream_input_control_new (const gchar *name, MateMixerStreamControlRole role, AlsaStream *stream) { + + g_return_val_if_fail (name != NULL, NULL); + g_return_val_if_fail (label != NULL, NULL); + g_return_val_if_fail (ALSA_IS_STREAM (stream), NULL); + return g_object_new (ALSA_TYPE_STREAM_INPUT_CONTROL, "name", name, "label", label, @@ -133,7 +139,7 @@ alsa_stream_input_control_set_mute (AlsaStreamControl *control, gboolean mute) snd_mixer_elem_t *el; gint ret; - g_return_val_if_fail (ALSA_IS_STREAM_CONTROL (control), FALSE); + g_return_val_if_fail (ALSA_IS_STREAM_INPUT_CONTROL (control), FALSE); el = alsa_element_get_snd_element (ALSA_ELEMENT (control)); if G_UNLIKELY (el == NULL) @@ -154,7 +160,7 @@ alsa_stream_input_control_set_volume (AlsaStreamControl *control, guint volume) snd_mixer_elem_t *el; gint ret; - g_return_val_if_fail (ALSA_IS_STREAM_CONTROL (control), FALSE); + g_return_val_if_fail (ALSA_IS_STREAM_INPUT_CONTROL (control), FALSE); el = alsa_element_get_snd_element (ALSA_ELEMENT (control)); if G_UNLIKELY (el == NULL) @@ -177,7 +183,7 @@ alsa_stream_input_control_set_channel_volume (AlsaStreamControl *contr snd_mixer_elem_t *el; gint ret; - g_return_val_if_fail (ALSA_IS_STREAM_CONTROL (control), FALSE); + g_return_val_if_fail (ALSA_IS_STREAM_INPUT_CONTROL (control), FALSE); el = alsa_element_get_snd_element (ALSA_ELEMENT (control)); if G_UNLIKELY (el == NULL) @@ -202,7 +208,7 @@ alsa_stream_input_control_get_volume_from_decibel (AlsaStreamControl *control, glong value; gint ret; - g_return_val_if_fail (ALSA_IS_STREAM_CONTROL (control), FALSE); + g_return_val_if_fail (ALSA_IS_STREAM_INPUT_CONTROL (control), FALSE); el = alsa_element_get_snd_element (ALSA_ELEMENT (control)); if G_UNLIKELY (el == NULL) @@ -231,7 +237,7 @@ alsa_stream_input_control_get_decibel_from_volume (AlsaStreamControl *control, glong value; gint ret; - g_return_val_if_fail (ALSA_IS_STREAM_CONTROL (control), FALSE); + g_return_val_if_fail (ALSA_IS_STREAM_INPUT_CONTROL (control), FALSE); el = alsa_element_get_snd_element (ALSA_ELEMENT (control)); if G_UNLIKELY (el == NULL) diff --git a/backends/alsa/alsa-stream-output-control.c b/backends/alsa/alsa-stream-output-control.c index 5b6a1eb..9d7813d 100644 --- a/backends/alsa/alsa-stream-output-control.c +++ b/backends/alsa/alsa-stream-output-control.c @@ -25,6 +25,7 @@ #include "alsa-compat.h" #include "alsa-constants.h" #include "alsa-element.h" +#include "alsa-stream.h" #include "alsa-stream-control.h" #include "alsa-stream-output-control.h" @@ -82,6 +83,10 @@ alsa_stream_output_control_new (const gchar *name, MateMixerStreamControlRole role, AlsaStream *stream) { + g_return_val_if_fail (name != NULL, NULL); + g_return_val_if_fail (label != NULL, NULL); + g_return_val_if_fail (ALSA_IS_STREAM (stream), NULL); + return g_object_new (ALSA_TYPE_STREAM_OUTPUT_CONTROL, "name", name, "label", label, @@ -133,7 +138,7 @@ alsa_stream_output_control_set_mute (AlsaStreamControl *control, gboolean mute) snd_mixer_elem_t *el; gint ret; - g_return_val_if_fail (ALSA_IS_STREAM_CONTROL (control), FALSE); + g_return_val_if_fail (ALSA_IS_STREAM_OUTPUT_CONTROL (control), FALSE); el = alsa_element_get_snd_element (ALSA_ELEMENT (control)); if G_UNLIKELY (el == NULL) @@ -154,7 +159,7 @@ alsa_stream_output_control_set_volume (AlsaStreamControl *control, guint volume) snd_mixer_elem_t *el; gint ret; - g_return_val_if_fail (ALSA_IS_STREAM_CONTROL (control), FALSE); + g_return_val_if_fail (ALSA_IS_STREAM_OUTPUT_CONTROL (control), FALSE); el = alsa_element_get_snd_element (ALSA_ELEMENT (control)); if G_UNLIKELY (el == NULL) @@ -177,7 +182,7 @@ alsa_stream_output_control_set_channel_volume (AlsaStreamControl *cont snd_mixer_elem_t *el; gint ret; - g_return_val_if_fail (ALSA_IS_STREAM_CONTROL (control), FALSE); + g_return_val_if_fail (ALSA_IS_STREAM_OUTPUT_CONTROL (control), FALSE); el = alsa_element_get_snd_element (ALSA_ELEMENT (control)); if G_UNLIKELY (el == NULL) @@ -202,7 +207,7 @@ alsa_stream_output_control_get_volume_from_decibel (AlsaStreamControl *control, glong value; gint ret; - g_return_val_if_fail (ALSA_IS_STREAM_CONTROL (control), FALSE); + g_return_val_if_fail (ALSA_IS_STREAM_OUTPUT_CONTROL (control), FALSE); el = alsa_element_get_snd_element (ALSA_ELEMENT (control)); if G_UNLIKELY (el == NULL) @@ -231,7 +236,7 @@ alsa_stream_output_control_get_decibel_from_volume (AlsaStreamControl *control, glong value; gint ret; - g_return_val_if_fail (ALSA_IS_STREAM_CONTROL (control), FALSE); + g_return_val_if_fail (ALSA_IS_STREAM_OUTPUT_CONTROL (control), FALSE); el = alsa_element_get_snd_element (ALSA_ELEMENT (control)); if G_UNLIKELY (el == NULL) diff --git a/backends/alsa/alsa-stream.c b/backends/alsa/alsa-stream.c index bce66ec..fc72f65 100644 --- a/backends/alsa/alsa-stream.c +++ b/backends/alsa/alsa-stream.c @@ -20,6 +20,7 @@ #include <libmatemixer/matemixer.h> #include <libmatemixer/matemixer-private.h> +#include "alsa-device.h" #include "alsa-element.h" #include "alsa-stream.h" #include "alsa-stream-control.h" @@ -94,7 +95,12 @@ alsa_stream_new (const gchar *name, MateMixerDevice *device, MateMixerDirection direction) { - const gchar *label = mate_mixer_device_get_label (device); + const gchar *label; + + g_return_val_if_fail (name != NULL, NULL); + g_return_val_if_fail (ALSA_IS_DEVICE (device), NULL); + + label = mate_mixer_device_get_label (device); return g_object_new (ALSA_TYPE_STREAM, "name", name, diff --git a/backends/alsa/alsa-switch-option.c b/backends/alsa/alsa-switch-option.c index 1800df2..81326ce 100644 --- a/backends/alsa/alsa-switch-option.c +++ b/backends/alsa/alsa-switch-option.c @@ -54,6 +54,9 @@ alsa_switch_option_new (const gchar *name, { AlsaSwitchOption *option; + g_return_val_if_fail (name != NULL, NULL); + g_return_val_if_fail (label != NULL, NULL); + option = g_object_new (ALSA_TYPE_SWITCH_OPTION, "name", name, "label", label, diff --git a/backends/alsa/alsa-toggle.c b/backends/alsa/alsa-toggle.c index 1fee1c1..d143236 100644 --- a/backends/alsa/alsa-toggle.c +++ b/backends/alsa/alsa-toggle.c @@ -89,6 +89,12 @@ alsa_toggle_new (AlsaStream *stream, { AlsaToggle *toggle; + g_return_val_if_fail (ALSA_IS_STREAM (stream), NULL); + g_return_val_if_fail (name != NULL, NULL); + g_return_val_if_fail (label != NULL, NULL); + g_return_val_if_fail (ALSA_IS_SWITCH_OPTION (on), NULL); + g_return_val_if_fail (ALSA_IS_SWITCH_OPTION (off), NULL); + toggle = g_object_new (ALSA_TYPE_TOGGLE, "name", name, "label", label, @@ -166,6 +172,8 @@ alsa_toggle_load (AlsaElement *element) gint ret; snd_mixer_selem_channel_id_t c; + g_return_val_if_fail (ALSA_IS_TOGGLE (element), FALSE); + toggle = ALSA_TOGGLE (element); if G_UNLIKELY (toggle->priv->element == NULL) |