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

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

Issue 2864683002: Don't ReleaseCodecAndBundle in AVDA::ActualDestroy. (Closed)
Patch Set: Created 3 years, 7 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "media/gpu/android_video_decode_accelerator.h" 5 #include "media/gpu/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 1284 matching lines...) Expand 10 before | Expand all | Expand 10 after
1295 1295
1296 void AndroidVideoDecodeAccelerator::ActualDestroy() { 1296 void AndroidVideoDecodeAccelerator::ActualDestroy() {
1297 DVLOG(1) << __func__; 1297 DVLOG(1) << __func__;
1298 DCHECK(thread_checker_.CalledOnValidThread()); 1298 DCHECK(thread_checker_.CalledOnValidThread());
1299 1299
1300 // Note that async codec construction might still be in progress. In that 1300 // Note that async codec construction might still be in progress. In that
1301 // case, the codec will be deleted when it completes once we invalidate all 1301 // case, the codec will be deleted when it completes once we invalidate all
1302 // our weak refs. 1302 // our weak refs.
1303 weak_this_factory_.InvalidateWeakPtrs(); 1303 weak_this_factory_.InvalidateWeakPtrs();
1304 GetManager()->StopTimer(this); 1304 GetManager()->StopTimer(this);
1305 ReleaseCodecAndBundle(); 1305 // We only release the codec here, in case codec allocation is in progress.
1306 // We don't want to modify |codec_config_|. Note that the ref will sill be
1307 // dropped when it completes, or when we delete |this|.
1308 ReleaseCodec();
1306 1309
1307 delete this; 1310 delete this;
1308 } 1311 }
1309 1312
1310 bool AndroidVideoDecodeAccelerator::TryToSetupDecodeOnSeparateThread( 1313 bool AndroidVideoDecodeAccelerator::TryToSetupDecodeOnSeparateThread(
1311 const base::WeakPtr<Client>& decode_client, 1314 const base::WeakPtr<Client>& decode_client,
1312 const scoped_refptr<base::SingleThreadTaskRunner>& decode_task_runner) { 1315 const scoped_refptr<base::SingleThreadTaskRunner>& decode_task_runner) {
1313 return false; 1316 return false;
1314 } 1317 }
1315 1318
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
1387 incoming_overlay_ = std::unique_ptr<AndroidOverlay>(); 1390 incoming_overlay_ = std::unique_ptr<AndroidOverlay>();
1388 1391
1389 UpdateSurface(); 1392 UpdateSurface();
1390 // Switching to a SurfaceTexture should never need to wait. If it does, 1393 // Switching to a SurfaceTexture should never need to wait. If it does,
1391 // then the codec might still be using the destroyed surface, which is bad. 1394 // then the codec might still be using the destroyed surface, which is bad.
1392 return; 1395 return;
1393 } 1396 }
1394 1397
1395 // If we're currently asynchronously configuring a codec, it will be destroyed 1398 // If we're currently asynchronously configuring a codec, it will be destroyed
1396 // when configuration completes and it notices that |state_| has changed to 1399 // when configuration completes and it notices that |state_| has changed to
1397 // SURFACE_DESTROYED. 1400 // SURFACE_DESTROYED. It's safe to modify |codec_config_| here, since we
1401 // checked above for WAITING_FOR_CODEC.
1398 state_ = SURFACE_DESTROYED; 1402 state_ = SURFACE_DESTROYED;
1399 ReleaseCodecAndBundle(); 1403 ReleaseCodecAndBundle();
1400 1404
1401 // If we're draining, signal completion now because the drain can no longer 1405 // If we're draining, signal completion now because the drain can no longer
1402 // proceed. 1406 // proceed.
1403 if (drain_type_) 1407 if (drain_type_)
1404 OnDrainCompleted(); 1408 OnDrainCompleted();
1405 } 1409 }
1406 1410
1407 void AndroidVideoDecodeAccelerator::InitializeCdm() { 1411 void AndroidVideoDecodeAccelerator::InitializeCdm() {
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
1649 bool AndroidVideoDecodeAccelerator::IsMediaCodecSoftwareDecodingForbidden() 1653 bool AndroidVideoDecodeAccelerator::IsMediaCodecSoftwareDecodingForbidden()
1650 const { 1654 const {
1651 // Prevent MediaCodec from using its internal software decoders when we have 1655 // Prevent MediaCodec from using its internal software decoders when we have
1652 // more secure and up to date versions in the renderer process. 1656 // more secure and up to date versions in the renderer process.
1653 return !config_.is_encrypted() && (codec_config_->codec == kCodecVP8 || 1657 return !config_.is_encrypted() && (codec_config_->codec == kCodecVP8 ||
1654 codec_config_->codec == kCodecVP9); 1658 codec_config_->codec == kCodecVP9);
1655 } 1659 }
1656 1660
1657 bool AndroidVideoDecodeAccelerator::UpdateSurface() { 1661 bool AndroidVideoDecodeAccelerator::UpdateSurface() {
1658 DCHECK(incoming_overlay_); 1662 DCHECK(incoming_overlay_);
1663 DCHECK_NE(state_, WAITING_FOR_CODEC);
1659 1664
1660 // Start surface creation. Note that if we're called via surfaceDestroyed, 1665 // Start surface creation. Note that if we're called via surfaceDestroyed,
1661 // then this must complete synchronously or it will DCHECK. Otherwise, we 1666 // then this must complete synchronously or it will DCHECK. Otherwise, we
1662 // might still be using the destroyed surface. We don't enforce this, but 1667 // might still be using the destroyed surface. We don't enforce this, but
1663 // it's worth remembering that there are cases where it's required. 1668 // it's worth remembering that there are cases where it's required.
1664 // Note that we don't re-use |surface_bundle|, since the codec is using it! 1669 // Note that we don't re-use |surface_bundle|, since the codec is using it!
1665 incoming_bundle_ = 1670 incoming_bundle_ =
1666 new AVDASurfaceBundle(std::move(incoming_overlay_.value())); 1671 new AVDASurfaceBundle(std::move(incoming_overlay_.value()));
1667 incoming_overlay_.reset(); 1672 incoming_overlay_.reset();
1668 InitializePictureBufferManager(); 1673 InitializePictureBufferManager();
(...skipping 25 matching lines...) Expand all
1694 codec_config_->task_type, 1699 codec_config_->task_type,
1695 codec_config_->surface_bundle); 1700 codec_config_->surface_bundle);
1696 } 1701 }
1697 1702
1698 void AndroidVideoDecodeAccelerator::ReleaseCodecAndBundle() { 1703 void AndroidVideoDecodeAccelerator::ReleaseCodecAndBundle() {
1699 ReleaseCodec(); 1704 ReleaseCodec();
1700 codec_config_->surface_bundle = nullptr; 1705 codec_config_->surface_bundle = nullptr;
1701 } 1706 }
1702 1707
1703 } // namespace media 1708 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698