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

Unified Diff: media/gpu/avda_shared_state.cc

Issue 1924973004: Avoid waiting on the SurfaceTexture until we need to. (Closed) Base URL: http://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comment fix. Created 4 years, 8 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/gpu/avda_shared_state.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/gpu/avda_shared_state.cc
diff --git a/media/gpu/avda_shared_state.cc b/media/gpu/avda_shared_state.cc
index f1ee105317920409762617b8f820e3e2097c4cbb..0408e243e01b3e6b26a196bf507a7c8f62722eb5 100644
--- a/media/gpu/avda_shared_state.cc
+++ b/media/gpu/avda_shared_state.cc
@@ -4,6 +4,7 @@
#include "media/gpu/avda_shared_state.h"
+#include "base/metrics/histogram_macros.h"
#include "base/time/time.h"
#include "media/gpu/avda_codec_image.h"
#include "ui/gl/gl_bindings.h"
@@ -23,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() {
@@ -47,6 +71,7 @@ void AVDASharedState::DidDetachSurfaceTexture() {
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,
@@ -67,4 +92,13 @@ AVDACodecImage* AVDASharedState::GetImageForPicture(
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 media
« no previous file with comments | « media/gpu/avda_shared_state.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698