summaryrefslogtreecommitdiff
path: root/backends/pulse/pulse-source-output.c
diff options
context:
space:
mode:
Diffstat (limited to 'backends/pulse/pulse-source-output.c')
-rw-r--r--backends/pulse/pulse-source-output.c86
1 files changed, 71 insertions, 15 deletions
diff --git a/backends/pulse/pulse-source-output.c b/backends/pulse/pulse-source-output.c
index b3552d5..5c5509b 100644
--- a/backends/pulse/pulse-source-output.c
+++ b/backends/pulse/pulse-source-output.c
@@ -30,11 +30,20 @@
#include "pulse-stream.h"
#include "pulse-stream-control.h"
+enum {
+ STREAM_CHANGED_BY_REQUEST,
+ N_SIGNALS
+};
+
+static guint signals[N_SIGNALS] = { 0, };
+
static void pulse_source_output_class_init (PulseSourceOutputClass *klass);
static void pulse_source_output_init (PulseSourceOutput *output);
G_DEFINE_TYPE (PulseSourceOutput, pulse_source_output, PULSE_TYPE_STREAM_CONTROL);
+static gboolean pulse_source_output_set_stream (MateMixerStreamControl *mmsc,
+ MateMixerStream *mms);
static guint pulse_source_output_get_max_volume (MateMixerStreamControl *mmsc);
static gboolean pulse_source_output_set_mute (PulseStreamControl *psc,
@@ -50,12 +59,25 @@ pulse_source_output_class_init (PulseSourceOutputClass *klass)
PulseStreamControlClass *control_class;
mmsc_class = MATE_MIXER_STREAM_CONTROL_CLASS (klass);
+ mmsc_class->set_stream = pulse_source_output_set_stream;
mmsc_class->get_max_volume = pulse_source_output_get_max_volume;
control_class = PULSE_STREAM_CONTROL_CLASS (klass);
control_class->set_mute = pulse_source_output_set_mute;
control_class->set_volume = pulse_source_output_set_volume;
control_class->create_monitor = pulse_source_output_create_monitor;
+
+ signals[STREAM_CHANGED_BY_REQUEST] =
+ g_signal_new ("stream-changed-by-request",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (PulseSourceOutputClass, stream_changed_by_request),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__OBJECT,
+ G_TYPE_NONE,
+ 1,
+ G_TYPE_OBJECT);
}
static void
@@ -75,6 +97,7 @@ pulse_source_output_new (PulseConnection *connection,
MateMixerStreamControlFlags flags = MATE_MIXER_STREAM_CONTROL_MUTE_READABLE |
MATE_MIXER_STREAM_CONTROL_MUTE_WRITABLE |
+ MATE_MIXER_STREAM_CONTROL_MOVABLE |
MATE_MIXER_STREAM_CONTROL_HAS_MONITOR;
MateMixerStreamControlRole role = MATE_MIXER_STREAM_CONTROL_ROLE_UNKNOWN;
@@ -144,37 +167,70 @@ pulse_source_output_new (PulseConnection *connection,
TRUE);
}
- pulse_source_output_update (output, info);
+ /* Read the rest of the output's values, parent was already given during
+ * the construction */
+ pulse_source_output_update (output, info, NULL);
return output;
}
void
pulse_source_output_update (PulseSourceOutput *output,
- const pa_source_output_info *info)
+ const pa_source_output_info *info,
+ PulseSource *parent)
{
g_return_if_fail (PULSE_IS_SOURCE_OUTPUT (output));
- g_return_if_fail (info != NULL);
+ g_return_if_fail (parent == NULL || PULSE_IS_SOURCE (parent));
/* Let all the information update before emitting notify signals */
g_object_freeze_notify (G_OBJECT (output));
- _mate_mixer_stream_control_set_mute (MATE_MIXER_STREAM_CONTROL (output),
- info->mute ? TRUE : FALSE);
+ if (info != NULL) {
+ _mate_mixer_stream_control_set_mute (MATE_MIXER_STREAM_CONTROL (output),
+ info->mute ? TRUE : FALSE);
+
+ pulse_stream_control_set_channel_map (PULSE_STREAM_CONTROL (output),
+ &info->channel_map);
+ if (info->has_volume)
+ pulse_stream_control_set_cvolume (PULSE_STREAM_CONTROL (output),
+ &info->volume,
+ 0);
+ else
+ pulse_stream_control_set_cvolume (PULSE_STREAM_CONTROL (output),
+ NULL,
+ 0);
+ }
- pulse_stream_control_set_channel_map (PULSE_STREAM_CONTROL (output),
- &info->channel_map);
- if (info->has_volume)
- pulse_stream_control_set_cvolume (PULSE_STREAM_CONTROL (output),
- &info->volume,
- 0);
- else
- pulse_stream_control_set_cvolume (PULSE_STREAM_CONTROL (output),
- NULL,
- 0);
+ /* Source output must always have a parent source, but it is possible to
+ * pass a NULL parent to indicate that it has not changed */
+ if (parent != NULL)
+ _mate_mixer_stream_control_set_stream (MATE_MIXER_STREAM_CONTROL (output),
+ MATE_MIXER_STREAM (parent));
g_object_thaw_notify (G_OBJECT (output));
}
+static gboolean
+pulse_source_output_set_stream (MateMixerStreamControl *mmsc, MateMixerStream *mms)
+{
+ PulseStreamControl *psc;
+ gboolean ret;
+
+ g_return_val_if_fail (PULSE_IS_SOURCE_OUTPUT (mmsc), FALSE);
+ g_return_val_if_fail (PULSE_IS_SOURCE (mms), FALSE);
+
+ psc = PULSE_STREAM_CONTROL (mmsc);
+ ret = pulse_connection_move_source_output (pulse_stream_control_get_connection (psc),
+ pulse_stream_control_get_index (psc),
+ pulse_stream_get_index (PULSE_STREAM (mms)));
+ if (ret == TRUE)
+ g_signal_emit (G_OBJECT (psc),
+ signals[STREAM_CHANGED_BY_REQUEST],
+ 0,
+ mms);
+
+ return ret;
+}
+
static guint
pulse_source_output_get_max_volume (MateMixerStreamControl *mmsc)
{