[gnome-media] Implement port changing
- From: Bastien Nocera <hadess src gnome org>
- To: svn-commits-list gnome org
- Subject: [gnome-media] Implement port changing
- Date: Mon, 27 Jul 2009 15:16:43 +0000 (UTC)
commit 5847b884a4d42f41c992b3f2424a4e21a9fc810e
Author: Bastien Nocera <hadess hadess net>
Date: Mon Jul 27 15:50:43 2009 +0100
Implement port changing
In both the sink and source.
gnome-volume-control/src/gvc-mixer-sink.c | 28 +++++++++++++++++++++++++++
gnome-volume-control/src/gvc-mixer-source.c | 28 +++++++++++++++++++++++++++
gnome-volume-control/src/gvc-mixer-stream.c | 12 +++++++++-
gnome-volume-control/src/gvc-mixer-stream.h | 5 +++-
4 files changed, 70 insertions(+), 3 deletions(-)
---
diff --git a/gnome-volume-control/src/gvc-mixer-sink.c b/gnome-volume-control/src/gvc-mixer-sink.c
index 06e5af6..4576db9 100644
--- a/gnome-volume-control/src/gvc-mixer-sink.c
+++ b/gnome-volume-control/src/gvc-mixer-sink.c
@@ -106,6 +106,33 @@ gvc_mixer_sink_change_is_muted (GvcMixerStream *stream,
return TRUE;
}
+static gboolean
+gvc_mixer_sink_change_port (GvcMixerStream *stream,
+ const char *port)
+{
+ pa_operation *o;
+ guint index;
+ pa_context *context;
+
+ index = gvc_mixer_stream_get_index (stream);
+ context = gvc_mixer_stream_get_pa_context (stream);
+
+ o = pa_context_set_sink_port_by_index (context,
+ index,
+ port,
+ NULL,
+ NULL);
+
+ if (o == NULL) {
+ g_warning ("pa_context_set_sink_port_by_index() failed: %s", pa_strerror(pa_context_errno(context)));
+ return FALSE;
+ }
+
+ pa_operation_unref(o);
+
+ return TRUE;
+}
+
static GObject *
gvc_mixer_sink_constructor (GType type,
guint n_construct_properties,
@@ -132,6 +159,7 @@ gvc_mixer_sink_class_init (GvcMixerSinkClass *klass)
object_class->finalize = gvc_mixer_sink_finalize;
stream_class->push_volume = gvc_mixer_sink_push_volume;
+ stream_class->change_port = gvc_mixer_sink_change_port;
stream_class->change_is_muted = gvc_mixer_sink_change_is_muted;
g_type_class_add_private (klass, sizeof (GvcMixerSinkPrivate));
diff --git a/gnome-volume-control/src/gvc-mixer-source.c b/gnome-volume-control/src/gvc-mixer-source.c
index ae02d85..8f8927f 100644
--- a/gnome-volume-control/src/gvc-mixer-source.c
+++ b/gnome-volume-control/src/gvc-mixer-source.c
@@ -106,6 +106,33 @@ gvc_mixer_source_change_is_muted (GvcMixerStream *stream,
return TRUE;
}
+static gboolean
+gvc_mixer_source_change_port (GvcMixerStream *stream,
+ const char *port)
+{
+ pa_operation *o;
+ guint index;
+ pa_context *context;
+
+ index = gvc_mixer_stream_get_index (stream);
+ context = gvc_mixer_stream_get_pa_context (stream);
+
+ o = pa_context_set_source_port_by_index (context,
+ index,
+ port,
+ NULL,
+ NULL);
+
+ if (o == NULL) {
+ g_warning ("pa_context_set_source_port_by_index() failed: %s", pa_strerror(pa_context_errno(context)));
+ return FALSE;
+ }
+
+ pa_operation_unref(o);
+
+ return TRUE;
+}
+
static GObject *
gvc_mixer_source_constructor (GType type,
guint n_construct_properties,
@@ -133,6 +160,7 @@ gvc_mixer_source_class_init (GvcMixerSourceClass *klass)
stream_class->push_volume = gvc_mixer_source_push_volume;
stream_class->change_is_muted = gvc_mixer_source_change_is_muted;
+ stream_class->change_port = gvc_mixer_source_change_port;
g_type_class_add_private (klass, sizeof (GvcMixerSourcePrivate));
}
diff --git a/gnome-volume-control/src/gvc-mixer-stream.c b/gnome-volume-control/src/gvc-mixer-stream.c
index b577b47..caea0f1 100644
--- a/gnome-volume-control/src/gvc-mixer-stream.c
+++ b/gnome-volume-control/src/gvc-mixer-stream.c
@@ -452,8 +452,8 @@ gboolean
gvc_mixer_stream_change_port (GvcMixerStream *stream,
const char *port)
{
- //FIXME implementz!
- return FALSE;
+ g_return_val_if_fail (GVC_IS_MIXER_STREAM (stream), FALSE);
+ return GVC_MIXER_STREAM_GET_CLASS (stream)->change_port (stream, port);
}
const GList *
@@ -626,6 +626,13 @@ gvc_mixer_stream_constructor (GType type,
}
static gboolean
+gvc_mixer_stream_real_change_port (GvcMixerStream *stream,
+ const char *port)
+{
+ return FALSE;
+}
+
+static gboolean
gvc_mixer_stream_real_push_volume (GvcMixerStream *stream, gpointer *op)
{
return FALSE;
@@ -689,6 +696,7 @@ gvc_mixer_stream_class_init (GvcMixerStreamClass *klass)
gobject_class->get_property = gvc_mixer_stream_get_property;
klass->push_volume = gvc_mixer_stream_real_push_volume;
+ klass->change_port = gvc_mixer_stream_real_change_port;
klass->change_is_muted = gvc_mixer_stream_real_change_is_muted;
g_object_class_install_property (gobject_class,
diff --git a/gnome-volume-control/src/gvc-mixer-stream.h b/gnome-volume-control/src/gvc-mixer-stream.h
index 0113a2e..4ae2d34 100644
--- a/gnome-volume-control/src/gvc-mixer-stream.h
+++ b/gnome-volume-control/src/gvc-mixer-stream.h
@@ -48,9 +48,12 @@ typedef struct
GObjectClass parent_class;
/* vtable */
- gboolean (*push_volume) (GvcMixerStream *stream, gpointer *operation);
+ gboolean (*push_volume) (GvcMixerStream *stream,
+ gpointer *operation);
gboolean (*change_is_muted) (GvcMixerStream *stream,
gboolean is_muted);
+ gboolean (*change_port) (GvcMixerStream *stream,
+ const char *port);
} GvcMixerStreamClass;
typedef struct
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]