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);
}
int GstEngine::AddBackgroundStream(const QUrl& url) {
shared_ptr<GstEnginePipeline> pipeline = CreatePipeline(url);
if (!pipeline) {
return -1;
}
pipeline->SetVolume(30);
int GstEngine::AddBackgroundStream(shared_ptr<GstEnginePipeline> 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<GstEnginePipeline> 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);
}

View File

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