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

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

Issue 1577953002: Motown in-proc streaming framework used to implement media services. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Changed lpcm input/output to use packets for supplying frames. Some name changes. Synced to master. Created 4 years, 11 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_sink_stage.cc
diff --git a/services/media/framework/stages/active_sink_stage.cc b/services/media/framework/stages/active_sink_stage.cc
new file mode 100644
index 0000000000000000000000000000000000000000..e99e5c01e0a83657c45c3c52472a800fa1611b1b
--- /dev/null
+++ b/services/media/framework/stages/active_sink_stage.cc
@@ -0,0 +1,46 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "services/media/framework/stages/active_sink_stage.h"
+
+namespace mojo {
+namespace media {
+
+ActiveSinkStage::ActiveSinkStage(ActiveSinkPtr sink) : sink_(sink) {
+ DCHECK(sink_);
+
+ demand_function_ = [this](Demand demand) {
+ DCHECK(update_callback_);
+ if (sink_demand_ != demand) {
+ sink_demand_ = demand;
+ update_callback_(this);
+ }
+ };
+
+ sink_->RegisterDemandCallback(demand_function_);
+}
+
+ActiveSinkStage::~ActiveSinkStage() {}
+
+bool ActiveSinkStage::Prepare(UpdateCallback update_callback) {
+ input_.Prepare(sink_->allocator(), sink_->must_allocate());
+ update_callback_ = update_callback;
+ return true;
+}
+
+void ActiveSinkStage::Prime() {
+ sink_->Prime();
+}
+
+void ActiveSinkStage::Update(Engine& engine) {
+ if (input_.packet_from_upstream()) {
+ sink_demand_ =
+ sink_->SupplyPacket(std::move(input_.packet_from_upstream()));
+ }
+
+ input_.set_demand(sink_demand_, engine);
+}
+
+} // namespace media
+} // namespace mojo

Powered by Google App Engine
This is Rietveld 408576698