aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy-gtk/empathy-audio-sink.c
diff options
context:
space:
mode:
authorSjoerd Simons <sjoerd.simons@collabora.co.uk>2009-02-17 05:25:01 +0800
committerXavier Claessens <xclaesse@src.gnome.org>2009-02-17 05:25:01 +0800
commit0740bc82804c91d033d9e77588ccff724cb37e88 (patch)
tree7da2975c3228440766accec874f0ab80481e0c78 /libempathy-gtk/empathy-audio-sink.c
parentd57177df0cae66abfbccb0f012504dd26cc49743 (diff)
downloadgsoc2013-empathy-0740bc82804c91d033d9e77588ccff724cb37e88.tar
gsoc2013-empathy-0740bc82804c91d033d9e77588ccff724cb37e88.tar.gz
gsoc2013-empathy-0740bc82804c91d033d9e77588ccff724cb37e88.tar.bz2
gsoc2013-empathy-0740bc82804c91d033d9e77588ccff724cb37e88.tar.lz
gsoc2013-empathy-0740bc82804c91d033d9e77588ccff724cb37e88.tar.xz
gsoc2013-empathy-0740bc82804c91d033d9e77588ccff724cb37e88.tar.zst
gsoc2013-empathy-0740bc82804c91d033d9e77588ccff724cb37e88.zip
Add API to get and set the volume
From: Sjoerd Simons <sjoerd.simons@collabora.co.uk> svn path=/trunk/; revision=2484
Diffstat (limited to 'libempathy-gtk/empathy-audio-sink.c')
-rw-r--r--libempathy-gtk/empathy-audio-sink.c100
1 files changed, 95 insertions, 5 deletions
diff --git a/libempathy-gtk/empathy-audio-sink.c b/libempathy-gtk/empathy-audio-sink.c
index 8db046a85..d304a2676 100644
--- a/libempathy-gtk/empathy-audio-sink.c
+++ b/libempathy-gtk/empathy-audio-sink.c
@@ -22,8 +22,11 @@
#include <stdio.h>
#include <stdlib.h>
+#include <gst/farsight/fs-element-added-notifier.h>
+
#include "empathy-audio-sink.h"
+
G_DEFINE_TYPE(EmpathyGstAudioSink, empathy_audio_sink, GST_TYPE_BIN)
/* signal enum */
@@ -36,6 +39,10 @@ enum
static guint signals[LAST_SIGNAL] = {0};
#endif
+enum {
+ PROP_VOLUME = 1,
+};
+
/* private structure */
typedef struct _EmpathyGstAudioSinkPrivate EmpathyGstAudioSinkPrivate;
@@ -43,6 +50,8 @@ struct _EmpathyGstAudioSinkPrivate
{
gboolean dispose_has_run;
GstElement *sink;
+ GstElement *volume;
+ FsElementAddedNotifier *notifier;
};
#define EMPATHY_GST_AUDIO_SINK_GET_PRIVATE(o) \
@@ -50,19 +59,37 @@ struct _EmpathyGstAudioSinkPrivate
EmpathyGstAudioSinkPrivate))
static void
+empathy_audio_sink_element_added_cb (FsElementAddedNotifier *notifier,
+ GstBin *bin, GstElement *element, EmpathyGstAudioSink *self)
+{
+ EmpathyGstAudioSinkPrivate *priv = EMPATHY_GST_AUDIO_SINK_GET_PRIVATE (self);
+
+ if (g_object_class_find_property (G_OBJECT_CLASS (element), "volume"))
+ {
+ priv->volume = element;
+ }
+}
+
+static void
empathy_audio_sink_init (EmpathyGstAudioSink *obj)
{
EmpathyGstAudioSinkPrivate *priv = EMPATHY_GST_AUDIO_SINK_GET_PRIVATE (obj);
GstElement *resample;
GstPad *ghost, *sink;
- /* allocate any data required by the object here */
- resample = gst_element_factory_make ("audioresample", NULL);
+ priv->notifier = fs_element_added_notifier_new ();
+ g_signal_connect (priv->notifier, "element-added",
+ G_CALLBACK (empathy_audio_sink_element_added_cb), obj);
+ resample = gst_element_factory_make ("audioresample", NULL);
+ priv->volume = gst_element_factory_make ("volume", NULL);
priv->sink = gst_element_factory_make ("gconfaudiosink", NULL);
- gst_bin_add_many (GST_BIN (obj), resample, priv->sink, NULL);
- gst_element_link_many (resample, priv->sink, NULL);
+ fs_element_added_notifier_add (priv->notifier, GST_BIN (priv->sink));
+
+
+ gst_bin_add_many (GST_BIN (obj), resample, priv->volume, priv->sink, NULL);
+ gst_element_link_many (resample, priv->volume, priv->sink, NULL);
sink = gst_element_get_static_pad (resample, "sink");
@@ -76,16 +103,57 @@ static void empathy_audio_sink_dispose (GObject *object);
static void empathy_audio_sink_finalize (GObject *object);
static void
+empathy_audio_sink_set_property (GObject *object,
+ guint property_id, const GValue *value, GParamSpec *pspec)
+{
+ switch (property_id)
+ {
+ case PROP_VOLUME:
+ empathy_audio_sink_set_volume (EMPATHY_GST_AUDIO_SINK (object),
+ g_value_get_double (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ }
+}
+
+static void
+empathy_audio_sink_get_property (GObject *object,
+ guint property_id, GValue *value, GParamSpec *pspec)
+{
+ switch (property_id)
+ {
+ case PROP_VOLUME:
+ g_value_set_double (value,
+ empathy_audio_sink_get_volume (EMPATHY_GST_AUDIO_SINK (object)));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ }
+}
+
+
+
+static void
empathy_audio_sink_class_init (EmpathyGstAudioSinkClass
*empathy_audio_sink_class)
{
GObjectClass *object_class = G_OBJECT_CLASS (empathy_audio_sink_class);
+ GParamSpec *param_spec;
g_type_class_add_private (empathy_audio_sink_class,
sizeof (EmpathyGstAudioSinkPrivate));
object_class->dispose = empathy_audio_sink_dispose;
object_class->finalize = empathy_audio_sink_finalize;
+
+ object_class->set_property = empathy_audio_sink_set_property;
+ object_class->get_property = empathy_audio_sink_get_property;
+
+ param_spec = g_param_spec_double ("volume", "Volume", "volume factory",
+ 0.0, 5.0, 1.0,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+ g_object_class_install_property (object_class, PROP_VOLUME, param_spec);
}
void
@@ -99,7 +167,10 @@ empathy_audio_sink_dispose (GObject *object)
priv->dispose_has_run = TRUE;
- /* release any references held by the object here */
+ if (priv->notifier != NULL)
+ g_object_unref (priv->notifier);
+ priv->notifier = NULL;
+
if (G_OBJECT_CLASS (empathy_audio_sink_parent_class)->dispose)
G_OBJECT_CLASS (empathy_audio_sink_parent_class)->dispose (object);
@@ -122,3 +193,22 @@ empathy_audio_sink_new (void)
{
return GST_ELEMENT (g_object_new (EMPATHY_TYPE_GST_AUDIO_SINK, NULL));
}
+
+void
+empathy_audio_sink_set_volume (EmpathyGstAudioSink *sink, gdouble volume)
+{
+ EmpathyGstAudioSinkPrivate *priv = EMPATHY_GST_AUDIO_SINK_GET_PRIVATE (sink);
+
+ g_object_set (G_OBJECT (priv->volume), "volume", volume, NULL);
+}
+
+gdouble
+empathy_audio_sink_get_volume (EmpathyGstAudioSink *sink)
+{
+ EmpathyGstAudioSinkPrivate *priv = EMPATHY_GST_AUDIO_SINK_GET_PRIVATE (sink);
+ gdouble volume;
+
+ g_object_get (G_OBJECT (priv->volume), "volume", &volume, NULL);
+
+ return volume;
+}