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

Unified Diff: services/media/framework/stages/active_multistream_sink_stage.h

Issue 1678433002: Motown: Remove LPCM optimizations, fix prepare, add flush, add ActiveMultistreamSink model/stage (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 10 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_sink_stage.h
diff --git a/services/media/framework/stages/active_multistream_sink_stage.h b/services/media/framework/stages/active_multistream_sink_stage.h
new file mode 100644
index 0000000000000000000000000000000000000000..d8644cdf4d8d4da31c1c94e9207c9a34b9f468e3
--- /dev/null
+++ b/services/media/framework/stages/active_multistream_sink_stage.h
@@ -0,0 +1,86 @@
+// 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.
+
+#ifndef SERVICES_MEDIA_FRAMEWORK_STAGES_ACTIVE_MULTISTREAM_SINK_STAGE_H_
+#define SERVICES_MEDIA_FRAMEWORK_STAGES_ACTIVE_MULTISTREAM_SINK_STAGE_H_
+
+#include <list>
+#include <vector>
+
+#include "base/synchronization/lock.h"
+#include "services/media/framework/models/active_multistream_sink.h"
+#include "services/media/framework/stages/stage.h"
+
+namespace mojo {
+namespace media {
+
+// A stage that hosts an ActiveSink.
+class ActiveMultistreamSinkStage :
+ public Stage,
+ public ActiveMultistreamSinkHost {
+ public:
+ ActiveMultistreamSinkStage(std::shared_ptr<ActiveMultistreamSink> sink);
+
+ ~ActiveMultistreamSinkStage() override;
+
+ // Stage implementation.
+ size_t input_count() const override;
+
+ Input& input(size_t index) override;
+
+ size_t output_count() const override;
+
+ Output& output(size_t index) override;
+
+ PayloadAllocator* PrepareInput(size_t index) override;
+
+ void PrepareOutput(
+ size_t index,
+ PayloadAllocator* allocator,
+ const PrepareCallback& callback) override;
+
+ void Prime() override;
+
+ void Update(Engine* engine) override;
+
+ void FlushInput(
+ size_t index,
+ const FlushCallback& callback) override;
+
+ void FlushOutput(size_t index) override;
+
+ // ActiveMultistreamSinkHost implementation.
+ size_t AllocateInput() override;
+
+ size_t ReleaseInput(size_t index) override;
+
+ void UpdateDemand(size_t input_index, Demand demand) override;
+
+ private:
+ struct StageInput {
+ StageInput(size_t index) :
+ index_(index),
+ allocated_(false),
+ demand_(Demand::kNegative) {}
+ Input input_;
+ size_t index_;
+ bool allocated_;
+ Demand demand_;
+ };
+
+ void AddToUnallocatedUnsafe(StageInput* input);
+
+ std::shared_ptr<ActiveMultistreamSink> sink_;
+ Stage::UpdateCallback update_callback_;
+
+ mutable base::Lock lock_;
+ std::vector<StageInput*> inputs_;
+ std::list<StageInput*> unallocated_inputs_; // In index order.
+ std::list<StageInput*> pending_inputs_;
+};
+
+} // namespace media
+} // namespace mojo
+
+#endif // SERVICES_MEDIA_FRAMEWORK_STAGES_ACTIVE_MULTISTREAM_SINK_STAGE_H_

Powered by Google App Engine
This is Rietveld 408576698