gnome-media r4061 - in trunk/gnome-volume-control: . src
- From: mccann svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-media r4061 - in trunk/gnome-volume-control: . src
- Date: Thu, 13 Nov 2008 02:32:22 +0000 (UTC)
Author: mccann
Date: Thu Nov 13 02:32:22 2008
New Revision: 4061
URL: http://svn.gnome.org/viewvc/gnome-media?rev=4061&view=rev
Log:
2008-11-12 William Jon McCann <jmccann redhat com>
* src/Makefile.am:
* src/gvc-mixer-control.c (update_event_role_stream):
* src/gvc-mixer-dialog.c (create_bar), (add_stream):
* src/gvc-mixer-event-role.c (update_settings),
(gvc_mixer_event_role_change_volume),
(gvc_mixer_event_role_change_is_muted),
(gvc_mixer_event_role_set_device),
(gvc_mixer_event_role_set_property),
(gvc_mixer_event_role_get_property),
(gvc_mixer_event_role_constructor),
(gvc_mixer_event_role_class_init), (gvc_mixer_event_role_init),
(gvc_mixer_event_role_finalize), (gvc_mixer_event_role_new):
* src/gvc-mixer-event-role.h:
Add event role stream. Make setting event volume work.
Added:
trunk/gnome-volume-control/src/gvc-mixer-event-role.c
trunk/gnome-volume-control/src/gvc-mixer-event-role.h
Modified:
trunk/gnome-volume-control/ChangeLog
trunk/gnome-volume-control/src/Makefile.am
trunk/gnome-volume-control/src/gvc-mixer-control.c
trunk/gnome-volume-control/src/gvc-mixer-dialog.c
Modified: trunk/gnome-volume-control/src/Makefile.am
==============================================================================
--- trunk/gnome-volume-control/src/Makefile.am (original)
+++ trunk/gnome-volume-control/src/Makefile.am Thu Nov 13 02:32:22 2008
@@ -29,6 +29,8 @@
gvc-mixer-source.c \
gvc-mixer-sink-input.h \
gvc-mixer-sink-input.c \
+ gvc-mixer-event-role.h \
+ gvc-mixer-event-role.c \
gvc-mixer-control.h \
gvc-mixer-control.c \
gvc-channel-bar.h \
@@ -52,6 +54,8 @@
gvc-mixer-source.c \
gvc-mixer-sink-input.h \
gvc-mixer-sink-input.c \
+ gvc-mixer-event-role.h \
+ gvc-mixer-event-role.c \
gvc-mixer-control.h \
gvc-mixer-control.c \
gvc-channel-bar.h \
Modified: trunk/gnome-volume-control/src/gvc-mixer-control.c
==============================================================================
--- trunk/gnome-volume-control/src/gvc-mixer-control.c (original)
+++ trunk/gnome-volume-control/src/gvc-mixer-control.c Thu Nov 13 02:32:22 2008
@@ -37,6 +37,7 @@
#include "gvc-mixer-sink.h"
#include "gvc-mixer-source.h"
#include "gvc-mixer-sink-input.h"
+#include "gvc-mixer-event-role.h"
#define GVC_MIXER_CONTROL_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GVC_TYPE_MIXER_CONTROL, GvcMixerControlPrivate))
@@ -695,9 +696,8 @@
is_new = FALSE;
if (!control->priv->event_sink_input_is_set) {
- stream = gvc_mixer_sink_input_new (control->priv->pa_context,
- 0,
- 1);
+ stream = gvc_mixer_event_role_new (control->priv->pa_context,
+ info->device);
control->priv->event_sink_input_id = gvc_mixer_stream_get_id (stream);
control->priv->event_sink_input_is_set = TRUE;
Modified: trunk/gnome-volume-control/src/gvc-mixer-dialog.c
==============================================================================
--- trunk/gnome-volume-control/src/gvc-mixer-dialog.c (original)
+++ trunk/gnome-volume-control/src/gvc-mixer-dialog.c Thu Nov 13 02:32:22 2008
@@ -251,6 +251,7 @@
GtkWidget *bar;
bar = gvc_channel_bar_new ();
+ gtk_widget_set_sensitive (bar, FALSE);
if (size_group != NULL) {
gvc_channel_bar_set_size_group (GVC_CHANNEL_BAR (bar),
size_group);
@@ -317,6 +318,7 @@
bar = dialog->priv->input_bar;
} else if (stream == gvc_mixer_control_get_event_sink_input (dialog->priv->mixer_control)) {
bar = dialog->priv->effects_bar;
+ g_debug ("Adding effects stream");
} else if (! GVC_IS_MIXER_SOURCE (stream)
&& !GVC_IS_MIXER_SINK (stream)) {
bar = create_bar (dialog, dialog->priv->apps_size_group);
Added: trunk/gnome-volume-control/src/gvc-mixer-event-role.c
==============================================================================
--- (empty file)
+++ trunk/gnome-volume-control/src/gvc-mixer-event-role.c Thu Nov 13 02:32:22 2008
@@ -0,0 +1,241 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2008 William Jon McCann
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#include "config.h"
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+
+#include <glib.h>
+#include <glib/gi18n.h>
+
+#include <pulse/pulseaudio.h>
+#include <pulse/ext-stream-restore.h>
+
+#include "gvc-mixer-event-role.h"
+
+#define GVC_MIXER_EVENT_ROLE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GVC_TYPE_MIXER_EVENT_ROLE, GvcMixerEventRolePrivate))
+
+struct GvcMixerEventRolePrivate
+{
+ char *device;
+};
+
+enum
+{
+ PROP_0,
+ PROP_DEVICE
+};
+
+static void gvc_mixer_event_role_class_init (GvcMixerEventRoleClass *klass);
+static void gvc_mixer_event_role_init (GvcMixerEventRole *mixer_event_role);
+static void gvc_mixer_event_role_finalize (GObject *object);
+
+G_DEFINE_TYPE (GvcMixerEventRole, gvc_mixer_event_role, GVC_TYPE_MIXER_STREAM)
+
+static gboolean
+update_settings (GvcMixerEventRole *role,
+ guint volume,
+ gboolean is_muted)
+{
+ pa_operation *o;
+ guint index;
+ guint num_channels;
+ pa_context *context;
+ pa_ext_stream_restore_info info;
+
+ index = gvc_mixer_stream_get_index (GVC_MIXER_STREAM (role));
+ num_channels = gvc_mixer_stream_get_num_channels (GVC_MIXER_STREAM (role));
+
+ pa_cvolume_set (&info.volume, num_channels, (pa_volume_t)volume);
+
+ info.name = "sink-input-by-media-role:event";
+ info.channel_map.channels = 1;
+ info.channel_map.map[0] = PA_CHANNEL_POSITION_MONO;
+ info.device = role->priv->device;
+ info.mute = is_muted;
+
+ context = gvc_mixer_stream_get_pa_context (GVC_MIXER_STREAM (role));
+
+ o = pa_ext_stream_restore_write (context,
+ PA_UPDATE_REPLACE,
+ &info,
+ 1,
+ TRUE,
+ NULL,
+ NULL);
+
+ if (o == NULL) {
+ g_warning ("pa_ext_stream_restore_write() failed");
+ return FALSE;
+ }
+
+ pa_operation_unref(o);
+
+ return TRUE;
+}
+
+static gboolean
+gvc_mixer_event_role_change_volume (GvcMixerStream *stream,
+ guint volume)
+{
+ return update_settings (GVC_MIXER_EVENT_ROLE (stream),
+ volume,
+ gvc_mixer_stream_get_is_muted (stream));
+}
+
+static gboolean
+gvc_mixer_event_role_change_is_muted (GvcMixerStream *stream,
+ gboolean is_muted)
+{
+ return update_settings (GVC_MIXER_EVENT_ROLE (stream),
+ gvc_mixer_stream_get_volume (stream),
+ is_muted);
+}
+
+static gboolean
+gvc_mixer_event_role_set_device (GvcMixerEventRole *role,
+ const char *device)
+{
+ g_return_val_if_fail (GVC_IS_MIXER_EVENT_ROLE (role), FALSE);
+
+ g_free (role->priv->device);
+ role->priv->device = g_strdup (device);
+ g_object_notify (G_OBJECT (role), "device");
+
+ return TRUE;
+}
+
+static void
+gvc_mixer_event_role_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GvcMixerEventRole *self = GVC_MIXER_EVENT_ROLE (object);
+
+ switch (prop_id) {
+ case PROP_DEVICE:
+ gvc_mixer_event_role_set_device (self, g_value_get_string (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+gvc_mixer_event_role_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GvcMixerEventRole *self = GVC_MIXER_EVENT_ROLE (object);
+
+ switch (prop_id) {
+ case PROP_DEVICE:
+ g_value_set_string (value, self->priv->device);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static GObject *
+gvc_mixer_event_role_constructor (GType type,
+ guint n_construct_properties,
+ GObjectConstructParam *construct_params)
+{
+ GObject *object;
+ GvcMixerEventRole *self;
+
+ object = G_OBJECT_CLASS (gvc_mixer_event_role_parent_class)->constructor (type, n_construct_properties, construct_params);
+
+ self = GVC_MIXER_EVENT_ROLE (object);
+
+ return object;
+}
+
+static void
+gvc_mixer_event_role_class_init (GvcMixerEventRoleClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GvcMixerStreamClass *stream_class = GVC_MIXER_STREAM_CLASS (klass);
+
+ object_class->constructor = gvc_mixer_event_role_constructor;
+ object_class->finalize = gvc_mixer_event_role_finalize;
+ object_class->set_property = gvc_mixer_event_role_set_property;
+ object_class->get_property = gvc_mixer_event_role_get_property;
+
+ stream_class->change_volume = gvc_mixer_event_role_change_volume;
+ stream_class->change_is_muted = gvc_mixer_event_role_change_is_muted;
+
+ g_object_class_install_property (object_class,
+ PROP_DEVICE,
+ g_param_spec_string ("device",
+ "Device",
+ "Device",
+ NULL,
+ G_PARAM_READWRITE|G_PARAM_CONSTRUCT));
+
+ g_type_class_add_private (klass, sizeof (GvcMixerEventRolePrivate));
+}
+
+static void
+gvc_mixer_event_role_init (GvcMixerEventRole *event_role)
+{
+ event_role->priv = GVC_MIXER_EVENT_ROLE_GET_PRIVATE (event_role);
+
+}
+
+static void
+gvc_mixer_event_role_finalize (GObject *object)
+{
+ GvcMixerEventRole *mixer_event_role;
+
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (GVC_IS_MIXER_EVENT_ROLE (object));
+
+ mixer_event_role = GVC_MIXER_EVENT_ROLE (object);
+
+ g_return_if_fail (mixer_event_role->priv != NULL);
+
+ g_free (mixer_event_role->priv->device);
+
+ G_OBJECT_CLASS (gvc_mixer_event_role_parent_class)->finalize (object);
+}
+
+GvcMixerStream *
+gvc_mixer_event_role_new (pa_context *context,
+ const char *device)
+{
+ GObject *object;
+
+ object = g_object_new (GVC_TYPE_MIXER_EVENT_ROLE,
+ "pa-context", context,
+ "index", 0,
+ "num-channels", 1,
+ "device", device,
+ NULL);
+
+ return GVC_MIXER_STREAM (object);
+}
Added: trunk/gnome-volume-control/src/gvc-mixer-event-role.h
==============================================================================
--- (empty file)
+++ trunk/gnome-volume-control/src/gvc-mixer-event-role.h Thu Nov 13 02:32:22 2008
@@ -0,0 +1,56 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2008 Red Hat, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#ifndef __GVC_MIXER_EVENT_ROLE_H
+#define __GVC_MIXER_EVENT_ROLE_H
+
+#include <glib-object.h>
+#include "gvc-mixer-stream.h"
+
+G_BEGIN_DECLS
+
+#define GVC_TYPE_MIXER_EVENT_ROLE (gvc_mixer_event_role_get_type ())
+#define GVC_MIXER_EVENT_ROLE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GVC_TYPE_MIXER_EVENT_ROLE, GvcMixerEventRole))
+#define GVC_MIXER_EVENT_ROLE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GVC_TYPE_MIXER_EVENT_ROLE, GvcMixerEventRoleClass))
+#define GVC_IS_MIXER_EVENT_ROLE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GVC_TYPE_MIXER_EVENT_ROLE))
+#define GVC_IS_MIXER_EVENT_ROLE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GVC_TYPE_MIXER_EVENT_ROLE))
+#define GVC_MIXER_EVENT_ROLE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GVC_TYPE_MIXER_EVENT_ROLE, GvcMixerEventRoleClass))
+
+typedef struct GvcMixerEventRolePrivate GvcMixerEventRolePrivate;
+
+typedef struct
+{
+ GvcMixerStream parent;
+ GvcMixerEventRolePrivate *priv;
+} GvcMixerEventRole;
+
+typedef struct
+{
+ GvcMixerStreamClass parent_class;
+} GvcMixerEventRoleClass;
+
+GType gvc_mixer_event_role_get_type (void);
+
+GvcMixerStream * gvc_mixer_event_role_new (pa_context *context,
+ const char *device);
+
+G_END_DECLS
+
+#endif /* __GVC_MIXER_EVENT_ROLE_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]