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

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: Fixed the check whether surface is empty, faster stopping after SyncStop, cleanup 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
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..89aa87db5b03b1e08325b2bfbd017f2054e8de2a 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,6 +83,9 @@ void MediaCodecDecoder::ReleaseDecoderResources() {
DVLOG(1) << class_name() << "::" << __FUNCTION__;
+ // Set [kInEmergencyStop| state to block already posted ProcessNextFrame().
+ SetState(kInEmergencyStop);
+
decoder_thread_.Stop(); // synchronous
state_ = kStopped;
media_codec_bridge_.reset();
@@ -186,6 +190,16 @@ 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();
+
+ // Shall we move |delayed_buffers_| from VideoDecoder to Decoder class?
+ ClearDelayedBuffers();
+ }
+
MediaCodecDecoder::ConfigStatus result;
if (media_codec_bridge_) {
DVLOG(1) << class_name() << "::" << __FUNCTION__
@@ -269,6 +283,9 @@ 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;
@@ -333,10 +350,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)
@@ -637,7 +654,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 +672,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";

Powered by Google App Engine
This is Rietveld 408576698