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

Side by Side Diff: chrome/browser/media/webrtc/audio_debug_recordings_handler.cc

Issue 2582703003: Audio output debug recording. (Closed)
Patch Set: Control through AudioManager. Compiles on Linux, works with PulseAudio. Created 3 years, 11 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/media/audio_debug_recordings_handler.h" 5 #include "chrome/browser/media/audio_debug_recordings_handler.h"
6 6
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/files/file_util.h" 12 #include "base/files/file_util.h"
13 #include "base/strings/string_number_conversions.h" 13 #include "base/strings/string_number_conversions.h"
14 #include "base/time/time.h" 14 #include "base/time/time.h"
15 #include "chrome/browser/media/webrtc/webrtc_log_list.h" 15 #include "chrome/browser/media/webrtc/webrtc_log_list.h"
16 #include "chrome/browser/profiles/profile.h" 16 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/common/chrome_switches.h" 17 #include "chrome/common/chrome_switches.h"
18 #include "content/public/browser/browser_thread.h" 18 #include "content/public/browser/browser_thread.h"
19 #include "content/public/browser/render_process_host.h" 19 #include "content/public/browser/render_process_host.h"
20 #include "media/audio/audio_manager.h"
20 21
21 using content::BrowserThread; 22 using content::BrowserThread;
22 23
23 // Keys used to attach handler to the RenderProcessHost 24 // Keys used to attach handler to the RenderProcessHost
24 const char AudioDebugRecordingsHandler::kAudioDebugRecordingsHandlerKey[] = 25 const char AudioDebugRecordingsHandler::kAudioDebugRecordingsHandlerKey[] =
25 "kAudioDebugRecordingsHandlerKey"; 26 "kAudioDebugRecordingsHandlerKey";
26 27
27 namespace { 28 namespace {
28 29
29 // Returns a path name to be used as prefix for audio debug recordings files. 30 // Returns a path name to be used as prefix for audio debug recordings files.
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 if (is_audio_debug_recordings_in_progress_) { 100 if (is_audio_debug_recordings_in_progress_) {
100 error_callback.Run("Audio debug recordings already in progress"); 101 error_callback.Run("Audio debug recordings already in progress");
101 return; 102 return;
102 } 103 }
103 104
104 is_audio_debug_recordings_in_progress_ = true; 105 is_audio_debug_recordings_in_progress_ = true;
105 base::FilePath prefix_path = GetAudioDebugRecordingsPrefixPath( 106 base::FilePath prefix_path = GetAudioDebugRecordingsPrefixPath(
106 log_directory, ++current_audio_debug_recordings_id_); 107 log_directory, ++current_audio_debug_recordings_id_);
107 host->EnableAudioDebugRecordings(prefix_path); 108 host->EnableAudioDebugRecordings(prefix_path);
108 109
110 // AudioManager is deleted on the audio thread, and the AudioManager outlives
111 // this object, so it's safe to post unretained.
112 media::AudioManager::Get()->GetTaskRunner()->PostTask(
DaleCurtis 2017/01/19 17:44:33 Just call Get() once and reuse value?
Henrik Grunell 2017/01/20 10:38:55 Done.
113 FROM_HERE,
114 base::Bind(&media::AudioManager::EnableOutputDebugRecording,
115 base::Unretained(media::AudioManager::Get()), prefix_path));
116
109 if (delay.is_zero()) { 117 if (delay.is_zero()) {
110 const bool is_stopped = false, is_manual_stop = false; 118 const bool is_stopped = false, is_manual_stop = false;
111 callback.Run(prefix_path.AsUTF8Unsafe(), is_stopped, is_manual_stop); 119 callback.Run(prefix_path.AsUTF8Unsafe(), is_stopped, is_manual_stop);
112 return; 120 return;
113 } 121 }
114 122
115 const bool is_manual_stop = false; 123 const bool is_manual_stop = false;
116 BrowserThread::PostDelayedTask( 124 BrowserThread::PostDelayedTask(
117 BrowserThread::UI, FROM_HERE, 125 BrowserThread::UI, FROM_HERE,
118 base::Bind(&AudioDebugRecordingsHandler::DoStopAudioDebugRecordings, this, 126 base::Bind(&AudioDebugRecordingsHandler::DoStopAudioDebugRecordings, this,
(...skipping 23 matching lines...) Expand all
142 const bool is_stopped = false; 150 const bool is_stopped = false;
143 callback.Run(prefix_path.AsUTF8Unsafe(), is_stopped, is_manual_stop); 151 callback.Run(prefix_path.AsUTF8Unsafe(), is_stopped, is_manual_stop);
144 return; 152 return;
145 } 153 }
146 154
147 if (!is_audio_debug_recordings_in_progress_) { 155 if (!is_audio_debug_recordings_in_progress_) {
148 error_callback.Run("No audio debug recording in progress"); 156 error_callback.Run("No audio debug recording in progress");
149 return; 157 return;
150 } 158 }
151 159
160 // AudioManager is deleted on the audio thread, and the AudioManager outlives
161 // this object, so it's safe to post unretained.
162 media::AudioManager::Get()->GetTaskRunner()->PostTask(
163 FROM_HERE, base::Bind(&media::AudioManager::DisableOutputDebugRecording,
164 base::Unretained(media::AudioManager::Get())));
165
152 host->DisableAudioDebugRecordings(); 166 host->DisableAudioDebugRecordings();
167
153 is_audio_debug_recordings_in_progress_ = false; 168 is_audio_debug_recordings_in_progress_ = false;
154 const bool is_stopped = true; 169 const bool is_stopped = true;
155 callback.Run(prefix_path.AsUTF8Unsafe(), is_stopped, is_manual_stop); 170 callback.Run(prefix_path.AsUTF8Unsafe(), is_stopped, is_manual_stop);
156 } 171 }
OLDNEW
« no previous file with comments | « no previous file | content/browser/browser_main_loop.cc » ('j') | content/browser/renderer_host/media/audio_debug_file_writer.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698