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

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

Issue 2692863011: Add ContentVideoViewOverlay to AVDA. (Closed)
Patch Set: fixed avda unittest Created 3 years, 9 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 | « media/gpu/android_video_decode_accelerator.h ('k') | media/gpu/avda_codec_allocator.h » ('j') | 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 17 matching lines...) Expand all
28 #include "gpu/ipc/service/gpu_channel.h" 28 #include "gpu/ipc/service/gpu_channel.h"
29 #include "media/base/android/media_codec_bridge_impl.h" 29 #include "media/base/android/media_codec_bridge_impl.h"
30 #include "media/base/android/media_codec_util.h" 30 #include "media/base/android/media_codec_util.h"
31 #include "media/base/bind_to_current_loop.h" 31 #include "media/base/bind_to_current_loop.h"
32 #include "media/base/bitstream_buffer.h" 32 #include "media/base/bitstream_buffer.h"
33 #include "media/base/limits.h" 33 #include "media/base/limits.h"
34 #include "media/base/media.h" 34 #include "media/base/media.h"
35 #include "media/base/timestamp_constants.h" 35 #include "media/base/timestamp_constants.h"
36 #include "media/base/video_decoder_config.h" 36 #include "media/base/video_decoder_config.h"
37 #include "media/gpu/avda_picture_buffer_manager.h" 37 #include "media/gpu/avda_picture_buffer_manager.h"
38 #include "media/gpu/content_video_view_overlay.h"
38 #include "media/gpu/shared_memory_region.h" 39 #include "media/gpu/shared_memory_region.h"
39 #include "media/video/picture.h" 40 #include "media/video/picture.h"
40 #include "ui/gl/android/scoped_java_surface.h" 41 #include "ui/gl/android/scoped_java_surface.h"
41 #include "ui/gl/android/surface_texture.h" 42 #include "ui/gl/android/surface_texture.h"
42 #include "ui/gl/gl_bindings.h" 43 #include "ui/gl/gl_bindings.h"
43 44
44 #if defined(ENABLE_MOJO_MEDIA_IN_GPU_PROCESS) 45 #if defined(ENABLE_MOJO_MEDIA_IN_GPU_PROCESS)
45 #include "media/mojo/services/mojo_cdm_service.h" 46 #include "media/mojo/services/mojo_cdm_service.h"
46 #endif 47 #endif
47 48
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 358
358 // Fail / complete / defer initialization. 359 // Fail / complete / defer initialization.
359 return state_ != ERROR; 360 return state_ != ERROR;
360 } 361 }
361 362
362 void AndroidVideoDecodeAccelerator::StartSurfaceCreation() { 363 void AndroidVideoDecodeAccelerator::StartSurfaceCreation() {
363 // We might be called during Initialize, during deferred initialization, or 364 // We might be called during Initialize, during deferred initialization, or
364 // afterwards (::Decode, for deferred surface init, UpdateSurface). 365 // afterwards (::Decode, for deferred surface init, UpdateSurface).
365 DCHECK(incoming_bundle_); 366 DCHECK(incoming_bundle_);
366 367
368 // We should not yet have an overlay.
369 DCHECK(!incoming_bundle_->overlay);
370
371 // Note that we don't enforce that for any SurfaceTexture or its Surface,
372 // since there might be a codec that's using them. They'll get cleared
373 // later, in InitializePictureBufferManager.
374
367 // If surface creation is deferred, then do nothing except signal that init 375 // If surface creation is deferred, then do nothing except signal that init
368 // is complete, if needed. We might still fail to get a surface or codec, 376 // is complete, if needed. We might still fail to get a surface or codec,
369 // which would normally be an init error. Since we're deferring init until a 377 // which would normally be an init error. Since we're deferring init until a
370 // decode to save resources, though, we're signaling success now. If we're 378 // decode to save resources, though, we're signaling success now. If we're
371 // wrong, then decoding might fail when we might have been able to use a 379 // wrong, then decoding might fail when we might have been able to use a
372 // fallback renderer in WMPI if we failed init. 380 // fallback renderer in WMPI if we failed init.
373 if (defer_surface_creation_) { 381 if (defer_surface_creation_) {
374 if (deferred_initialization_pending_) 382 if (deferred_initialization_pending_)
375 NotifyInitializationSucceeded(); 383 NotifyInitializationSucceeded();
376 384
377 return; 385 return;
378 } 386 }
379 387
380 if (!codec_allocator_->AllocateSurface(this, incoming_bundle_->surface_id)) { 388 if (incoming_bundle_->surface_id != SurfaceManager::kNoSurfaceID) {
389 // Create the overlay. Note that it will never call us back immediately.
390 // It will post when the surface is available.
391 AndroidOverlay::Config overlay_config;
392 // We use weak ptrs here since |overlay| can outlive us, if we send it for
393 // async codec config.
394 overlay_config.ready_cb =
395 base::Bind(&AndroidVideoDecodeAccelerator::OnOverlayReady,
396 weak_this_factory_.GetWeakPtr());
397 overlay_config.failed_cb =
398 base::Bind(&AndroidVideoDecodeAccelerator::OnOverlayFailed,
399 weak_this_factory_.GetWeakPtr());
400 overlay_config.destroyed_cb =
401 base::Bind(&AndroidVideoDecodeAccelerator::OnSurfaceDestroyed,
402 weak_this_factory_.GetWeakPtr());
403 // TODO(liberato): make |surface_id| the overlay config token. If we're
404 // using CVV, then we'll need a CVV factory impl that understands it.
405 incoming_bundle_->overlay = base::MakeUnique<ContentVideoViewOverlay>(
406 codec_allocator_, incoming_bundle_->surface_id, overlay_config);
381 // We have to wait for some other AVDA instance to free up the surface. 407 // We have to wait for some other AVDA instance to free up the surface.
382 // OnSurfaceAvailable will be called when it's available. 408 // OnOverlayReady will be called when it's available.
383 // Note that if we aren't deferring init, then we'll signal success, and 409 // Note that if we aren't deferring init, then we'll signal success, and
384 // if we fail later then it will fail decoding instead. However, since 410 // if we fail later then it will fail decoding instead. However, since
385 // nobody that provides a SurfaceView requires sync init, it doesn't matter. 411 // nobody that provides a SurfaceView requires sync init, it doesn't matter.
412 // Also remember that ContentVideoViewOverlay will not call OnOverlayReady
413 // before it returns.
386 state_ = WAITING_FOR_SURFACE; 414 state_ = WAITING_FOR_SURFACE;
387 return; 415 return;
388 } 416 }
389 417
390 // We now own the surface, so finish initialization. 418 // We're creating a SurfaceTexture.
391 InitializePictureBufferManager(); 419 InitializePictureBufferManager();
392 } 420 }
393 421
394 void AndroidVideoDecodeAccelerator::OnSurfaceAvailable(bool success) { 422 void AndroidVideoDecodeAccelerator::OnOverlayReady() {
395 DCHECK(!defer_surface_creation_); 423 DCHECK(!defer_surface_creation_);
396 DCHECK_EQ(state_, WAITING_FOR_SURFACE); 424 DCHECK_EQ(state_, WAITING_FOR_SURFACE);
397 DCHECK(incoming_bundle_); 425 DCHECK(incoming_bundle_);
398 426
399 if (!success) { 427 InitializePictureBufferManager();
400 NOTIFY_ERROR(PLATFORM_FAILURE, "Surface is not available"); 428 }
401 incoming_bundle_ = nullptr;
402 return;
403 }
404 429
405 InitializePictureBufferManager(); 430 void AndroidVideoDecodeAccelerator::OnOverlayFailed() {
431 NOTIFY_ERROR(PLATFORM_FAILURE, "Surface is not available");
406 } 432 }
407 433
408 void AndroidVideoDecodeAccelerator::InitializePictureBufferManager() { 434 void AndroidVideoDecodeAccelerator::InitializePictureBufferManager() {
409 DCHECK(!defer_surface_creation_); 435 DCHECK(!defer_surface_creation_);
410 DCHECK(incoming_bundle_); 436 DCHECK(incoming_bundle_);
411 437
412 if (!make_context_current_cb_.Run()) { 438 if (!make_context_current_cb_.Run()) {
413 NOTIFY_ERROR(PLATFORM_FAILURE, 439 NOTIFY_ERROR(PLATFORM_FAILURE,
414 "Failed to make this decoder's GL context current"); 440 "Failed to make this decoder's GL context current");
441 incoming_bundle_ = nullptr;
415 return; 442 return;
416 } 443 }
417 444
418 // Move |incoming_bundle_| to |codec_config_|. Our caller must set up an 445 // Move |incoming_bundle_| to |codec_config_|. Our caller must set up an
419 // incoming bundle properly, since we don't want to accidentally overwrite 446 // incoming bundle properly, since we don't want to accidentally overwrite
420 // |surface_bundle| for a codec that's being released elsewhere. 447 // |surface_bundle| for a codec that's being released elsewhere.
421 incoming_bundle_->surface = picture_buffer_manager_.Initialize(surface_id()); 448 // TODO(liberato): it doesn't make sense anymore for the PictureBufferManager
422 incoming_bundle_->surface_texture = picture_buffer_manager_.surface_texture(); 449 // to create the surface texture. We can probably make an overlay impl out
423 if (incoming_bundle_->surface.IsEmpty()) { 450 // of it, and provide the surface texture to |picture_buffer_manager_|.
424 NOTIFY_ERROR(PLATFORM_FAILURE, "Codec surface is empty"); 451 if (incoming_bundle_->overlay) {
425 incoming_bundle_ = nullptr; 452 picture_buffer_manager_.InitializeForOverlay();
426 return; 453 } else {
454 incoming_bundle_->surface_texture_surface =
455 picture_buffer_manager_.InitializeForSurfaceTexture();
456 incoming_bundle_->surface_texture =
457 picture_buffer_manager_.surface_texture();
458
459 if (!incoming_bundle_->surface_texture) {
460 NOTIFY_ERROR(PLATFORM_FAILURE, "Could not allocate surface texture");
461 incoming_bundle_ = nullptr;
462 return;
463 }
427 } 464 }
428 465
429 // If we have a media codec, then SetSurface. If that doesn't work, then we 466 // If we have a media codec, then SetSurface. If that doesn't work, then we
430 // do not try to allocate a new codec; we might not be at a keyframe, etc. 467 // do not try to allocate a new codec; we might not be at a keyframe, etc.
431 // If we get here with a codec, then we must setSurface. 468 // If we get here with a codec, then we must setSurface.
432 if (media_codec_) { 469 if (media_codec_) {
433 // TODO(liberato): fail on api check? 470 // TODO(liberato): fail on api check?
434 if (!media_codec_->SetSurface( 471 if (!media_codec_->SetSurface(incoming_bundle_->j_surface().obj())) {
435 incoming_bundle_->surface.j_surface().obj())) {
436 NOTIFY_ERROR(PLATFORM_FAILURE, "MediaCodec failed to switch surfaces."); 472 NOTIFY_ERROR(PLATFORM_FAILURE, "MediaCodec failed to switch surfaces.");
437 // We're not going to use |incoming_bundle_|. 473 // We're not going to use |incoming_bundle_|.
438 } else { 474 } else {
439 // We've switched surfaces, so replace |surface_bundle|. 475 // We've switched surfaces, so replace |surface_bundle|.
440 codec_config_->surface_bundle = incoming_bundle_; 476 codec_config_->surface_bundle = incoming_bundle_;
441 // We could be in WAITING_FOR_SURFACE, but we're not anymore. 477 // We could be in WAITING_FOR_SURFACE, but we're not anymore.
442 state_ = NO_ERROR; 478 state_ = NO_ERROR;
443 } 479 }
444 incoming_bundle_ = nullptr; 480 incoming_bundle_ = nullptr;
445 return; 481 return;
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
648 684
649 // If we're waiting to switch surfaces pause output release until we have all 685 // If we're waiting to switch surfaces pause output release until we have all
650 // picture buffers returned. This is so we can ensure the right flags are set 686 // picture buffers returned. This is so we can ensure the right flags are set
651 // on the picture buffers returned to the client. 687 // on the picture buffers returned to the client.
652 if (pending_surface_id_) { 688 if (pending_surface_id_) {
653 if (picture_buffer_manager_.HasUnrenderedPictures()) 689 if (picture_buffer_manager_.HasUnrenderedPictures())
654 return false; 690 return false;
655 if (!UpdateSurface()) 691 if (!UpdateSurface())
656 return false; 692 return false;
657 // If we can't allocate the incoming surface yet, then stop here. 693 // If we can't allocate the incoming surface yet, then stop here.
658 if (state_ == WAITING_FOR_SURFACE) 694 if (state_ != NO_ERROR)
659 return false; 695 return false;
660 } 696 }
661 697
662 bool eos = false; 698 bool eos = false;
663 base::TimeDelta presentation_timestamp; 699 base::TimeDelta presentation_timestamp;
664 int32_t buf_index = 0; 700 int32_t buf_index = 0;
665 do { 701 do {
666 size_t offset = 0; 702 size_t offset = 0;
667 size_t size = 0; 703 size_t size = 0;
668 704
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
1007 std::unique_ptr<MediaCodecBridge> media_codec = 1043 std::unique_ptr<MediaCodecBridge> media_codec =
1008 AVDACodecAllocator::Instance()->CreateMediaCodecSync(codec_config_); 1044 AVDACodecAllocator::Instance()->CreateMediaCodecSync(codec_config_);
1009 // Note that |media_codec| might be null, which will NotifyError. 1045 // Note that |media_codec| might be null, which will NotifyError.
1010 OnCodecConfigured(std::move(media_codec)); 1046 OnCodecConfigured(std::move(media_codec));
1011 } 1047 }
1012 1048
1013 void AndroidVideoDecodeAccelerator::OnCodecConfigured( 1049 void AndroidVideoDecodeAccelerator::OnCodecConfigured(
1014 std::unique_ptr<MediaCodecBridge> media_codec) { 1050 std::unique_ptr<MediaCodecBridge> media_codec) {
1015 DCHECK(thread_checker_.CalledOnValidThread()); 1051 DCHECK(thread_checker_.CalledOnValidThread());
1016 DCHECK(state_ == WAITING_FOR_CODEC || state_ == SURFACE_DESTROYED); 1052 DCHECK(state_ == WAITING_FOR_CODEC || state_ == SURFACE_DESTROYED);
1017
1018 // If we are supposed to notify that initialization is complete, then do so 1053 // If we are supposed to notify that initialization is complete, then do so
1019 // before returning. Otherwise, this is a reconfiguration. 1054 // before returning. Otherwise, this is a reconfiguration.
1020 1055
1021 // If |state_| changed to SURFACE_DESTROYED while we were configuring a codec, 1056 // If |state_| changed to SURFACE_DESTROYED while we were configuring a codec,
1022 // then the codec is already invalid so we return early and drop it. 1057 // then the codec is already invalid so we return early and drop it.
1023 // TODO(liberato): We're going to drop the codec when |media_codec| goes out 1058 // TODO(liberato): We're going to drop the codec when |media_codec| goes out
1024 // of scope, on this thread. We really should post it to the proper thread 1059 // of scope, on this thread. We really should post it to the proper thread
1025 // to avoid potentially hanging. 1060 // to avoid potentially hanging.
1026 if (state_ == SURFACE_DESTROYED) { 1061 if (state_ == SURFACE_DESTROYED) {
1027 if (deferred_initialization_pending_) { 1062 if (deferred_initialization_pending_) {
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
1151 // Flush the codec if possible, or create a new one if not. 1186 // Flush the codec if possible, or create a new one if not.
1152 if (!MediaCodecUtil::CodecNeedsFlushWorkaround(media_codec_.get())) { 1187 if (!MediaCodecUtil::CodecNeedsFlushWorkaround(media_codec_.get())) {
1153 DVLOG(3) << __func__ << " Flushing MediaCodec."; 1188 DVLOG(3) << __func__ << " Flushing MediaCodec.";
1154 media_codec_->Flush(); 1189 media_codec_->Flush();
1155 // Since we just flushed all the output buffers, make sure that nothing is 1190 // Since we just flushed all the output buffers, make sure that nothing is
1156 // using them. 1191 // using them.
1157 picture_buffer_manager_.CodecChanged(media_codec_.get()); 1192 picture_buffer_manager_.CodecChanged(media_codec_.get());
1158 } else { 1193 } else {
1159 DVLOG(3) << __func__ << " Deleting the MediaCodec and creating a new one."; 1194 DVLOG(3) << __func__ << " Deleting the MediaCodec and creating a new one.";
1160 GetManager()->StopTimer(this); 1195 GetManager()->StopTimer(this);
1196 // Note that this will release the codec, then allocate a new one. It will
1197 // not wait for the old one to finish up with the surface, which is bad.
1198 // It works (usually) because it ends up allocating the codec on the same
1199 // thread as is used to release the old one, so it's serialized anyway.
1161 ConfigureMediaCodecAsynchronously(); 1200 ConfigureMediaCodecAsynchronously();
1162 } 1201 }
1163 } 1202 }
1164 1203
1165 void AndroidVideoDecodeAccelerator::Reset() { 1204 void AndroidVideoDecodeAccelerator::Reset() {
1166 DVLOG(1) << __func__; 1205 DVLOG(1) << __func__;
1167 DCHECK(thread_checker_.CalledOnValidThread()); 1206 DCHECK(thread_checker_.CalledOnValidThread());
1168 TRACE_EVENT0("media", "AVDA::Reset"); 1207 TRACE_EVENT0("media", "AVDA::Reset");
1169 1208
1170 if (defer_surface_creation_) { 1209 if (defer_surface_creation_) {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
1227 DVLOG(1) << __func__; 1266 DVLOG(1) << __func__;
1228 DCHECK(thread_checker_.CalledOnValidThread()); 1267 DCHECK(thread_checker_.CalledOnValidThread());
1229 1268
1230 // Note that async codec construction might still be in progress. In that 1269 // Note that async codec construction might still be in progress. In that
1231 // case, the codec will be deleted when it completes once we invalidate all 1270 // case, the codec will be deleted when it completes once we invalidate all
1232 // our weak refs. 1271 // our weak refs.
1233 weak_this_factory_.InvalidateWeakPtrs(); 1272 weak_this_factory_.InvalidateWeakPtrs();
1234 GetManager()->StopTimer(this); 1273 GetManager()->StopTimer(this);
1235 ReleaseCodec(); 1274 ReleaseCodec();
1236 1275
1237 // We no longer care about |surface_id|, in case we did before. It's okay
1238 // if we have no surface and/or weren't the owner or a waiter.
1239 codec_allocator_->DeallocateSurface(this, surface_id());
1240
1241 delete this; 1276 delete this;
1242 } 1277 }
1243 1278
1244 bool AndroidVideoDecodeAccelerator::TryToSetupDecodeOnSeparateThread( 1279 bool AndroidVideoDecodeAccelerator::TryToSetupDecodeOnSeparateThread(
1245 const base::WeakPtr<Client>& decode_client, 1280 const base::WeakPtr<Client>& decode_client,
1246 const scoped_refptr<base::SingleThreadTaskRunner>& decode_task_runner) { 1281 const scoped_refptr<base::SingleThreadTaskRunner>& decode_task_runner) {
1247 return false; 1282 return false;
1248 } 1283 }
1249 1284
1250 const gfx::Size& AndroidVideoDecodeAccelerator::GetSize() const { 1285 const gfx::Size& AndroidVideoDecodeAccelerator::GetSize() const {
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
1552 return !config_.is_encrypted() && (codec_config_->codec == kCodecVP8 || 1587 return !config_.is_encrypted() && (codec_config_->codec == kCodecVP8 ||
1553 codec_config_->codec == kCodecVP9); 1588 codec_config_->codec == kCodecVP9);
1554 } 1589 }
1555 1590
1556 bool AndroidVideoDecodeAccelerator::UpdateSurface() { 1591 bool AndroidVideoDecodeAccelerator::UpdateSurface() {
1557 DCHECK(pending_surface_id_); 1592 DCHECK(pending_surface_id_);
1558 DCHECK_NE(surface_id(), pending_surface_id_.value()); 1593 DCHECK_NE(surface_id(), pending_surface_id_.value());
1559 DCHECK(surface_id() == SurfaceManager::kNoSurfaceID || 1594 DCHECK(surface_id() == SurfaceManager::kNoSurfaceID ||
1560 pending_surface_id_.value() == SurfaceManager::kNoSurfaceID); 1595 pending_surface_id_.value() == SurfaceManager::kNoSurfaceID);
1561 1596
1562 const int previous_surface_id = surface_id();
1563 const int new_surface_id = pending_surface_id_.value(); 1597 const int new_surface_id = pending_surface_id_.value();
1564 pending_surface_id_.reset(); 1598 pending_surface_id_.reset();
1565 1599
1566 // Start surface creation. Note that if we're called via surfaceDestroyed, 1600 // Start surface creation. Note that if we're called via surfaceDestroyed,
1567 // then this must complete synchronously or it will DCHECK. Otherwise, we 1601 // then this must complete synchronously or it will DCHECK. Otherwise, we
1568 // might still be using the destroyed surface. We don't enforce this, but 1602 // might still be using the destroyed surface. We don't enforce this, but
1569 // it's worth remembering that there are cases where it's required. 1603 // it's worth remembering that there are cases where it's required.
1570 // Note that we don't re-use |surface_bundle|, since the codec is using it! 1604 // Note that we don't re-use |surface_bundle|, since the codec is using it!
1571 incoming_bundle_ = new AVDASurfaceBundle(new_surface_id); 1605 incoming_bundle_ = new AVDASurfaceBundle(new_surface_id);
1572 StartSurfaceCreation(); 1606 StartSurfaceCreation();
1573 if (state_ == ERROR) { 1607 if (state_ == ERROR) {
1574 // This might be called from OnSurfaceDestroyed(), so we have to release the 1608 // This might be called from OnSurfaceDestroyed(), so we have to release the
1575 // MediaCodec if we failed to switch the surface. We reset the surface ID 1609 // MediaCodec if we failed to switch the surface. We reset the surface ID
1576 // to the previous one, since failures never result in the codec using the 1610 // to the previous one, since failures never result in the codec using the
1577 // new surface. This is only guaranteed because of how OnCodecConfigured 1611 // new surface. This is only guaranteed because of how OnCodecConfigured
1578 // works. If it could fail after getting a codec, then this assumption 1612 // works. If it could fail after getting a codec, then this assumption
1579 // wouldn't be necessarily true anymore. 1613 // wouldn't be necessarily true anymore.
1580 // Also note that we might not have switched surfaces yet, which is also bad 1614 // Also note that we might not have switched surfaces yet, which is also bad
1581 // for OnSurfaceDestroyed, because of WAITING_FOR_SURFACE. Shouldn't 1615 // for OnSurfaceDestroyed, because of WAITING_FOR_SURFACE. Shouldn't
1582 // happen with SurfaceTexture, and OnSurfaceDestroyed checks for it. In 1616 // happen with SurfaceTexture, and OnSurfaceDestroyed checks for it. In
1583 // either case, we definitely should not still have an incoming bundle; it 1617 // either case, we definitely should not still have an incoming bundle; it
1584 // should have been dropped. 1618 // should have been dropped.
1585 DCHECK(!incoming_bundle_); 1619 DCHECK(!incoming_bundle_);
1586 ReleaseCodec(); 1620 ReleaseCodec();
1587 // We no longer own the new surface.
1588 codec_allocator_->DeallocateSurface(this, new_surface_id);
1589 } 1621 }
1590 1622
1591 // Regardless of whether we succeeded, we no longer own the previous surface.
1592 // This is the only case where we start a new incoming bundle, and we maintain
1593 // the property that |incoming_bundle_| is the one that we own, as documented
1594 // for surface_id().
1595 // It would be nice if the outgoing surface bundle did this.
1596 // TODO(liberato): It could, but the CVV implementation of AndroidOverlay
1597 // will do it too when the bundle holding it is dropped. We'll do it this way
1598 // until then, just to minimize changes.
1599 codec_allocator_->DeallocateSurface(this, previous_surface_id);
1600
1601 return state_ != ERROR; 1623 return state_ != ERROR;
1602 } 1624 }
1603 1625
1604 void AndroidVideoDecodeAccelerator::ReleaseCodec() { 1626 void AndroidVideoDecodeAccelerator::ReleaseCodec() {
1605 if (!media_codec_) 1627 if (!media_codec_)
1606 return; 1628 return;
1607 1629
1608 picture_buffer_manager_.CodecChanged(nullptr); 1630 picture_buffer_manager_.CodecChanged(nullptr);
1609 codec_allocator_->ReleaseMediaCodec(std::move(media_codec_), 1631 codec_allocator_->ReleaseMediaCodec(std::move(media_codec_),
1610 codec_config_->task_type, 1632 codec_config_->task_type,
1611 codec_config_->surface_bundle); 1633 codec_config_->surface_bundle);
1612 } 1634 }
1613 1635
1614 } // namespace media 1636 } // namespace media
OLDNEW
« no previous file with comments | « media/gpu/android_video_decode_accelerator.h ('k') | media/gpu/avda_codec_allocator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698