Rename: Use "Register" Mojo Service/App in content client API.
[chromium-blink-merge.git] / media / audio / test_audio_input_controller_factory.cc
blobcd07e20bb350c75035c1228c24ffc74a70268283
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
3 // found in the LICENSE file.
5 #include "media/audio/test_audio_input_controller_factory.h"
6 #include "media/audio/audio_io.h"
8 namespace media {
10 TestAudioInputController::TestAudioInputController(
11 TestAudioInputControllerFactory* factory,
12 AudioManager* audio_manager,
13 const AudioParameters& audio_parameters,
14 EventHandler* event_handler,
15 SyncWriter* sync_writer,
16 UserInputMonitor* user_input_monitor)
17 : AudioInputController(event_handler,
18 sync_writer,
19 user_input_monitor,
20 false),
21 audio_parameters_(audio_parameters),
22 factory_(factory),
23 event_handler_(event_handler) {
24 task_runner_ = audio_manager->GetTaskRunner();
27 TestAudioInputController::~TestAudioInputController() {
28 // Inform the factory so that it allows creating new instances in future.
29 factory_->OnTestAudioInputControllerDestroyed(this);
32 void TestAudioInputController::Record() {
33 if (factory_->delegate_)
34 factory_->delegate_->TestAudioControllerOpened(this);
37 void TestAudioInputController::Close(const base::Closure& closed_task) {
38 task_runner_->PostTask(FROM_HERE, closed_task);
39 if (factory_->delegate_)
40 factory_->delegate_->TestAudioControllerClosed(this);
43 TestAudioInputControllerFactory::TestAudioInputControllerFactory()
44 : controller_(NULL),
45 delegate_(NULL) {
48 TestAudioInputControllerFactory::~TestAudioInputControllerFactory() {
49 DCHECK(!controller_);
52 AudioInputController* TestAudioInputControllerFactory::Create(
53 AudioManager* audio_manager,
54 AudioInputController::EventHandler* event_handler,
55 AudioParameters params,
56 UserInputMonitor* user_input_monitor) {
57 DCHECK(!controller_); // Only one test instance managed at a time.
58 controller_ = new TestAudioInputController(
59 this, audio_manager, params, event_handler, NULL, user_input_monitor);
60 return controller_;
63 void TestAudioInputControllerFactory::OnTestAudioInputControllerDestroyed(
64 TestAudioInputController* controller) {
65 DCHECK_EQ(controller_, controller);
66 controller_ = NULL;
69 } // namespace media