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

Unified Diff: media/filters/android/media_codec_audio_decoder.cc

Issue 2642823004: media: Fix MediaCodecAudioDecoder reinitialization (Closed)
Patch Set: rebase Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | media/filters/audio_decoder_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/filters/android/media_codec_audio_decoder.cc
diff --git a/media/filters/android/media_codec_audio_decoder.cc b/media/filters/android/media_codec_audio_decoder.cc
index a38e57a3770d17ad947a4fed7eada3b0b9349f9b..8c59934ed3a23d4cf810b502e64e35ea46e41028 100644
--- a/media/filters/android/media_codec_audio_decoder.cc
+++ b/media/filters/android/media_codec_audio_decoder.cc
@@ -57,11 +57,25 @@ void MediaCodecAudioDecoder::Initialize(const AudioDecoderConfig& config,
const InitCB& init_cb,
const OutputCB& output_cb) {
DVLOG(1) << __func__ << ": " << config.AsHumanReadableString();
- DCHECK_EQ(state_, STATE_UNINITIALIZED);
+ DCHECK_NE(state_, STATE_WAITING_FOR_MEDIA_CRYPTO);
+
+ // Initialization and reinitialization should not be called during pending
+ // decode.
+ DCHECK(input_queue_.empty());
+ ClearInputQueue(DecodeStatus::ABORTED);
InitCB bound_init_cb = BindToCurrentLoop(init_cb);
+ if (state_ == STATE_ERROR) {
+ DVLOG(1) << "Decoder is in error state.";
+ bound_init_cb.Run(false);
+ return;
+ }
+
// We can support only the codecs that AudioCodecBridge can decode.
+ // TODO(xhwang): Get this list from AudioCodecBridge or just rely on
+ // AudioCodecBridge::ConfigureAndStart() to determine whether the codec is
+ // supported.
const bool is_codec_supported = config.codec() == kCodecVorbis ||
config.codec() == kCodecAAC ||
config.codec() == kCodecOpus;
@@ -82,11 +96,11 @@ void MediaCodecAudioDecoder::Initialize(const AudioDecoderConfig& config,
SetInitialConfiguration();
- if (config_.is_encrypted()) {
+ if (config_.is_encrypted() && !media_crypto_) {
// Postpone initialization after MediaCrypto is available.
// SetCdm uses init_cb in a method that's already bound to the current loop.
- SetCdm(cdm_context, init_cb);
SetState(STATE_WAITING_FOR_MEDIA_CRYPTO);
+ SetCdm(cdm_context, init_cb);
return;
}
« no previous file with comments | « no previous file | media/filters/audio_decoder_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698