1
0
mirror of https://github.com/clementine-player/Clementine synced 2025-01-28 18:19:42 +01:00

Code review comments for r1476.

This commit is contained in:
John Maguire 2010-07-14 11:43:23 +00:00
parent 41ab99e62e
commit 31a726789a
2 changed files with 15 additions and 20 deletions

View File

@ -781,12 +781,7 @@ void GstEngine::RemoveBufferConsumer(BufferConsumer *consumer) {
current_pipeline_->RemoveBufferConsumer(consumer); current_pipeline_->RemoveBufferConsumer(consumer);
} }
int GstEngine::AddBackgroundStream(const QUrl& url) { int GstEngine::AddBackgroundStream(shared_ptr<GstEnginePipeline> pipeline) {
shared_ptr<GstEnginePipeline> pipeline = CreatePipeline(url);
if (!pipeline) {
return -1;
}
pipeline->SetVolume(30);
// We don't want to get metadata messages or end notifications. // We don't want to get metadata messages or end notifications.
disconnect(pipeline.get(), SIGNAL(MetadataFound(Engine::SimpleMetaBundle)), this, 0); disconnect(pipeline.get(), SIGNAL(MetadataFound(Engine::SimpleMetaBundle)), this, 0);
disconnect(pipeline.get(), SIGNAL(EndOfStreamReached(bool)), this, 0); disconnect(pipeline.get(), SIGNAL(EndOfStreamReached(bool)), this, 0);
@ -796,12 +791,21 @@ int GstEngine::AddBackgroundStream(const QUrl& url) {
pipeline.reset(); pipeline.reset();
return -1; return -1;
} }
pipeline->SetNextUrl(url); const int stream_id = next_background_stream_id_++;
int stream_id = next_background_stream_id_++;
background_streams_[stream_id] = pipeline; background_streams_[stream_id] = pipeline;
return stream_id; return stream_id;
} }
int GstEngine::AddBackgroundStream(const QUrl& url) {
shared_ptr<GstEnginePipeline> pipeline = CreatePipeline(url);
if (!pipeline) {
return -1;
}
pipeline->SetVolume(30);
pipeline->SetNextUrl(url);
return AddBackgroundStream(pipeline);
}
void GstEngine::StopBackgroundStream(int id) { void GstEngine::StopBackgroundStream(int id) {
background_streams_.remove(id); // Removes last shared_ptr reference. background_streams_.remove(id); // Removes last shared_ptr reference.
} }
@ -818,16 +822,5 @@ int GstEngine::AllGloryToTheHypnotoad() {
return -1; return -1;
} }
pipeline->SetVolume(5); // Hypnotoad is *loud*. pipeline->SetVolume(5); // Hypnotoad is *loud*.
// We don't want to get metadata messages or end notifications. return AddBackgroundStream(pipeline);
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;
} }

View File

@ -140,6 +140,8 @@ class GstEngine : public Engine::Base, public BufferConsumer {
void UpdateScope(); void UpdateScope();
qint64 PruneScope(); qint64 PruneScope();
int AddBackgroundStream(boost::shared_ptr<GstEnginePipeline> pipeline);
private: private:
static const int kTimerInterval = 1000; // msec static const int kTimerInterval = 1000; // msec
static const int kPreloadGap = 1000; // msec static const int kPreloadGap = 1000; // msec