diff --git a/starboard/android/shared/media_decoder.cc b/starboard/android/shared/media_decoder.cc index 912ee0673b63..6f76681896ce 100644 --- a/starboard/android/shared/media_decoder.cc +++ b/starboard/android/shared/media_decoder.cc @@ -467,24 +467,20 @@ bool MediaDecoder::ProcessOneInputBuffer( } jint status; - if (event.type == Event::kWriteCodecConfig) { - if (!drm_system_ || (drm_system_ && drm_system_->IsReady())) { - status = media_codec_bridge_->QueueInputBuffer(dequeue_input_result.index, - kNoOffset, size, kNoPts, - BUFFER_FLAG_CODEC_CONFIG); - } else { - status = MEDIA_CODEC_NO_KEY; - } + if (drm_system_ && !drm_system_->IsReady()) { + // Drm system initialization is asynchronous. If there's a drm system, we + // should wait until it's initialized to avoid errors. + status = MEDIA_CODEC_NO_KEY; + } else if (event.type == Event::kWriteCodecConfig) { + status = media_codec_bridge_->QueueInputBuffer(dequeue_input_result.index, + kNoOffset, size, kNoPts, + BUFFER_FLAG_CODEC_CONFIG); } else if (event.type == Event::kWriteInputBuffer) { jlong pts_us = input_buffer->timestamp(); if (drm_system_ && input_buffer->drm_info()) { - if (drm_system_->IsReady()) { - status = media_codec_bridge_->QueueSecureInputBuffer( - dequeue_input_result.index, kNoOffset, *input_buffer->drm_info(), - pts_us); - } else { - status = MEDIA_CODEC_NO_KEY; - } + status = media_codec_bridge_->QueueSecureInputBuffer( + dequeue_input_result.index, kNoOffset, *input_buffer->drm_info(), + pts_us); } else { status = media_codec_bridge_->QueueInputBuffer( dequeue_input_result.index, kNoOffset, size, pts_us, kNoBufferFlags);