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"
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
,
21 audio_parameters_(audio_parameters
),
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()
48 TestAudioInputControllerFactory::~TestAudioInputControllerFactory() {
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
);
63 void TestAudioInputControllerFactory::OnTestAudioInputControllerDestroyed(
64 TestAudioInputController
* controller
) {
65 DCHECK_EQ(controller_
, controller
);