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

Unified Diff: chromecast/media/cma/backend/media_pipeline_backend_manager.cc

Issue 2173593002: [Chromecast] Limit number of concurrent audio and video decoders (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: use enum for decoder type Created 4 years, 5 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: chromecast/media/cma/backend/media_pipeline_backend_manager.cc
diff --git a/chromecast/media/cma/backend/media_pipeline_backend_manager.cc b/chromecast/media/cma/backend/media_pipeline_backend_manager.cc
index 49227383e414f2b37af46db4d778c4db3cec5e49..c8e1b22a242badd5ac4f2a12526e8fed21e361a9 100644
--- a/chromecast/media/cma/backend/media_pipeline_backend_manager.cc
+++ b/chromecast/media/cma/backend/media_pipeline_backend_manager.cc
@@ -16,6 +16,9 @@ namespace media {
MediaPipelineBackendManager::MediaPipelineBackendManager(
scoped_refptr<base::SingleThreadTaskRunner> media_task_runner)
: media_task_runner_(std::move(media_task_runner)) {
+ DCHECK_EQ(2, NUM_DECODER_TYPES);
+ decoder_count_[AUDIO_DECODER] = 0;
+ decoder_count_[VIDEO_DECODER] = 0;
}
MediaPipelineBackendManager::~MediaPipelineBackendManager() {
@@ -42,6 +45,26 @@ MediaPipelineBackendManager::CreateMediaPipelineBackend(
return backend_ptr;
}
+bool MediaPipelineBackendManager::IncrementDecoderCount(DecoderType type) {
+ DCHECK(media_task_runner_->BelongsToCurrentThread());
+ DCHECK(type < NUM_DECODER_TYPES);
+ const int limit = (type == AUDIO_DECODER) ? 2 : 1;
+ if (decoder_count_[type] >= limit) {
+ LOG(WARNING) << "Decoder limit reached for type " << type;
+ return false;
+ }
+
+ ++decoder_count_[type];
+ return true;
+}
+
+void MediaPipelineBackendManager::DecrementDecoderCount(DecoderType type) {
+ DCHECK(media_task_runner_->BelongsToCurrentThread());
+ DCHECK(type < NUM_DECODER_TYPES);
+ DCHECK(decoder_count_[type] > 0);
+ decoder_count_[type]--;
+}
+
void MediaPipelineBackendManager::OnMediaPipelineBackendDestroyed(
const MediaPipelineBackend* backend) {
DCHECK(media_task_runner_->BelongsToCurrentThread());

Powered by Google App Engine
This is Rietveld 408576698