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

Unified Diff: content/common/gpu/media/avda_shared_state.cc

Issue 1963773003: Merge to M51: Various fixes to prevent playback hang on MotoX. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2704
Patch Set: Created 4 years, 7 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: content/common/gpu/media/avda_shared_state.cc
diff --git a/content/common/gpu/media/avda_shared_state.cc b/content/common/gpu/media/avda_shared_state.cc
index 7746254fee94c3ecdc1f3bc7d787998d097850f3..be70693534a000e4d5bb6002716c6d258ebdbe66 100644
--- a/content/common/gpu/media/avda_shared_state.cc
+++ b/content/common/gpu/media/avda_shared_state.cc
@@ -4,7 +4,9 @@
#include "content/common/gpu/media/avda_shared_state.h"
+#include "base/metrics/histogram_macros.h"
#include "base/time/time.h"
+#include "content/common/gpu/media/avda_codec_image.h"
#include "ui/gl/gl_bindings.h"
#include "ui/gl/scoped_make_current.h"
@@ -22,10 +24,33 @@ void AVDASharedState::SignalFrameAvailable() {
}
void AVDASharedState::WaitForFrameAvailable() {
- // 10msec covers >99.9% of cases, so just wait for up to that much before
+ DCHECK(!release_time_.is_null());
+
+ // 5msec covers >99.9% of cases, so just wait for up to that much before
// giving up. If an error occurs, we might not ever get a notification.
- const base::TimeDelta max_wait_time(base::TimeDelta::FromMilliseconds(10));
- frame_available_event_.TimedWait(max_wait_time);
+ const base::TimeDelta max_wait = base::TimeDelta::FromMilliseconds(5);
+ const base::TimeTicks call_time = base::TimeTicks::Now();
+ const base::TimeDelta elapsed = call_time - release_time_;
+ const base::TimeDelta remaining = max_wait - elapsed;
+ release_time_ = base::TimeTicks();
+
+ if (remaining <= base::TimeDelta()) {
+ if (!frame_available_event_.IsSignaled()) {
+ DVLOG(1) << "Deferred WaitForFrameAvailable() timed out, elapsed: "
+ << elapsed.InMillisecondsF() << "ms";
+ }
+ return;
+ }
+
+ DCHECK_LE(remaining, max_wait);
+ SCOPED_UMA_HISTOGRAM_TIMER("Media.AvdaCodecImage.WaitTimeForFrame");
+ if (!frame_available_event_.TimedWait(remaining)) {
+ DVLOG(1) << "WaitForFrameAvailable() timed out, elapsed: "
+ << elapsed.InMillisecondsF()
+ << "ms, additionally waited: " << remaining.InMillisecondsF()
+ << "ms, total: " << (elapsed + remaining).InMillisecondsF()
+ << "ms";
+ }
}
void AVDASharedState::DidAttachSurfaceTexture() {
@@ -43,4 +68,37 @@ void AVDASharedState::DidDetachSurfaceTexture() {
surface_texture_is_attached_ = false;
}
+void AVDASharedState::CodecChanged(media::MediaCodecBridge* codec) {
+ for (auto& image_kv : codec_images_)
+ image_kv.second->CodecChanged(codec);
+ release_time_ = base::TimeTicks();
+}
+
+void AVDASharedState::SetImageForPicture(int picture_buffer_id,
+ AVDACodecImage* image) {
+ if (!image) {
+ DCHECK(codec_images_.find(picture_buffer_id) != codec_images_.end());
+ codec_images_.erase(picture_buffer_id);
+ return;
+ }
+
+ DCHECK(codec_images_.find(picture_buffer_id) == codec_images_.end());
+ codec_images_[picture_buffer_id] = image;
+}
+
+AVDACodecImage* AVDASharedState::GetImageForPicture(
+ int picture_buffer_id) const {
+ auto it = codec_images_.find(picture_buffer_id);
+ return it == codec_images_.end() ? nullptr : it->second;
+}
+
+void AVDASharedState::RenderCodecBufferToSurfaceTexture(
+ media::MediaCodecBridge* codec,
+ int codec_buffer_index) {
+ if (!release_time_.is_null())
+ WaitForFrameAvailable();
+ codec->ReleaseOutputBuffer(codec_buffer_index, true);
+ release_time_ = base::TimeTicks::Now();
+}
+
} // namespace content
« no previous file with comments | « content/common/gpu/media/avda_shared_state.h ('k') | content/common/gpu/media/gpu_video_decode_accelerator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698