diff options
author | Arun Raghavan <arun.raghavan@collabora.co.uk> | 2011-10-31 21:12:56 +0800 |
---|---|---|
committer | Arun Raghavan <arun.raghavan@collabora.co.uk> | 2011-11-09 17:40:34 +0800 |
commit | cec65054ff56209c3e660817830b7586b56a16d0 (patch) | |
tree | 7e53f90700408c873f819f830c43466527659be3 /src/empathy-audio-src.c | |
parent | e5f60e1e139a55250004a3683dd7edd780b43a54 (diff) | |
download | gsoc2013-empathy-cec65054ff56209c3e660817830b7586b56a16d0.tar gsoc2013-empathy-cec65054ff56209c3e660817830b7586b56a16d0.tar.gz gsoc2013-empathy-cec65054ff56209c3e660817830b7586b56a16d0.tar.bz2 gsoc2013-empathy-cec65054ff56209c3e660817830b7586b56a16d0.tar.lz gsoc2013-empathy-cec65054ff56209c3e660817830b7586b56a16d0.tar.xz gsoc2013-empathy-cec65054ff56209c3e660817830b7586b56a16d0.tar.zst gsoc2013-empathy-cec65054ff56209c3e660817830b7586b56a16d0.zip |
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.
Diffstat (limited to 'src/empathy-audio-src.c')
-rw-r--r-- | 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 bd3c433fa..350a29a8d 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); |