summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backends/pulse/pulse-client-stream.c17
-rw-r--r--backends/pulse/pulse-ext-stream.c41
-rw-r--r--backends/pulse/pulse-sink-input.c6
-rw-r--r--backends/pulse/pulse-source-output.c6
-rw-r--r--libmatemixer/matemixer-context.c28
5 files changed, 39 insertions, 59 deletions
diff --git a/backends/pulse/pulse-client-stream.c b/backends/pulse/pulse-client-stream.c
index d725146..b99c498 100644
--- a/backends/pulse/pulse-client-stream.c
+++ b/backends/pulse/pulse-client-stream.c
@@ -26,6 +26,8 @@
#include <pulse/pulseaudio.h>
#include "pulse-client-stream.h"
+#include "pulse-sink.h"
+#include "pulse-source.h"
#include "pulse-stream.h"
struct _PulseClientStreamPrivate
@@ -335,6 +337,7 @@ pulse_client_stream_get_parent (MateMixerClientStream *client)
static gboolean
pulse_client_stream_set_parent (MateMixerClientStream *client, MateMixerStream *parent)
{
+ MateMixerStreamFlags flags;
PulseClientStream *pclient;
PulseClientStreamClass *klass;
@@ -347,6 +350,20 @@ pulse_client_stream_set_parent (MateMixerClientStream *client, MateMixerStream *
if (pclient->priv->parent == parent)
return TRUE;
+ flags = mate_mixer_stream_get_flags (MATE_MIXER_STREAM (pclient));
+
+ /* Validate the parent stream */
+ if (flags & MATE_MIXER_STREAM_INPUT && !PULSE_IS_SOURCE (parent)) {
+ g_warning ("Could not change stream parent to %s: not a parent input stream",
+ mate_mixer_stream_get_name (MATE_MIXER_STREAM (parent)));
+ return FALSE;
+ } else if (flags & MATE_MIXER_STREAM_OUTPUT && !PULSE_IS_SINK (parent)) {
+ g_warning ("Could not change stream parent to %s: not a parent output stream",
+ mate_mixer_stream_get_name (MATE_MIXER_STREAM (parent)));
+ return FALSE;
+ }
+
+ /* Set the parent */
if (klass->set_parent (pclient, PULSE_STREAM (parent)) == FALSE)
return FALSE;
diff --git a/backends/pulse/pulse-ext-stream.c b/backends/pulse/pulse-ext-stream.c
index 96164e8..b00e967 100644
--- a/backends/pulse/pulse-ext-stream.c
+++ b/backends/pulse/pulse-ext-stream.c
@@ -30,8 +30,6 @@
#include "pulse-client-stream.h"
#include "pulse-ext-stream.h"
#include "pulse-helpers.h"
-#include "pulse-sink.h"
-#include "pulse-source.h"
#include "pulse-stream.h"
static void pulse_ext_stream_class_init (PulseExtStreamClass *klass);
@@ -189,16 +187,10 @@ pulse_ext_stream_set_mute (PulseStream *pstream, gboolean mute)
info.mute = mute;
map = pulse_stream_get_channel_map (pstream);
- if (map != NULL)
- info.channel_map = *map;
- else
- pa_channel_map_init (&info.channel_map);
+ info.channel_map = *map;
cvolume = pulse_stream_get_cvolume (pstream);
- if (cvolume != NULL)
- info.volume = *cvolume;
- else
- pa_cvolume_init (&info.volume);
+ info.volume = *cvolume;
parent = mate_mixer_client_stream_get_parent (MATE_MIXER_CLIENT_STREAM (pstream));
if (parent != NULL)
@@ -223,10 +215,7 @@ pulse_ext_stream_set_volume (PulseStream *pstream, pa_cvolume *cvolume)
info.mute = mate_mixer_stream_get_mute (MATE_MIXER_STREAM (pstream));
map = pulse_stream_get_channel_map (pstream);
- if (map != NULL)
- info.channel_map = *map;
- else
- pa_channel_map_init (&info.channel_map);
+ info.channel_map = *map;
parent = mate_mixer_client_stream_get_parent (MATE_MIXER_CLIENT_STREAM (pstream));
if (parent != NULL)
@@ -242,7 +231,6 @@ pulse_ext_stream_set_volume (PulseStream *pstream, pa_cvolume *cvolume)
static gboolean
pulse_ext_stream_set_parent (PulseClientStream *pclient, PulseStream *parent)
{
- MateMixerStreamFlags flags;
PulseStream *pstream;
const pa_channel_map *map;
const pa_cvolume *cvolume;
@@ -251,35 +239,16 @@ pulse_ext_stream_set_parent (PulseClientStream *pclient, PulseStream *parent)
g_return_val_if_fail (PULSE_IS_EXT_STREAM (pclient), FALSE);
g_return_val_if_fail (PULSE_IS_STREAM (parent), FALSE);
- flags = mate_mixer_stream_get_flags (MATE_MIXER_STREAM (pclient));
-
- /* Validate the parent stream */
- if (flags & MATE_MIXER_STREAM_INPUT && !PULSE_IS_SOURCE (parent)) {
- g_warning ("Could not change stream parent to %s: not a parent input stream",
- mate_mixer_stream_get_name (MATE_MIXER_STREAM (parent)));
- return FALSE;
- } else if (!PULSE_IS_SINK (parent)) {
- g_warning ("Could not change stream parent to %s: not a parent output stream",
- mate_mixer_stream_get_name (MATE_MIXER_STREAM (parent)));
- return FALSE;
- }
-
pstream = PULSE_STREAM (pclient);
info.name = mate_mixer_stream_get_name (MATE_MIXER_STREAM (pstream));
info.mute = mate_mixer_stream_get_mute (MATE_MIXER_STREAM (pstream));
map = pulse_stream_get_channel_map (pstream);
- if (map != NULL)
- info.channel_map = *map;
- else
- pa_channel_map_init (&info.channel_map);
+ info.channel_map = *map;
cvolume = pulse_stream_get_cvolume (pstream);
- if (cvolume != NULL)
- info.volume = *cvolume;
- else
- pa_cvolume_init (&info.volume);
+ info.volume = *cvolume;
info.device = mate_mixer_stream_get_name (MATE_MIXER_STREAM (parent));
diff --git a/backends/pulse/pulse-sink-input.c b/backends/pulse/pulse-sink-input.c
index 54cd3b3..1d5f9c2 100644
--- a/backends/pulse/pulse-sink-input.c
+++ b/backends/pulse/pulse-sink-input.c
@@ -253,12 +253,6 @@ pulse_sink_input_set_parent (PulseClientStream *pclient, PulseStream *parent)
g_return_val_if_fail (PULSE_IS_SINK_INPUT (pclient), FALSE);
- if (!PULSE_IS_SINK (parent)) {
- g_warning ("Could not change stream parent to %s: not a parent output stream",
- mate_mixer_stream_get_name (MATE_MIXER_STREAM (parent)));
- return FALSE;
- }
-
pstream = PULSE_STREAM (pclient);
return pulse_connection_move_sink_input (pulse_stream_get_connection (pstream),
diff --git a/backends/pulse/pulse-source-output.c b/backends/pulse/pulse-source-output.c
index c46b65b..6cbd888 100644
--- a/backends/pulse/pulse-source-output.c
+++ b/backends/pulse/pulse-source-output.c
@@ -243,12 +243,6 @@ pulse_source_output_set_parent (PulseClientStream *pclient, PulseStream *parent)
g_return_val_if_fail (PULSE_IS_SOURCE_OUTPUT (pclient), FALSE);
- if (!PULSE_IS_SOURCE (parent)) {
- g_warning ("Could not change stream parent to %s: not a parent input stream",
- mate_mixer_stream_get_name (MATE_MIXER_STREAM (parent)));
- return FALSE;
- }
-
pstream = PULSE_STREAM (pclient);
return pulse_connection_move_sink_input (pulse_stream_get_connection (pstream),
diff --git a/libmatemixer/matemixer-context.c b/libmatemixer/matemixer-context.c
index 5bdc7a8..ecd617f 100644
--- a/libmatemixer/matemixer-context.c
+++ b/libmatemixer/matemixer-context.c
@@ -742,15 +742,15 @@ mate_mixer_context_open (MateMixerContext *context)
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 (context, MATE_MIXER_STATE_FAILED);
- return FALSE;
- }
if (info == NULL)
info = mate_mixer_backend_module_get_info (module);
@@ -760,6 +760,8 @@ mate_mixer_context_open (MateMixerContext *context)
mate_mixer_backend_set_data (context->priv->backend, &context->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 (context, MATE_MIXER_STATE_CONNECTING);
@@ -1269,9 +1271,10 @@ on_backend_default_output_stream_notify (MateMixerBackend *backend,
static gboolean
try_next_backend (MateMixerContext *context)
{
- 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 ();
@@ -1293,12 +1296,15 @@ try_next_backend (MateMixerContext *context)
return FALSE;
}
- context->priv->module = g_object_ref (module);
- context->priv->backend =
- g_object_new (mate_mixer_backend_module_get_info (module)->g_type, NULL);
+ info = mate_mixer_backend_module_get_info (module);
+
+ control->priv->module = g_object_ref (module);
+ control->priv->backend = g_object_new (info->g_type, NULL);
mate_mixer_backend_set_data (context->priv->backend, &context->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 (context->priv->backend) == FALSE)