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

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

Issue 1272223003: Implement writing mic audio input data to file for debugging purposes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Code review Created 5 years, 4 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_process_host_impl.cc
diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc
index d9e055cedf3ef99ec69e2ddf3e561c707dfe13fe..7c1e459929d906630f62dafe11c9a9028990ec2b 100644
--- a/content/browser/renderer_host/render_process_host_impl.cc
+++ b/content/browser/renderer_host/render_process_host_impl.cc
@@ -211,6 +211,12 @@
#include "content/common/media/media_stream_messages.h"
#endif
+#if defined(OS_WIN)
+#define IntToStringType base::IntToString16
+#else
+#define IntToStringType base::IntToString
+#endif
+
extern bool g_exited_main_message_loop;
namespace content {
@@ -218,6 +224,8 @@ namespace {
const char kSiteProcessMapKeyName[] = "content_site_process_map";
+const char kAecDumpFileNameAddition[] = "aec_dump";
+
void CacheShaderInfo(int32 id, base::FilePath path) {
ShaderCacheFactory::GetInstance()->SetCacheInfo(id, path);
}
@@ -791,14 +799,15 @@ void RenderProcessHostImpl::CreateMessageFilters() {
AddFilter(resource_message_filter);
MediaStreamManager* media_stream_manager =
BrowserMainLoop::GetInstance()->media_stream_manager();
- AddFilter(new AudioInputRendererHost(
+ // The AudioInputRendererHost and AudioRendererHost needs to be available for
+ // lookup, so it's stashed in a member variable.
+ audio_input_renderer_host_ = new AudioInputRendererHost(
GetID(),
audio_manager,
media_stream_manager,
AudioMirroringManager::GetInstance(),
- BrowserMainLoop::GetInstance()->user_input_monitor()));
- // The AudioRendererHost needs to be available for lookup, so it's
- // stashed in a member variable.
+ BrowserMainLoop::GetInstance()->user_input_monitor());
+ AddFilter(audio_input_renderer_host_.get());
audio_renderer_host_ = new AudioRendererHost(
GetID(),
audio_manager,
@@ -1759,25 +1768,47 @@ void RenderProcessHostImpl::FilterURL(bool empty_allowed, GURL* url) {
}
#if defined(ENABLE_WEBRTC)
-void RenderProcessHostImpl::EnableAecDump(const base::FilePath& file) {
+void RenderProcessHostImpl::EnableAudioDebugRecordings(
+ const base::FilePath& file) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
+
+ base::FilePath file_with_pid =
+ file.AddExtension(IntToStringType(base::GetProcId(GetHandle())));
+
// Enable AEC dump for each registered consumer.
+ base::FilePath file_with_extensions =
+ GetAecDumpFilePathWithExtensions(file_with_pid);
for (std::vector<int>::iterator it = aec_dump_consumers_.begin();
it != aec_dump_consumers_.end(); ++it) {
- EnableAecDumpForId(file, *it);
+ EnableAecDumpForId(file_with_extensions, *it);
}
+
+ // Enable mic input recording. AudioInputRendererHost is reference counted, so
+ // it's lifetime is guarantueed during the lifetime of the closure.
+ BrowserThread::PostTask(
+ BrowserThread::IO, FROM_HERE,
+ base::Bind(&AudioInputRendererHost::EnableDebugRecording,
+ audio_input_renderer_host_,
+ file_with_pid));
}
-void RenderProcessHostImpl::DisableAecDump() {
+void RenderProcessHostImpl::DisableAudioDebugRecordings() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
+
// Posting on the FILE thread and then replying back on the UI thread is only
// for avoiding races between enable and disable. Nothing is done on the FILE
- // thread.
+ // thread. AudioInputRendererHost is reference counted, so it's lifetime is
nasko 2015/08/20 20:56:13 This new comment is better suited before the PostT
Henrik Grunell 2015/08/21 13:51:03 Done.
+ // guarantueed during the lifetime of the closure.
BrowserThread::PostTaskAndReply(
BrowserThread::FILE, FROM_HERE,
base::Bind(&DisableAecDumpOnFileThread),
base::Bind(&RenderProcessHostImpl::SendDisableAecDumpToRenderer,
weak_factory_.GetWeakPtr()));
+ BrowserThread::PostTask(
+ BrowserThread::IO, FROM_HERE,
+ base::Bind(
+ &AudioInputRendererHost::DisableDebugRecording,
+ audio_input_renderer_host_));
}
void RenderProcessHostImpl::SetWebRtcLogMessageCallback(
@@ -2381,8 +2412,10 @@ void RenderProcessHostImpl::OnProcessLaunched() {
tracked_objects::ScopedTracker tracking_profile7(
FROM_HERE_WITH_EXPLICIT_FUNCTION(
"465841 RenderProcessHostImpl::OnProcessLaunched::EnableAec"));
- if (WebRTCInternals::GetInstance()->aec_dump_enabled())
- EnableAecDump(WebRTCInternals::GetInstance()->aec_dump_file_path());
+ if (WebRTCInternals::GetInstance()->IsAudioDebugRecordingsEnabled()) {
+ EnableAudioDebugRecordings(
+ WebRTCInternals::GetInstance()->GetAudioDebugRecordingsFilePath());
+ }
#endif
}
@@ -2461,9 +2494,11 @@ void RenderProcessHostImpl::OnUnregisterAecDumpConsumer(int id) {
void RenderProcessHostImpl::RegisterAecDumpConsumerOnUIThread(int id) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
aec_dump_consumers_.push_back(id);
- if (WebRTCInternals::GetInstance()->aec_dump_enabled()) {
- EnableAecDumpForId(WebRTCInternals::GetInstance()->aec_dump_file_path(),
- id);
+ if (WebRTCInternals::GetInstance()->IsAudioDebugRecordingsEnabled()) {
+ EnableAecDumpForId(
+ GetAecDumpFilePathWithExtensions(
+ WebRTCInternals::GetInstance()->GetAudioDebugRecordingsFilePath()),
+ id);
}
}
@@ -2478,28 +2513,19 @@ void RenderProcessHostImpl::UnregisterAecDumpConsumerOnUIThread(int id) {
}
}
-#if defined(OS_WIN)
-#define IntToStringType base::IntToString16
-#else
-#define IntToStringType base::IntToString
-#endif
-
void RenderProcessHostImpl::EnableAecDumpForId(const base::FilePath& file,
int id) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
- base::FilePath unique_file =
- file.AddExtension(IntToStringType(base::GetProcId(GetHandle())))
- .AddExtension(IntToStringType(id));
BrowserThread::PostTaskAndReplyWithResult(
BrowserThread::FILE, FROM_HERE,
- base::Bind(&CreateAecDumpFileForProcess, unique_file, GetHandle()),
+ base::Bind(&CreateAecDumpFileForProcess,
+ file.AddExtension(IntToStringType(id)),
+ GetHandle()),
base::Bind(&RenderProcessHostImpl::SendAecDumpFileToRenderer,
weak_factory_.GetWeakPtr(),
id));
}
-#undef IntToStringType
-
void RenderProcessHostImpl::SendAecDumpFileToRenderer(
int id,
IPC::PlatformFileForTransit file_for_transit) {
@@ -2511,6 +2537,11 @@ void RenderProcessHostImpl::SendAecDumpFileToRenderer(
void RenderProcessHostImpl::SendDisableAecDumpToRenderer() {
Send(new AecDumpMsg_DisableAecDump());
}
+
+base::FilePath RenderProcessHostImpl::GetAecDumpFilePathWithExtensions(
+ const base::FilePath& file) {
+ return file.AddExtension(kAecDumpFileNameAddition);
nasko 2015/08/20 20:56:13 This seems an overkill to have a method with only
Henrik Grunell 2015/08/21 13:51:03 Sure, removed the function.
+}
#endif
void RenderProcessHostImpl::IncrementWorkerRefCount() {
« no previous file with comments | « content/browser/renderer_host/render_process_host_impl.h ('k') | content/browser/resources/media/dump_creator.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698