From 03acf0d17a8f3fd885f0ea4311010894a3898780 Mon Sep 17 00:00:00 2001 From: fgerlits Date: Wed, 11 Oct 2006 15:17:25 +0000 Subject: [PATCH] Added an audioscale element to the GStreamer pipeline; this may fix #1840. Added audioconvert, too -- not sure what that does, but it seems to be the thing to do. --- .../playlistExecutor/src/GstreamerPlayer.cxx | 62 ++++++++++++++----- .../playlistExecutor/src/GstreamerPlayer.h | 10 +++ 2 files changed, 58 insertions(+), 14 deletions(-) diff --git a/livesupport/src/modules/playlistExecutor/src/GstreamerPlayer.cxx b/livesupport/src/modules/playlistExecutor/src/GstreamerPlayer.cxx index 94325a2d9..7d1ae44a1 100644 --- a/livesupport/src/modules/playlistExecutor/src/GstreamerPlayer.cxx +++ b/livesupport/src/modules/playlistExecutor/src/GstreamerPlayer.cxx @@ -291,15 +291,29 @@ GstreamerPlayer :: open(const std::string fileUrl) gst_element_unlink(decoder, fakesink); gst_object_unref(GST_OBJECT(pipe)); + // not sure what this does, but it seems important + audioconvert = gst_element_factory_make("audioconvert", NULL); + // reduce the volume to 80% - volume = gst_element_factory_make("volume", NULL); + volume = gst_element_factory_make("volume", NULL); g_object_set(G_OBJECT(volume), "volume", gdouble(0.8), NULL); - - gst_element_link_many(decoder, volume, audiosink, NULL); - gst_bin_add_many(GST_BIN(pipeline), filesrc, - decoder, - volume, - audiosink, NULL); + + // scale the sampling rate, if necessary + audioscale = gst_element_factory_make("audioscale", NULL); + + gst_element_link_many(decoder, + audioconvert, + volume, + audioscale, + audiosink, + NULL); + gst_bin_add_many(GST_BIN(pipeline), filesrc, + decoder, + audioconvert, + volume, + audioscale, + audiosink, + NULL); // connect the eos signal handler g_signal_connect(decoder, "eos", G_CALLBACK(eosEventHandler), this); @@ -445,14 +459,31 @@ GstreamerPlayer :: close(void) throw () } gst_element_set_state(pipeline, GST_STATE_NULL); + if (filesrc && decoder) { gst_element_unlink(filesrc, decoder); } - if (decoder && volume) { - gst_element_unlink(decoder, volume); + if (decoder && audioconvert) { + gst_element_unlink(decoder, audioconvert); } - if (volume && audiosink) { - gst_element_unlink(volume, audiosink); + if (audioconvert && volume) { + gst_element_unlink(audioconvert, volume); + } + if (volume && audioscale) { + gst_element_unlink(volume, audioscale); + } + if (audioscale && audiosink) { + gst_element_unlink(audioscale, audiosink); + } + + if (audioscale) { + gst_bin_remove(GST_BIN(pipeline), audioscale); + } + if (volume) { + gst_bin_remove(GST_BIN(pipeline), volume); + } + if (audioconvert) { + gst_bin_remove(GST_BIN(pipeline), audioconvert); } if (decoder) { gst_bin_remove(GST_BIN(pipeline), decoder); @@ -460,9 +491,12 @@ GstreamerPlayer :: close(void) throw () if (filesrc) { gst_bin_remove(GST_BIN(pipeline), filesrc); } - filesrc = 0; - decoder = 0; - volume = 0; + + filesrc = 0; + decoder = 0; + audioconvert = 0; + volume = 0; + audioscale = 0; } diff --git a/livesupport/src/modules/playlistExecutor/src/GstreamerPlayer.h b/livesupport/src/modules/playlistExecutor/src/GstreamerPlayer.h index fd23f8513..a898678bd 100644 --- a/livesupport/src/modules/playlistExecutor/src/GstreamerPlayer.h +++ b/livesupport/src/modules/playlistExecutor/src/GstreamerPlayer.h @@ -112,11 +112,21 @@ class GstreamerPlayer : virtual public Configurable, */ GstElement * decoder; + /** + * The audioconvert element. + */ + GstElement * audioconvert; + /** * The volume element. */ GstElement * volume; + /** + * The audioscale element. + */ + GstElement * audioscale; + /** * The desired capabilities of the audio sink. */