From a1983264ddb80e5da8a77e830388376fbce6329a Mon Sep 17 00:00:00 2001 From: mark <mark@cfc7b370-4200-0410-a6e3-cb6bdb053afe> Date: Sat, 28 Oct 2006 18:20:09 +0000 Subject: [PATCH] Optimize: There is no need to remove the audiosink from the pipeline, only to add it again a few lines later on. --- .../playlistExecutor/src/GstreamerPlayer.cxx | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/campcaster/src/modules/playlistExecutor/src/GstreamerPlayer.cxx b/campcaster/src/modules/playlistExecutor/src/GstreamerPlayer.cxx index 17730d049..36586cb7c 100644 --- a/campcaster/src/modules/playlistExecutor/src/GstreamerPlayer.cxx +++ b/campcaster/src/modules/playlistExecutor/src/GstreamerPlayer.cxx @@ -266,9 +266,6 @@ GstreamerPlayer :: open(const std::string fileUrl) throw std::invalid_argument("badly formed URL or unsupported protocol"); } - gst_object_ref(GST_OBJECT(audiosink)); - gst_bin_remove(GST_BIN(pipeline), audiosink); - filesrc = gst_element_factory_make("filesrc", "file-source"); gst_element_set(filesrc, "location", filePath.c_str(), NULL); @@ -308,17 +305,17 @@ GstreamerPlayer :: open(const std::string fileUrl) // scale the sampling rate, if necessary audioscale = gst_element_factory_make("audioscale", NULL); + gst_bin_add_many(GST_BIN(pipeline), filesrc, + decoder, + audioconvert, + audioscale, + NULL); gst_element_link_many(decoder, audioconvert, audioscale, audiosink, NULL); - gst_bin_add_many(GST_BIN(pipeline), filesrc, - decoder, - audioconvert, - audioscale, - audiosink, - NULL); + // connect the eos signal handler g_signal_connect(decoder, "eos", G_CALLBACK(eosEventHandler), this); @@ -404,6 +401,8 @@ GstreamerPlayer :: getPosition(void) throw (std::logic_error) void GstreamerPlayer :: start(void) throw (std::logic_error) { + DEBUG_BLOCK + if (!isOpen()) { throw std::logic_error("GstreamerPlayer not opened yet"); }