diff options
author | Michal Ratajsky <[email protected]> | 2014-07-20 09:30:38 +0200 |
---|---|---|
committer | Michal Ratajsky <[email protected]> | 2014-07-20 09:30:38 +0200 |
commit | c965e0de05231c7da6c11d5cc1a8d97b6d156f1b (patch) | |
tree | 0365fd57bbbff9a8bec7afbda5b2e34c55281162 | |
parent | 1c842063e1f7bf6803655ac193ac28704c4dc0c2 (diff) | |
download | libmatemixer-c965e0de05231c7da6c11d5cc1a8d97b6d156f1b.tar.bz2 libmatemixer-c965e0de05231c7da6c11d5cc1a8d97b6d156f1b.tar.xz |
Fail when an unavailable module is requested
-rw-r--r-- | libmatemixer/matemixer-control.c | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/libmatemixer/matemixer-control.c b/libmatemixer/matemixer-control.c index b501f1e..45316d5 100644 --- a/libmatemixer/matemixer-control.c +++ b/libmatemixer/matemixer-control.c @@ -750,15 +750,15 @@ mate_mixer_control_open (MateMixerControl *control) module = NULL; modules = modules->next; } + if (module == NULL) { + /* The selected backend is not available */ + change_state (control, MATE_MIXER_STATE_FAILED); + return FALSE; + } } else { /* The highest priority module is on the top of the list */ module = MATE_MIXER_BACKEND_MODULE (modules->data); } - if (module == NULL) { - /* Most likely the selected backend is not installed */ - change_state (control, MATE_MIXER_STATE_FAILED); - return FALSE; - } if (info == NULL) info = mate_mixer_backend_module_get_info (module); @@ -768,6 +768,8 @@ mate_mixer_control_open (MateMixerControl *control) mate_mixer_backend_set_data (control->priv->backend, &control->priv->backend_data); + g_debug ("Trying to open backend %s", info->name); + /* This transitional state is always present, it will change to MATE_MIXER_STATE_READY * or MATE_MIXER_STATE_FAILED either instantly or asynchronously */ change_state (control, MATE_MIXER_STATE_CONNECTING); @@ -1298,9 +1300,10 @@ on_backend_default_output_notify (MateMixerBackend *backend, static gboolean try_next_backend (MateMixerControl *control) { - const GList *modules; - MateMixerBackendModule *module = NULL; - MateMixerState state; + MateMixerBackendModule *module = NULL; + MateMixerState state; + const GList *modules; + const MateMixerBackendInfo *info = NULL; modules = mate_mixer_get_modules (); @@ -1322,12 +1325,15 @@ try_next_backend (MateMixerControl *control) return FALSE; } + info = mate_mixer_backend_module_get_info (module); + control->priv->module = g_object_ref (module); - control->priv->backend = - g_object_new (mate_mixer_backend_module_get_info (module)->g_type, NULL); + control->priv->backend = g_object_new (info->g_type, NULL); mate_mixer_backend_set_data (control->priv->backend, &control->priv->backend_data); + g_debug ("Trying to open backend %s", info->name); + /* Try to open this backend and in case of failure keep trying until we find * one that works or reach the end of the list */ if (mate_mixer_backend_open (control->priv->backend) == FALSE) |