Optimize: There is no need to remove the audiosink from the pipeline, only to add it again a few lines later on.

This commit is contained in:
mark 2006-10-28 18:20:09 +00:00
parent 2290edbd00
commit a1983264dd
1 changed files with 8 additions and 9 deletions

View File

@ -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");
}