diff --git a/src/engines/gstengine.cpp b/src/engines/gstengine.cpp index a9e17c476..3f9040a29 100644 --- a/src/engines/gstengine.cpp +++ b/src/engines/gstengine.cpp @@ -781,12 +781,7 @@ void GstEngine::RemoveBufferConsumer(BufferConsumer *consumer) { current_pipeline_->RemoveBufferConsumer(consumer); } -int GstEngine::AddBackgroundStream(const QUrl& url) { - shared_ptr pipeline = CreatePipeline(url); - if (!pipeline) { - return -1; - } - pipeline->SetVolume(30); +int GstEngine::AddBackgroundStream(shared_ptr pipeline) { // We don't want to get metadata messages or end notifications. disconnect(pipeline.get(), SIGNAL(MetadataFound(Engine::SimpleMetaBundle)), this, 0); disconnect(pipeline.get(), SIGNAL(EndOfStreamReached(bool)), this, 0); @@ -796,12 +791,21 @@ int GstEngine::AddBackgroundStream(const QUrl& url) { pipeline.reset(); return -1; } - pipeline->SetNextUrl(url); - int stream_id = next_background_stream_id_++; + const int stream_id = next_background_stream_id_++; background_streams_[stream_id] = pipeline; return stream_id; } +int GstEngine::AddBackgroundStream(const QUrl& url) { + shared_ptr pipeline = CreatePipeline(url); + if (!pipeline) { + return -1; + } + pipeline->SetVolume(30); + pipeline->SetNextUrl(url); + return AddBackgroundStream(pipeline); +} + void GstEngine::StopBackgroundStream(int id) { background_streams_.remove(id); // Removes last shared_ptr reference. } @@ -818,16 +822,5 @@ int GstEngine::AllGloryToTheHypnotoad() { return -1; } pipeline->SetVolume(5); // Hypnotoad is *loud*. - // We don't want to get metadata messages or end notifications. - disconnect(pipeline.get(), SIGNAL(MetadataFound(Engine::SimpleMetaBundle)), this, 0); - disconnect(pipeline.get(), SIGNAL(EndOfStreamReached(bool)), this, 0); - connect(pipeline.get(), SIGNAL(EndOfStreamReached(bool)), SLOT(BackgroundStreamFinished())); - if (!pipeline->SetState(GST_STATE_PLAYING)) { - qWarning() << "Could not set thread to PLAYING."; - pipeline.reset(); - return -1; - } - int stream_id = next_background_stream_id_++; - background_streams_[stream_id] = pipeline; - return stream_id; + return AddBackgroundStream(pipeline); } diff --git a/src/engines/gstengine.h b/src/engines/gstengine.h index e69f09931..33c552080 100644 --- a/src/engines/gstengine.h +++ b/src/engines/gstengine.h @@ -140,6 +140,8 @@ class GstEngine : public Engine::Base, public BufferConsumer { void UpdateScope(); qint64 PruneScope(); + int AddBackgroundStream(boost::shared_ptr pipeline); + private: static const int kTimerInterval = 1000; // msec static const int kPreloadGap = 1000; // msec