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

Side by Side Diff: media/audio/audio_input_controller.cc

Issue 2531333005: Unit tests of AudioInputRendererHost. Some cleanups. (Closed)
Patch Set: Small comments describing tests. Created 4 years 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
« no previous file with comments | « media/audio/audio_input_controller.h ('k') | media/audio/test_audio_input_controller_factory.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "media/audio/audio_input_controller.h" 5 #include "media/audio/audio_input_controller.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 EventHandler* event_handler, 121 EventHandler* event_handler,
122 const AudioParameters& params, 122 const AudioParameters& params,
123 const std::string& device_id, 123 const std::string& device_id,
124 UserInputMonitor* user_input_monitor) { 124 UserInputMonitor* user_input_monitor) {
125 DCHECK(audio_manager); 125 DCHECK(audio_manager);
126 126
127 if (!params.IsValid() || (params.channels() > kMaxInputChannels)) 127 if (!params.IsValid() || (params.channels() > kMaxInputChannels))
128 return nullptr; 128 return nullptr;
129 129
130 if (factory_) { 130 if (factory_) {
131 return factory_->Create( 131 return factory_->Create(audio_manager->GetTaskRunner(),
132 audio_manager, event_handler, params, user_input_monitor); 132 /*sync_writer*/ nullptr, audio_manager,
133 event_handler, params, user_input_monitor);
133 } 134 }
135
134 scoped_refptr<AudioInputController> controller(new AudioInputController( 136 scoped_refptr<AudioInputController> controller(new AudioInputController(
135 event_handler, nullptr, nullptr, user_input_monitor, false)); 137 event_handler, nullptr, nullptr, user_input_monitor, false));
136 138
137 controller->task_runner_ = audio_manager->GetTaskRunner(); 139 controller->task_runner_ = audio_manager->GetTaskRunner();
138 140
139 // Create and open a new audio input stream from the existing 141 // Create and open a new audio input stream from the existing
140 // audio-device thread. 142 // audio-device thread.
141 if (!controller->task_runner_->PostTask( 143 if (!controller->task_runner_->PostTask(
142 FROM_HERE, 144 FROM_HERE,
143 base::Bind(&AudioInputController::DoCreate, 145 base::Bind(&AudioInputController::DoCreate,
(...skipping 16 matching lines...) Expand all
160 SyncWriter* sync_writer, 162 SyncWriter* sync_writer,
161 std::unique_ptr<AudioInputWriter> debug_writer, 163 std::unique_ptr<AudioInputWriter> debug_writer,
162 UserInputMonitor* user_input_monitor, 164 UserInputMonitor* user_input_monitor,
163 const bool agc_is_enabled) { 165 const bool agc_is_enabled) {
164 DCHECK(audio_manager); 166 DCHECK(audio_manager);
165 DCHECK(sync_writer); 167 DCHECK(sync_writer);
166 168
167 if (!params.IsValid() || (params.channels() > kMaxInputChannels)) 169 if (!params.IsValid() || (params.channels() > kMaxInputChannels))
168 return nullptr; 170 return nullptr;
169 171
172 if (factory_) {
173 return factory_->Create(audio_manager->GetTaskRunner(), sync_writer,
174 audio_manager, event_handler, params,
175 user_input_monitor);
176 }
177
170 // Create the AudioInputController object and ensure that it runs on 178 // Create the AudioInputController object and ensure that it runs on
171 // the audio-manager thread. 179 // the audio-manager thread.
172 scoped_refptr<AudioInputController> controller(new AudioInputController( 180 scoped_refptr<AudioInputController> controller(new AudioInputController(
173 event_handler, sync_writer, std::move(debug_writer), user_input_monitor, 181 event_handler, sync_writer, std::move(debug_writer), user_input_monitor,
174 agc_is_enabled)); 182 agc_is_enabled));
175 controller->task_runner_ = audio_manager->GetTaskRunner(); 183 controller->task_runner_ = audio_manager->GetTaskRunner();
176 184
177 // Create and open a new audio input stream from the existing 185 // Create and open a new audio input stream from the existing
178 // audio-device thread. Use the provided audio-input device. 186 // audio-device thread. Use the provided audio-input device.
179 if (!controller->task_runner_->PostTask( 187 if (!controller->task_runner_->PostTask(
(...skipping 13 matching lines...) Expand all
193 scoped_refptr<AudioInputController> AudioInputController::CreateForStream( 201 scoped_refptr<AudioInputController> AudioInputController::CreateForStream(
194 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, 202 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
195 EventHandler* event_handler, 203 EventHandler* event_handler,
196 AudioInputStream* stream, 204 AudioInputStream* stream,
197 SyncWriter* sync_writer, 205 SyncWriter* sync_writer,
198 std::unique_ptr<AudioInputWriter> debug_writer, 206 std::unique_ptr<AudioInputWriter> debug_writer,
199 UserInputMonitor* user_input_monitor) { 207 UserInputMonitor* user_input_monitor) {
200 DCHECK(sync_writer); 208 DCHECK(sync_writer);
201 DCHECK(stream); 209 DCHECK(stream);
202 210
211 if (factory_) {
212 return factory_->Create(
213 task_runner, sync_writer, AudioManager::Get(), event_handler,
214 media::AudioParameters::UnavailableDeviceParams(), user_input_monitor);
215 }
216
203 // Create the AudioInputController object and ensure that it runs on 217 // Create the AudioInputController object and ensure that it runs on
204 // the audio-manager thread. 218 // the audio-manager thread.
205 scoped_refptr<AudioInputController> controller(new AudioInputController( 219 scoped_refptr<AudioInputController> controller(new AudioInputController(
206 event_handler, sync_writer, std::move(debug_writer), user_input_monitor, 220 event_handler, sync_writer, std::move(debug_writer), user_input_monitor,
207 false)); 221 false));
208 controller->task_runner_ = task_runner; 222 controller->task_runner_ = task_runner;
209 223
210 if (!controller->task_runner_->PostTask( 224 if (!controller->task_runner_->PostTask(
211 FROM_HERE, 225 FROM_HERE,
212 base::Bind(&AudioInputController::DoCreateForStream, 226 base::Bind(&AudioInputController::DoCreateForStream,
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 if (debug_writer_) 653 if (debug_writer_)
640 debug_writer_->Write(std::move(data)); 654 debug_writer_->Write(std::move(data));
641 } 655 }
642 656
643 void AudioInputController::LogMessage(const std::string& message) { 657 void AudioInputController::LogMessage(const std::string& message) {
644 DCHECK(task_runner_->BelongsToCurrentThread()); 658 DCHECK(task_runner_->BelongsToCurrentThread());
645 handler_->OnLog(this, message); 659 handler_->OnLog(this, message);
646 } 660 }
647 661
648 } // namespace media 662 } // namespace media
OLDNEW
« no previous file with comments | « media/audio/audio_input_controller.h ('k') | media/audio/test_audio_input_controller_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698