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

Unified Diff: content/browser/renderer_host/render_message_filter.cc

Issue 1372203002: Throttle media decoding after excessive Android media server crashes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressing comments Created 5 years, 3 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/browser/renderer_host/render_message_filter.cc
diff --git a/content/browser/renderer_host/render_message_filter.cc b/content/browser/renderer_host/render_message_filter.cc
index 5a1a8475f96e7cbaebd8903518aaa08050ae2fb8..2bcf19d59a0fd78993b8e445e08009d438a35580 100644
--- a/content/browser/renderer_host/render_message_filter.cc
+++ b/content/browser/renderer_host/render_message_filter.cc
@@ -62,7 +62,9 @@
#if defined(OS_POSIX)
#include "base/file_descriptor_posix.h"
#endif
+
#if defined(OS_ANDROID)
+#include "content/browser/media/android/media_throttler.h"
#include "media/base/android/webaudio_media_codec_bridge.h"
#endif
@@ -82,6 +84,13 @@ base::LazyInstance<gfx::ColorProfile>::Leaky g_color_profile =
LAZY_INSTANCE_INITIALIZER;
#endif
+#if defined(OS_ANDROID)
+void CloseWebAudioFileDescriptor(int fd) {
+ if (close(fd))
+ VLOG(1) << "Couldn't close output webaudio fd: " << strerror(errno);
+}
+#endif
+
} // namespace
RenderMessageFilter::RenderMessageFilter(
@@ -504,14 +513,24 @@ void RenderMessageFilter::OnWebAudioMediaCodec(
base::SharedMemoryHandle encoded_data_handle,
base::FileDescriptor pcm_output,
uint32_t data_size) {
- // Let a WorkerPool handle this request since the WebAudio
- // MediaCodec bridge is slow and can block while sending the data to
- // the renderer.
- base::WorkerPool::PostTask(
- FROM_HERE,
- base::Bind(&media::WebAudioMediaCodecBridge::RunWebAudioMediaCodec,
- encoded_data_handle, pcm_output, data_size),
- true);
+ if (!MediaThrottler::GetInstance()->RequestDecoderResources()) {
+ base::WorkerPool::PostTask(
+ FROM_HERE,
+ base::Bind(&CloseWebAudioFileDescriptor, pcm_output.fd),
+ true);
+ VLOG(1) << "Cannot decode audio data due to throttling";
+ } else {
+ // Let a WorkerPool handle this request since the WebAudio
+ // MediaCodec bridge is slow and can block while sending the data to
+ // the renderer.
+ base::WorkerPool::PostTask(
+ FROM_HERE,
+ base::Bind(&media::WebAudioMediaCodecBridge::RunWebAudioMediaCodec,
+ encoded_data_handle, pcm_output, data_size,
+ base::Bind(&MediaThrottler::OnDecodeRequestFinished,
+ base::Unretained(MediaThrottler::GetInstance()))),
+ true);
+ }
}
#endif

Powered by Google App Engine
This is Rietveld 408576698