Index: media/gpu/android_video_decode_accelerator.cc |
diff --git a/media/gpu/android_video_decode_accelerator.cc b/media/gpu/android_video_decode_accelerator.cc |
index d1416a11c527ac2e369c48dcd666136bc0308422..6ae1d349bcdae22ef70e6937ba594b185acefadc 100644 |
--- a/media/gpu/android_video_decode_accelerator.cc |
+++ b/media/gpu/android_video_decode_accelerator.cc |
@@ -1302,7 +1302,10 @@ void AndroidVideoDecodeAccelerator::ActualDestroy() { |
// our weak refs. |
weak_this_factory_.InvalidateWeakPtrs(); |
GetManager()->StopTimer(this); |
- ReleaseCodecAndBundle(); |
+ // We only release the codec here, in case codec allocation is in progress. |
+ // We don't want to modify |codec_config_|. Note that the ref will sill be |
+ // dropped when it completes, or when we delete |this|. |
+ ReleaseCodec(); |
delete this; |
} |
@@ -1394,7 +1397,8 @@ void AndroidVideoDecodeAccelerator::OnStopUsingOverlayImmediately( |
// If we're currently asynchronously configuring a codec, it will be destroyed |
// when configuration completes and it notices that |state_| has changed to |
- // SURFACE_DESTROYED. |
+ // SURFACE_DESTROYED. It's safe to modify |codec_config_| here, since we |
+ // checked above for WAITING_FOR_CODEC. |
state_ = SURFACE_DESTROYED; |
ReleaseCodecAndBundle(); |
@@ -1656,6 +1660,7 @@ bool AndroidVideoDecodeAccelerator::IsMediaCodecSoftwareDecodingForbidden() |
bool AndroidVideoDecodeAccelerator::UpdateSurface() { |
DCHECK(incoming_overlay_); |
+ DCHECK_NE(state_, WAITING_FOR_CODEC); |
// Start surface creation. Note that if we're called via surfaceDestroyed, |
// then this must complete synchronously or it will DCHECK. Otherwise, we |