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..06a41a2a6678d1cba7c930a6f3e5208769940c13 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 |
@@ -504,14 +506,25 @@ 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()->RequestToDecodeData()) { |
+ // TODO(qinmin): should this be done on a worker thread? And we should |
+ // notify the user that WebAudio cannot decode the data. |
+ if (close(pcm_output.fd)) { |
jochen (gone - plz use gerrit)
2015/09/29 07:14:29
why not just post it to the blocking worker pool?
qinmin
2015/09/29 23:16:23
Done.
|
+ LOG(ERROR) << "Couldn't close output webaudio fd " |
+ << ": " << strerror(errno); |
+ } |
+ } 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 |