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

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

Issue 2692863011: Add ContentVideoViewOverlay to AVDA. (Closed)
Patch Set: make DequeueOutput require NO_ERROR from setsurface 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
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 incoming_bundle_->overlay = base::MakeUnique<ContentVideoViewOverlay>(
404 codec_allocator_, incoming_bundle_->surface_id, overlay_config);
381 // We have to wait for some other AVDA instance to free up the surface. 405 // We have to wait for some other AVDA instance to free up the surface.
382 // OnSurfaceAvailable will be called when it's available. 406 // OnOverlayReady will be called when it's available.
383 // Note that if we aren't deferring init, then we'll signal success, and 407 // 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 408 // 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. 409 // nobody that provides a SurfaceView requires sync init, it doesn't matter.
410 // Also remember that ContentVideoViewOverlay will not call OnOverlayReady
411 // before it returns.
386 state_ = WAITING_FOR_SURFACE; 412 state_ = WAITING_FOR_SURFACE;
387 return; 413 return;
388 } 414 }
389 415
390 // We now own the surface, so finish initialization. 416 // We're creating a SurfaceTexture.
391 InitializePictureBufferManager(); 417 InitializePictureBufferManager();
392 } 418 }
393 419
394 void AndroidVideoDecodeAccelerator::OnSurfaceAvailable(bool success) { 420 void AndroidVideoDecodeAccelerator::OnOverlayReady() {
395 DCHECK(!defer_surface_creation_); 421 DCHECK(!defer_surface_creation_);
396 DCHECK_EQ(state_, WAITING_FOR_SURFACE); 422 DCHECK_EQ(state_, WAITING_FOR_SURFACE);
397 DCHECK(incoming_bundle_); 423 DCHECK(incoming_bundle_);
398 424
399 if (!success) { 425 InitializePictureBufferManager();
400 NOTIFY_ERROR(PLATFORM_FAILURE, "Surface is not available"); 426 }
401 incoming_bundle_ = nullptr;
402 return;
403 }
404 427
405 InitializePictureBufferManager(); 428 void AndroidVideoDecodeAccelerator::OnOverlayFailed() {
429 NOTIFY_ERROR(PLATFORM_FAILURE, "Surface is not available");
406 } 430 }
407 431
408 void AndroidVideoDecodeAccelerator::InitializePictureBufferManager() { 432 void AndroidVideoDecodeAccelerator::InitializePictureBufferManager() {
409 DCHECK(!defer_surface_creation_); 433 DCHECK(!defer_surface_creation_);
410 DCHECK(incoming_bundle_); 434 DCHECK(incoming_bundle_);
411 435
412 if (!make_context_current_cb_.Run()) { 436 if (!make_context_current_cb_.Run()) {
413 NOTIFY_ERROR(PLATFORM_FAILURE, 437 NOTIFY_ERROR(PLATFORM_FAILURE,
414 "Failed to make this decoder's GL context current"); 438 "Failed to make this decoder's GL context current");
415 return; 439 return;
416 } 440 }
417 441
418 // Move |incoming_bundle_| to |codec_config_|. Our caller must set up an 442 // Move |incoming_bundle_| to |codec_config_|. Our caller must set up an
419 // incoming bundle properly, since we don't want to accidentally overwrite 443 // incoming bundle properly, since we don't want to accidentally overwrite
420 // |surface_bundle| for a codec that's being released elsewhere. 444 // |surface_bundle| for a codec that's being released elsewhere.
421 incoming_bundle_->surface = picture_buffer_manager_.Initialize(surface_id()); 445 // TODO(liberato): it doesn't make sense anymore for the PictureBufferManager
422 incoming_bundle_->surface_texture = picture_buffer_manager_.surface_texture(); 446 // to create the surface texture. We can probably make an overlay impl out
423 if (incoming_bundle_->surface.IsEmpty()) { 447 // of it, and provide the surface texture to |picture_buffer_manager_|.
448 if (incoming_bundle_->overlay) {
449 picture_buffer_manager_.InitializeForOverlay();
450 } else {
451 incoming_bundle_->surface_texture_surface =
452 picture_buffer_manager_.InitializeForSurfaceTexture();
453 incoming_bundle_->surface_texture =
454 picture_buffer_manager_.surface_texture();
455 }
456
457 if (incoming_bundle_->j_surface().is_null()) {
424 NOTIFY_ERROR(PLATFORM_FAILURE, "Codec surface is empty"); 458 NOTIFY_ERROR(PLATFORM_FAILURE, "Codec surface is empty");
425 incoming_bundle_ = nullptr; 459 incoming_bundle_ = nullptr;
426 return; 460 return;
427 } 461 }
428 462
429 // If we have a media codec, then SetSurface. If that doesn't work, then we 463 // 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. 464 // 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. 465 // If we get here with a codec, then we must setSurface.
432 if (media_codec_) { 466 if (media_codec_) {
433 // TODO(liberato): fail on api check? 467 // TODO(liberato): fail on api check?
434 if (!media_codec_->SetSurface( 468 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."); 469 NOTIFY_ERROR(PLATFORM_FAILURE, "MediaCodec failed to switch surfaces.");
437 // We're not going to use |incoming_bundle_|. 470 // We're not going to use |incoming_bundle_|.
438 } else { 471 } else {
439 // We've switched surfaces, so replace |surface_bundle|. 472 // We've switched surfaces, so replace |surface_bundle|.
440 codec_config_->surface_bundle = incoming_bundle_; 473 codec_config_->surface_bundle = incoming_bundle_;
441 // We could be in WAITING_FOR_SURFACE, but we're not anymore. 474 // We could be in WAITING_FOR_SURFACE, but we're not anymore.
442 state_ = NO_ERROR; 475 state_ = NO_ERROR;
443 } 476 }
444 incoming_bundle_ = nullptr; 477 incoming_bundle_ = nullptr;
445 return; 478 return;
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
648 681
649 // If we're waiting to switch surfaces pause output release until we have all 682 // 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 683 // picture buffers returned. This is so we can ensure the right flags are set
651 // on the picture buffers returned to the client. 684 // on the picture buffers returned to the client.
652 if (pending_surface_id_) { 685 if (pending_surface_id_) {
653 if (picture_buffer_manager_.HasUnrenderedPictures()) 686 if (picture_buffer_manager_.HasUnrenderedPictures())
654 return false; 687 return false;
655 if (!UpdateSurface()) 688 if (!UpdateSurface())
656 return false; 689 return false;
657 // If we can't allocate the incoming surface yet, then stop here. 690 // If we can't allocate the incoming surface yet, then stop here.
658 if (state_ == WAITING_FOR_SURFACE) 691 if (state_ != NO_ERROR)
659 return false; 692 return false;
660 } 693 }
661 694
662 bool eos = false; 695 bool eos = false;
663 base::TimeDelta presentation_timestamp; 696 base::TimeDelta presentation_timestamp;
664 int32_t buf_index = 0; 697 int32_t buf_index = 0;
665 do { 698 do {
666 size_t offset = 0; 699 size_t offset = 0;
667 size_t size = 0; 700 size_t size = 0;
668 701
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
1007 std::unique_ptr<MediaCodecBridge> media_codec = 1040 std::unique_ptr<MediaCodecBridge> media_codec =
1008 AVDACodecAllocator::Instance()->CreateMediaCodecSync(codec_config_); 1041 AVDACodecAllocator::Instance()->CreateMediaCodecSync(codec_config_);
1009 // Note that |media_codec| might be null, which will NotifyError. 1042 // Note that |media_codec| might be null, which will NotifyError.
1010 OnCodecConfigured(std::move(media_codec)); 1043 OnCodecConfigured(std::move(media_codec));
1011 } 1044 }
1012 1045
1013 void AndroidVideoDecodeAccelerator::OnCodecConfigured( 1046 void AndroidVideoDecodeAccelerator::OnCodecConfigured(
1014 std::unique_ptr<MediaCodecBridge> media_codec) { 1047 std::unique_ptr<MediaCodecBridge> media_codec) {
1015 DCHECK(thread_checker_.CalledOnValidThread()); 1048 DCHECK(thread_checker_.CalledOnValidThread());
1016 DCHECK(state_ == WAITING_FOR_CODEC || state_ == SURFACE_DESTROYED); 1049 DCHECK(state_ == WAITING_FOR_CODEC || state_ == SURFACE_DESTROYED);
1017
1018 // If we are supposed to notify that initialization is complete, then do so 1050 // If we are supposed to notify that initialization is complete, then do so
1019 // before returning. Otherwise, this is a reconfiguration. 1051 // before returning. Otherwise, this is a reconfiguration.
1020 1052
1021 // If |state_| changed to SURFACE_DESTROYED while we were configuring a codec, 1053 // 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. 1054 // 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 1055 // 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 1056 // of scope, on this thread. We really should post it to the proper thread
1025 // to avoid potentially hanging. 1057 // to avoid potentially hanging.
1026 if (state_ == SURFACE_DESTROYED) { 1058 if (state_ == SURFACE_DESTROYED) {
1027 if (deferred_initialization_pending_) { 1059 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. 1183 // Flush the codec if possible, or create a new one if not.
1152 if (!MediaCodecUtil::CodecNeedsFlushWorkaround(media_codec_.get())) { 1184 if (!MediaCodecUtil::CodecNeedsFlushWorkaround(media_codec_.get())) {
1153 DVLOG(3) << __func__ << " Flushing MediaCodec."; 1185 DVLOG(3) << __func__ << " Flushing MediaCodec.";
1154 media_codec_->Flush(); 1186 media_codec_->Flush();
1155 // Since we just flushed all the output buffers, make sure that nothing is 1187 // Since we just flushed all the output buffers, make sure that nothing is
1156 // using them. 1188 // using them.
1157 picture_buffer_manager_.CodecChanged(media_codec_.get()); 1189 picture_buffer_manager_.CodecChanged(media_codec_.get());
1158 } else { 1190 } else {
1159 DVLOG(3) << __func__ << " Deleting the MediaCodec and creating a new one."; 1191 DVLOG(3) << __func__ << " Deleting the MediaCodec and creating a new one.";
1160 GetManager()->StopTimer(this); 1192 GetManager()->StopTimer(this);
1193 // Note that this will release the codec, then allocate a new one. It will
1194 // not wait for the old one to finish up with the surface, which is bad.
1195 // It works (usually) because it ends up allocating the codec on the same
1196 // thread as is used to release the old one, so it's serialized anyway.
1161 ConfigureMediaCodecAsynchronously(); 1197 ConfigureMediaCodecAsynchronously();
1162 } 1198 }
1163 } 1199 }
1164 1200
1165 void AndroidVideoDecodeAccelerator::Reset() { 1201 void AndroidVideoDecodeAccelerator::Reset() {
1166 DVLOG(1) << __func__; 1202 DVLOG(1) << __func__;
1167 DCHECK(thread_checker_.CalledOnValidThread()); 1203 DCHECK(thread_checker_.CalledOnValidThread());
1168 TRACE_EVENT0("media", "AVDA::Reset"); 1204 TRACE_EVENT0("media", "AVDA::Reset");
1169 1205
1170 if (defer_surface_creation_) { 1206 if (defer_surface_creation_) {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
1227 DVLOG(1) << __func__; 1263 DVLOG(1) << __func__;
1228 DCHECK(thread_checker_.CalledOnValidThread()); 1264 DCHECK(thread_checker_.CalledOnValidThread());
1229 1265
1230 // Note that async codec construction might still be in progress. In that 1266 // 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 1267 // case, the codec will be deleted when it completes once we invalidate all
1232 // our weak refs. 1268 // our weak refs.
1233 weak_this_factory_.InvalidateWeakPtrs(); 1269 weak_this_factory_.InvalidateWeakPtrs();
1234 GetManager()->StopTimer(this); 1270 GetManager()->StopTimer(this);
1235 ReleaseCodec(); 1271 ReleaseCodec();
1236 1272
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());
liberato (no reviews please) 2017/03/08 22:48:59 one difference with this CL is that, if codec rele
1240
1241 delete this; 1273 delete this;
1242 } 1274 }
1243 1275
1244 bool AndroidVideoDecodeAccelerator::TryToSetupDecodeOnSeparateThread( 1276 bool AndroidVideoDecodeAccelerator::TryToSetupDecodeOnSeparateThread(
1245 const base::WeakPtr<Client>& decode_client, 1277 const base::WeakPtr<Client>& decode_client,
1246 const scoped_refptr<base::SingleThreadTaskRunner>& decode_task_runner) { 1278 const scoped_refptr<base::SingleThreadTaskRunner>& decode_task_runner) {
1247 return false; 1279 return false;
1248 } 1280 }
1249 1281
1250 const gfx::Size& AndroidVideoDecodeAccelerator::GetSize() const { 1282 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 || 1584 return !config_.is_encrypted() && (codec_config_->codec == kCodecVP8 ||
1553 codec_config_->codec == kCodecVP9); 1585 codec_config_->codec == kCodecVP9);
1554 } 1586 }
1555 1587
1556 bool AndroidVideoDecodeAccelerator::UpdateSurface() { 1588 bool AndroidVideoDecodeAccelerator::UpdateSurface() {
1557 DCHECK(pending_surface_id_); 1589 DCHECK(pending_surface_id_);
1558 DCHECK_NE(surface_id(), pending_surface_id_.value()); 1590 DCHECK_NE(surface_id(), pending_surface_id_.value());
1559 DCHECK(surface_id() == SurfaceManager::kNoSurfaceID || 1591 DCHECK(surface_id() == SurfaceManager::kNoSurfaceID ||
1560 pending_surface_id_.value() == SurfaceManager::kNoSurfaceID); 1592 pending_surface_id_.value() == SurfaceManager::kNoSurfaceID);
1561 1593
1562 const int previous_surface_id = surface_id();
1563 const int new_surface_id = pending_surface_id_.value(); 1594 const int new_surface_id = pending_surface_id_.value();
1564 pending_surface_id_.reset(); 1595 pending_surface_id_.reset();
1565 1596
1566 // Start surface creation. Note that if we're called via surfaceDestroyed, 1597 // Start surface creation. Note that if we're called via surfaceDestroyed,
1567 // then this must complete synchronously or it will DCHECK. Otherwise, we 1598 // 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 1599 // 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. 1600 // 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! 1601 // Note that we don't re-use |surface_bundle|, since the codec is using it!
1571 incoming_bundle_ = new AVDASurfaceBundle(new_surface_id); 1602 incoming_bundle_ = new AVDASurfaceBundle(new_surface_id);
1572 StartSurfaceCreation(); 1603 StartSurfaceCreation();
1573 if (state_ == ERROR) { 1604 if (state_ == ERROR) {
1574 // This might be called from OnSurfaceDestroyed(), so we have to release the 1605 // 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 1606 // 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 1607 // to the previous one, since failures never result in the codec using the
1577 // new surface. This is only guaranteed because of how OnCodecConfigured 1608 // new surface. This is only guaranteed because of how OnCodecConfigured
1578 // works. If it could fail after getting a codec, then this assumption 1609 // works. If it could fail after getting a codec, then this assumption
1579 // wouldn't be necessarily true anymore. 1610 // wouldn't be necessarily true anymore.
1580 // Also note that we might not have switched surfaces yet, which is also bad 1611 // Also note that we might not have switched surfaces yet, which is also bad
1581 // for OnSurfaceDestroyed, because of WAITING_FOR_SURFACE. Shouldn't 1612 // for OnSurfaceDestroyed, because of WAITING_FOR_SURFACE. Shouldn't
1582 // happen with SurfaceTexture, and OnSurfaceDestroyed checks for it. In 1613 // happen with SurfaceTexture, and OnSurfaceDestroyed checks for it. In
1583 // either case, we definitely should not still have an incoming bundle; it 1614 // either case, we definitely should not still have an incoming bundle; it
1584 // should have been dropped. 1615 // should have been dropped.
1585 DCHECK(!incoming_bundle_); 1616 DCHECK(!incoming_bundle_);
1586 ReleaseCodec(); 1617 ReleaseCodec();
1587 // We no longer own the new surface.
1588 codec_allocator_->DeallocateSurface(this, new_surface_id);
1589 } 1618 }
1590 1619
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; 1620 return state_ != ERROR;
1602 } 1621 }
1603 1622
1604 void AndroidVideoDecodeAccelerator::ReleaseCodec() { 1623 void AndroidVideoDecodeAccelerator::ReleaseCodec() {
1605 if (!media_codec_) 1624 if (!media_codec_)
1606 return; 1625 return;
1607 1626
1608 picture_buffer_manager_.CodecChanged(nullptr); 1627 picture_buffer_manager_.CodecChanged(nullptr);
1609 codec_allocator_->ReleaseMediaCodec(std::move(media_codec_), 1628 codec_allocator_->ReleaseMediaCodec(std::move(media_codec_),
1610 codec_config_->task_type, 1629 codec_config_->task_type,
1611 codec_config_->surface_bundle); 1630 codec_config_->surface_bundle);
1612 } 1631 }
1613 1632
1614 } // namespace media 1633 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698