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 : AudioInputController(event_handler
, sync_writer
),
17 audio_parameters_(audio_parameters
),
19 event_handler_(event_handler
) {
20 message_loop_
= audio_manager
->GetMessageLoop();
23 TestAudioInputController::~TestAudioInputController() {
24 // Inform the factory so that it allows creating new instances in future.
25 factory_
->OnTestAudioInputControllerDestroyed(this);
28 void TestAudioInputController::Record() {
29 if (factory_
->delegate_
)
30 factory_
->delegate_
->TestAudioControllerOpened(this);
33 void TestAudioInputController::Close(const base::Closure
& closed_task
) {
34 message_loop_
->PostTask(FROM_HERE
, closed_task
);
35 if (factory_
->delegate_
)
36 factory_
->delegate_
->TestAudioControllerClosed(this);
39 TestAudioInputControllerFactory::TestAudioInputControllerFactory()
44 TestAudioInputControllerFactory::~TestAudioInputControllerFactory() {
48 AudioInputController
* TestAudioInputControllerFactory::Create(
49 AudioManager
* audio_manager
,
50 AudioInputController::EventHandler
* event_handler
,
51 AudioParameters params
) {
52 DCHECK(!controller_
); // Only one test instance managed at a time.
53 controller_
= new TestAudioInputController(this, audio_manager
, params
,
58 void TestAudioInputControllerFactory::SetDelegateForTests(
59 TestAudioInputControllerDelegate
* delegate
) {
63 void TestAudioInputControllerFactory::OnTestAudioInputControllerDestroyed(
64 TestAudioInputController
* controller
) {
65 DCHECK_EQ(controller_
, controller
);