[empathy] audio-src: Add a caps filter to select appropriate input format
- From: Arun Raghavan <arunsr src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [empathy] audio-src: Add a caps filter to select appropriate input format
- Date: Thu, 10 Nov 2011 07:39:43 +0000 (UTC)
commit cec65054ff56209c3e660817830b7586b56a16d0
Author: Arun Raghavan <arun raghavan collabora co uk>
Date: Mon Oct 31 18:42:56 2011 +0530
audio-src: Add a caps filter to select appropriate input format
Instead of relying on the default caps that the pipeline selects (which
will usually end up being float32 stereo at 44.1kHz), this sets a caps
filter to select the format we want from pulsesrc -- s16ne mono at 32kHz.
The point of this is to do resampling/conversion as early in the
pipeline as possible, decreasing the amount of data that needs to be
carried around and thus improving performance a bit.
src/empathy-audio-src.c | 20 +++++++++++++++++++-
1 files changed, 19 insertions(+), 1 deletions(-)
---
diff --git a/src/empathy-audio-src.c b/src/empathy-audio-src.c
index bd3c433..350a29a 100644
--- a/src/empathy-audio-src.c
+++ b/src/empathy-audio-src.c
@@ -217,6 +217,8 @@ empathy_audio_src_init (EmpathyGstAudioSrc *obj)
{
EmpathyGstAudioSrcPrivate *priv = EMPATHY_GST_AUDIO_SRC_GET_PRIVATE (obj);
GstPad *ghost, *src;
+ GstElement *capsfilter;
+ GstCaps *caps;
priv->peak_level = -G_MAXDOUBLE;
priv->lock = g_mutex_new ();
@@ -227,11 +229,27 @@ empathy_audio_src_init (EmpathyGstAudioSrc *obj)
gst_bin_add (GST_BIN (obj), priv->src);
+ /* Explicitly state what format we want from pulsesrc. This pushes resampling
+ * and format conversion as early as possible, lowering the amount of data
+ * transferred and thus improving performance. When moving to GStreamer
+ * 0.11/1.0, this should change so that we actually request what the encoder
+ * wants downstream. */
+ caps = gst_caps_new_simple ("audio/x-raw-int",
+ "channels", G_TYPE_INT, 1,
+ "width", G_TYPE_INT, 16,
+ "depth", G_TYPE_INT, 16,
+ "rate", G_TYPE_INT, 32000,
+ NULL);
+ capsfilter = gst_element_factory_make ("capsfilter", NULL);
+ g_object_set (G_OBJECT (capsfilter), "caps", caps, NULL);
+ gst_bin_add (GST_BIN (obj), capsfilter);
+ gst_element_link (priv->src, capsfilter);
+
priv->volume = gst_element_factory_make ("volume", NULL);
g_object_ref (priv->volume);
gst_bin_add (GST_BIN (obj), priv->volume);
- gst_element_link (priv->src, priv->volume);
+ gst_element_link (capsfilter, priv->volume);
priv->level = gst_element_factory_make ("level", NULL);
gst_bin_add (GST_BIN (obj), priv->level);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]