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

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: new infobar text per UI review Created 5 years, 2 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 | « content/browser/media/android/media_throttler.cc ('k') | content/content_browser.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 d59828867501efea76a2013ea99b340c46eec4fc..efe1ce65b76f695e0aa5346c66e84ed3959af0a7 100644
--- a/content/browser/renderer_host/render_message_filter.cc
+++ b/content/browser/renderer_host/render_message_filter.cc
@@ -73,6 +73,7 @@
#endif
#if defined(OS_ANDROID)
+#include "content/browser/media/android/media_throttler.h"
#include "media/base/android/webaudio_media_codec_bridge.h"
#endif
@@ -97,6 +98,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(
@@ -640,14 +648,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
« no previous file with comments | « content/browser/media/android/media_throttler.cc ('k') | content/content_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698