2 * empathy-gst-audio-sink.c - Source for EmpathyGstAudioSink
3 * Copyright (C) 2008 Collabora Ltd.
4 * @author Sjoerd Simons <sjoerd.simons@collabora.co.uk>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 #include "empathy-audio-sink.h"
27 G_DEFINE_TYPE(EmpathyGstAudioSink, empathy_audio_sink, GST_TYPE_BIN)
36 static guint signals[LAST_SIGNAL] = {0};
39 /* private structure */
40 typedef struct _EmpathyGstAudioSinkPrivate EmpathyGstAudioSinkPrivate;
42 struct _EmpathyGstAudioSinkPrivate
44 gboolean dispose_has_run;
48 #define EMPATHY_GST_AUDIO_SINK_GET_PRIVATE(o) \
49 (G_TYPE_INSTANCE_GET_PRIVATE ((o), EMPATHY_TYPE_GST_AUDIO_SINK, \
50 EmpathyGstAudioSinkPrivate))
53 empathy_audio_sink_init (EmpathyGstAudioSink *obj)
55 EmpathyGstAudioSinkPrivate *priv = EMPATHY_GST_AUDIO_SINK_GET_PRIVATE (obj);
59 /* allocate any data required by the object here */
60 resample = gst_element_factory_make ("audioresample", NULL);
62 priv->sink = gst_element_factory_make ("gconfaudiosink", NULL);
64 gst_bin_add_many (GST_BIN (obj), resample, priv->sink, NULL);
65 gst_element_link_many (resample, priv->sink, NULL);
67 sink = gst_element_get_static_pad (resample, "sink");
69 ghost = gst_ghost_pad_new ("sink", sink);
70 gst_element_add_pad (GST_ELEMENT (obj), ghost);
72 gst_object_unref (G_OBJECT (sink));
75 static void empathy_audio_sink_dispose (GObject *object);
76 static void empathy_audio_sink_finalize (GObject *object);
79 empathy_audio_sink_class_init (EmpathyGstAudioSinkClass
80 *empathy_audio_sink_class)
82 GObjectClass *object_class = G_OBJECT_CLASS (empathy_audio_sink_class);
84 g_type_class_add_private (empathy_audio_sink_class,
85 sizeof (EmpathyGstAudioSinkPrivate));
87 object_class->dispose = empathy_audio_sink_dispose;
88 object_class->finalize = empathy_audio_sink_finalize;
92 empathy_audio_sink_dispose (GObject *object)
94 EmpathyGstAudioSink *self = EMPATHY_GST_AUDIO_SINK (object);
95 EmpathyGstAudioSinkPrivate *priv = EMPATHY_GST_AUDIO_SINK_GET_PRIVATE (self);
97 if (priv->dispose_has_run)
100 priv->dispose_has_run = TRUE;
102 /* release any references held by the object here */
104 if (G_OBJECT_CLASS (empathy_audio_sink_parent_class)->dispose)
105 G_OBJECT_CLASS (empathy_audio_sink_parent_class)->dispose (object);
109 empathy_audio_sink_finalize (GObject *object)
111 //EmpathyGstAudioSink *self = EMPATHY_GST_AUDIO_SINK (object);
112 //EmpathyGstAudioSinkPrivate *priv =
113 // EMPATHY_GST_AUDIO_SINK_GET_PRIVATE (self);
115 /* free any data held directly by the object here */
117 G_OBJECT_CLASS (empathy_audio_sink_parent_class)->finalize (object);
121 empathy_audio_sink_new (void)
123 return GST_ELEMENT (g_object_new (EMPATHY_TYPE_GST_AUDIO_SINK, NULL));