Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(26)

Unified Diff: services/media/framework/stages/active_multistream_source_stage.cc

Issue 1923763002: Motown: Ffmpeg video decoder (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: services/media/framework/stages/active_multistream_source_stage.cc
diff --git a/services/media/framework/stages/active_multistream_source_stage.cc b/services/media/framework/stages/active_multistream_source_stage.cc
index a6859bbb4ba9bd8b3c78621a0b487d5279107d33..4dcbd2d5cf02f1fcee0563a2a502e81deb55aa58 100644
--- a/services/media/framework/stages/active_multistream_source_stage.cc
+++ b/services/media/framework/stages/active_multistream_source_stage.cc
@@ -15,9 +15,13 @@ ActiveMultistreamSourceStage::ActiveMultistreamSourceStage(
outputs_.resize(source->stream_count());
supply_function_ = [this](size_t output_index, PacketPtr packet) {
+ lock_.Acquire();
DCHECK(!cached_packet_) << "source supplied unrequested packet";
DCHECK(output_index < outputs_.size());
DCHECK(packet);
+ DCHECK(packet_request_outstanding_);
+
+ packet_request_outstanding_ = false;
cached_packet_output_index_ = output_index;
cached_packet_ = std::move(packet);
@@ -28,7 +32,10 @@ ActiveMultistreamSourceStage::ActiveMultistreamSourceStage(
Output& output = outputs_[cached_packet_output_index_];
if (output.demand() != Demand::kNegative) {
+ lock_.Release();
RequestUpdate();
+ } else {
+ lock_.Release();
}
};
@@ -82,6 +89,7 @@ void ActiveMultistreamSourceStage::UnprepareOutput(
}
void ActiveMultistreamSourceStage::Update(Engine* engine) {
+ base::AutoLock lock(lock_);
DCHECK(engine);
if (cached_packet_) {
@@ -92,9 +100,11 @@ void ActiveMultistreamSourceStage::Update(Engine* engine) {
}
}
- if (!cached_packet_ && HasPositiveDemand(outputs_)) {
+ if (!cached_packet_ && HasPositiveDemand(outputs_) &&
+ !packet_request_outstanding_) {
// We have no cached packet and positive demand. Request a packet.
source_->RequestPacket();
+ packet_request_outstanding_ = true;
}
}
@@ -105,12 +115,14 @@ void ActiveMultistreamSourceStage::FlushInput(
}
void ActiveMultistreamSourceStage::FlushOutput(size_t index) {
+ base::AutoLock lock(lock_);
DCHECK(index < outputs_.size());
DCHECK(source_);
outputs_[index].Flush();
cached_packet_.reset(nullptr);
cached_packet_output_index_ = 0;
ended_streams_ = 0;
+ packet_request_outstanding_ = false;
}
} // namespace media

Powered by Google App Engine
This is Rietveld 408576698