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

Side by Side Diff: content/common/gpu/media/android_video_decode_accelerator.cc

Issue 1910063005: Store AVDACodecImage list in shared state, cleanup callers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix comment. 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/common/gpu/media/android_video_decode_accelerator.h" 5 #include "content/common/gpu/media/android_video_decode_accelerator.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 10
(...skipping 938 matching lines...) Expand 10 before | Expand all | Expand 10 after
949 949
950 state_ = WAITING_FOR_CODEC; 950 state_ = WAITING_FOR_CODEC;
951 951
952 // Tell the strategy that we're changing codecs. The codec itself could be 952 // Tell the strategy that we're changing codecs. The codec itself could be
953 // used normally, since we don't replace it until we're back on the main 953 // used normally, since we don't replace it until we're back on the main
954 // thread. However, if we're using an output surface, then the incoming codec 954 // thread. However, if we're using an output surface, then the incoming codec
955 // might access that surface while the main thread is drawing. Telling the 955 // might access that surface while the main thread is drawing. Telling the
956 // strategy to forget the codec avoids this. 956 // strategy to forget the codec avoids this.
957 if (media_codec_) { 957 if (media_codec_) {
958 media_codec_.reset(); 958 media_codec_.reset();
959 strategy_->CodecChanged(nullptr, output_picture_buffers_); 959 strategy_->CodecChanged(nullptr);
960 } 960 }
961 961
962 scoped_refptr<base::SingleThreadTaskRunner> task_runner = 962 scoped_refptr<base::SingleThreadTaskRunner> task_runner =
963 g_avda_timer.Pointer()->ConstructionTaskRunner(); 963 g_avda_timer.Pointer()->ConstructionTaskRunner();
964 CHECK(task_runner); 964 CHECK(task_runner);
965 965
966 base::PostTaskAndReplyWithResult( 966 base::PostTaskAndReplyWithResult(
967 task_runner.get(), FROM_HERE, 967 task_runner.get(), FROM_HERE,
968 base::Bind(&AndroidVideoDecodeAccelerator::ConfigureMediaCodecOnAnyThread, 968 base::Bind(&AndroidVideoDecodeAccelerator::ConfigureMediaCodecOnAnyThread,
969 codec_config_), 969 codec_config_),
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1001 void AndroidVideoDecodeAccelerator::OnCodecConfigured( 1001 void AndroidVideoDecodeAccelerator::OnCodecConfigured(
1002 std::unique_ptr<media::VideoCodecBridge> media_codec) { 1002 std::unique_ptr<media::VideoCodecBridge> media_codec) {
1003 DCHECK(thread_checker_.CalledOnValidThread()); 1003 DCHECK(thread_checker_.CalledOnValidThread());
1004 DCHECK_EQ(state_, WAITING_FOR_CODEC); 1004 DCHECK_EQ(state_, WAITING_FOR_CODEC);
1005 1005
1006 media_codec_ = std::move(media_codec); 1006 media_codec_ = std::move(media_codec);
1007 1007
1008 // Record one instance of the codec being initialized. 1008 // Record one instance of the codec being initialized.
1009 RecordFormatChangedMetric(FormatChangedValue::CodecInitialized); 1009 RecordFormatChangedMetric(FormatChangedValue::CodecInitialized);
1010 1010
1011 strategy_->CodecChanged(media_codec_.get(), output_picture_buffers_); 1011 strategy_->CodecChanged(media_codec_.get());
1012 1012
1013 // If we are supposed to notify that initialization is complete, then do so 1013 // If we are supposed to notify that initialization is complete, then do so
1014 // now. Otherwise, this is a reconfiguration. 1014 // now. Otherwise, this is a reconfiguration.
1015 if (deferred_initialization_pending_) { 1015 if (deferred_initialization_pending_) {
1016 NotifyInitializationComplete(!!media_codec_); 1016 NotifyInitializationComplete(!!media_codec_);
1017 deferred_initialization_pending_ = false; 1017 deferred_initialization_pending_ = false;
1018 } 1018 }
1019 1019
1020 if (!media_codec_) { 1020 if (!media_codec_) {
1021 POST_ERROR(PLATFORM_FAILURE, "Failed to create MediaCodec."); 1021 POST_ERROR(PLATFORM_FAILURE, "Failed to create MediaCodec.");
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1061 // flush()) for JB-MR2 and beyond. Prior to JB-MR2, flush() had several bugs 1061 // flush()) for JB-MR2 and beyond. Prior to JB-MR2, flush() had several bugs
1062 // (b/8125974, b/8347958) so we must delete the MediaCodec and create a new 1062 // (b/8125974, b/8347958) so we must delete the MediaCodec and create a new
1063 // one. The full reconfigure is much slower and may cause visible freezing if 1063 // one. The full reconfigure is much slower and may cause visible freezing if
1064 // done mid-stream. 1064 // done mid-stream.
1065 if (state_ == NO_ERROR && 1065 if (state_ == NO_ERROR &&
1066 base::android::BuildInfo::GetInstance()->sdk_int() >= 18) { 1066 base::android::BuildInfo::GetInstance()->sdk_int() >= 18) {
1067 DVLOG(3) << __FUNCTION__ << " Doing fast MediaCodec reset (flush)."; 1067 DVLOG(3) << __FUNCTION__ << " Doing fast MediaCodec reset (flush).";
1068 media_codec_->Reset(); 1068 media_codec_->Reset();
1069 // Since we just flushed all the output buffers, make sure that nothing is 1069 // Since we just flushed all the output buffers, make sure that nothing is
1070 // using them. 1070 // using them.
1071 strategy_->CodecChanged(media_codec_.get(), output_picture_buffers_); 1071 strategy_->CodecChanged(media_codec_.get());
1072 } else { 1072 } else {
1073 DVLOG(3) << __FUNCTION__ 1073 DVLOG(3) << __FUNCTION__
1074 << " Deleting the MediaCodec and creating a new one."; 1074 << " Deleting the MediaCodec and creating a new one.";
1075 g_avda_timer.Pointer()->StopTimer(this); 1075 g_avda_timer.Pointer()->StopTimer(this);
1076 // Changing the codec will also notify the strategy to forget about any 1076 // Changing the codec will also notify the strategy to forget about any
1077 // output buffers it has currently. 1077 // output buffers it has currently.
1078 state_ = NO_ERROR; 1078 state_ = NO_ERROR;
1079 ConfigureMediaCodecAsynchronously(); 1079 ConfigureMediaCodecAsynchronously();
1080 } 1080 }
1081 } 1081 }
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
1354 if (media::MediaCodecUtil::IsSurfaceViewOutputSupported()) { 1354 if (media::MediaCodecUtil::IsSurfaceViewOutputSupported()) {
1355 capabilities.flags |= media::VideoDecodeAccelerator::Capabilities:: 1355 capabilities.flags |= media::VideoDecodeAccelerator::Capabilities::
1356 SUPPORTS_EXTERNAL_OUTPUT_SURFACE; 1356 SUPPORTS_EXTERNAL_OUTPUT_SURFACE;
1357 } 1357 }
1358 } 1358 }
1359 1359
1360 return capabilities; 1360 return capabilities;
1361 } 1361 }
1362 1362
1363 } // namespace content 1363 } // namespace content
OLDNEW
« no previous file with comments | « content/common/gpu/media/android_video_decode_accelerator.h ('k') | content/common/gpu/media/avda_codec_image.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698