From 32049d16801b8c0b53448eba4b41df8765a94f84 Mon Sep 17 00:00:00 2001 From: Michal Ratajsky Date: Sun, 20 Jul 2014 10:35:28 +0200 Subject: Fix setting ext-stream parent and generalize it in PulseClientStream --- backends/pulse/pulse-client-stream.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'backends/pulse/pulse-client-stream.c') 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 #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; -- cgit v1.2.1