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

Unified Diff: media/base/android/media_codec_decoder.cc

Issue 1242913004: MediaCodecPlayer implementation (stage 3 - browser seek and surface change) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mtplayer-seek
Patch Set: Addressed Min comments, added unit tests. Created 5 years, 5 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 | « media/base/android/media_codec_decoder.h ('k') | media/base/android/media_codec_decoder_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/android/media_codec_decoder.cc
diff --git a/media/base/android/media_codec_decoder.cc b/media/base/android/media_codec_decoder.cc
index 5c9931f1c2b7021a92efce0d5ab5e95b146cd468..e863517109094fa170e9f1b37bd2832d7f86f00c 100644
--- a/media/base/android/media_codec_decoder.cc
+++ b/media/base/android/media_codec_decoder.cc
@@ -40,6 +40,7 @@ MediaCodecDecoder::MediaCodecDecoder(
const char* decoder_thread_name)
: media_task_runner_(media_task_runner),
decoder_thread_(decoder_thread_name),
+ needs_reconfigure_(false),
external_request_data_cb_(external_request_data_cb),
starvation_cb_(starvation_cb),
stop_done_cb_(stop_done_cb),
@@ -82,8 +83,12 @@ void MediaCodecDecoder::ReleaseDecoderResources() {
DVLOG(1) << class_name() << "::" << __FUNCTION__;
+ // Set [kInEmergencyStop| state to block already posted ProcessNextFrame().
+ SetState(kInEmergencyStop);
+
decoder_thread_.Stop(); // synchronous
- state_ = kStopped;
+
+ SetState(kStopped);
media_codec_bridge_.reset();
}
@@ -186,6 +191,19 @@ MediaCodecDecoder::ConfigStatus MediaCodecDecoder::Configure() {
// Here I assume that OnDemuxerConfigsAvailable won't come
// in the middle of demuxer data.
+ if (needs_reconfigure_) {
+ DVLOG(1) << class_name() << "::" << __FUNCTION__
+ << ": needs reconfigure, deleting MediaCodec";
+ needs_reconfigure_ = false;
+ media_codec_bridge_.reset();
+
+ // No need to release these buffers since the MediaCodec is deleted, just
+ // remove their indexes from |delayed_buffers_|.
+
+ // Shall we move |delayed_buffers_| from VideoDecoder to Decoder class?
+ ClearDelayedBuffers(false);
+ }
+
MediaCodecDecoder::ConfigStatus result;
if (media_codec_bridge_) {
DVLOG(1) << class_name() << "::" << __FUNCTION__
@@ -269,11 +287,15 @@ void MediaCodecDecoder::SyncStop() {
// After this method returns, decoder thread will not be running.
+ // Set [kInEmergencyStop| state to block already posted ProcessNextFrame().
+ SetState(kInEmergencyStop);
+
decoder_thread_.Stop(); // synchronous
- state_ = kStopped;
+
+ SetState(kStopped);
// Shall we move |delayed_buffers_| from VideoDecoder to Decoder class?
- ReleaseDelayedBuffers();
+ ClearDelayedBuffers(true); // release prior to clearing |delayed_buffers_|.
}
void MediaCodecDecoder::RequestToStop() {
@@ -313,7 +335,8 @@ void MediaCodecDecoder::OnLastFrameRendered(bool completed) {
<< " completed:" << completed;
decoder_thread_.Stop(); // synchronous
- state_ = kStopped;
+
+ SetState(kStopped);
completed_ = completed;
media_task_runner_->PostTask(FROM_HERE, stop_done_cb_);
@@ -333,10 +356,10 @@ void MediaCodecDecoder::OnDemuxerDataAvailable(const DemuxerData& data) {
: (aborted_data ? " skipped as aborted" : "");
for (const auto& unit : data.access_units)
- DVLOG(1) << class_name() << "::" << __FUNCTION__ << explain_if_skipped
+ DVLOG(2) << class_name() << "::" << __FUNCTION__ << explain_if_skipped
<< " au: " << unit;
for (const auto& configs : data.demuxer_configs)
- DVLOG(1) << class_name() << "::" << __FUNCTION__ << " configs: " << configs;
+ DVLOG(2) << class_name() << "::" << __FUNCTION__ << " configs: " << configs;
#endif
if (!is_incoming_data_invalid_ && !aborted_data)
@@ -347,7 +370,7 @@ void MediaCodecDecoder::OnDemuxerDataAvailable(const DemuxerData& data) {
// Do not request data if we got kAborted. There is no point to request the
// data after kAborted and before the OnDemuxerSeekDone.
- if (state_ == kPrefetching && !aborted_data)
+ if (GetState() == kPrefetching && !aborted_data)
PrefetchNextChunk();
}
@@ -372,6 +395,14 @@ void MediaCodecDecoder::CheckLastFrame(bool eos_encountered,
void MediaCodecDecoder::OnCodecError() {
DCHECK(media_task_runner_->BelongsToCurrentThread());
+ // Ignore codec errors from the moment surface is changed till the
Tima Vaisburd 2015/07/23 00:37:49 Also added this check.
+ // |media_codec_bridge_| is deleted.
+ if (needs_reconfigure_) {
+ DVLOG(1) << class_name() << "::" << __FUNCTION__
+ << ": needs reconfigure, ignoring";
+ return;
+ }
+
SetState(kError);
error_cb_.Run();
}
@@ -637,7 +668,7 @@ MediaCodecDecoder::DecoderState MediaCodecDecoder::GetState() const {
}
void MediaCodecDecoder::SetState(DecoderState state) {
- DVLOG(1) << class_name() << "::" << __FUNCTION__ << " " << state;
+ DVLOG(1) << class_name() << "::" << __FUNCTION__ << " " << AsString(state);
base::AutoLock lock(state_lock_);
state_ = state;
@@ -655,6 +686,7 @@ const char* MediaCodecDecoder::AsString(DecoderState state) {
RETURN_STRING(kPrefetched);
RETURN_STRING(kRunning);
RETURN_STRING(kStopping);
+ RETURN_STRING(kInEmergencyStop);
RETURN_STRING(kError);
default:
return "Unknown DecoderState";
« no previous file with comments | « media/base/android/media_codec_decoder.h ('k') | media/base/android/media_codec_decoder_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698