| OLD | NEW |
| 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/test_audio_input_controller_factory.h" | 5 #include "media/audio/test_audio_input_controller_factory.h" |
| 6 #include "media/audio/audio_io.h" | 6 #include "media/audio/audio_io.h" |
| 7 | 7 |
| 8 namespace media { | 8 namespace media { |
| 9 | 9 |
| 10 TestAudioInputController::TestAudioInputController( | 10 TestAudioInputController::TestAudioInputController( |
| 11 TestAudioInputControllerFactory* factory, | 11 TestAudioInputControllerFactory* factory, |
| 12 AudioManager* audio_manager, | 12 AudioManager* audio_manager, |
| 13 EventHandler* event_handler, | 13 EventHandler* event_handler, |
| 14 SyncWriter* sync_writer) | 14 SyncWriter* sync_writer) |
| 15 : AudioInputController(event_handler, sync_writer), | 15 : AudioInputController(event_handler, sync_writer), |
| 16 factory_(factory), | 16 factory_(factory), |
| 17 event_handler_(event_handler) { | 17 event_handler_(event_handler) { |
| 18 message_loop_ = audio_manager->GetMessageLoop(); | 18 message_loop_ = audio_manager->GetMessageLoop(); |
| 19 } | 19 } |
| 20 | 20 |
| 21 void TestAudioInputController::Close(const base::Closure& closed_task) { |
| 22 message_loop_->PostTask(FROM_HERE, closed_task); |
| 23 } |
| 24 |
| 21 TestAudioInputController::~TestAudioInputController() { | 25 TestAudioInputController::~TestAudioInputController() { |
| 22 // Inform the factory so that it allows creating new instances in future. | 26 // Inform the factory so that it allows creating new instances in future. |
| 23 factory_->OnTestAudioInputControllerDestroyed(this); | 27 factory_->OnTestAudioInputControllerDestroyed(this); |
| 24 } | 28 } |
| 25 | 29 |
| 26 void TestAudioInputController::Close(const base::Closure& closed_task) { | |
| 27 message_loop_->PostTask(FROM_HERE, closed_task); | |
| 28 } | |
| 29 | |
| 30 TestAudioInputControllerFactory::TestAudioInputControllerFactory() | 30 TestAudioInputControllerFactory::TestAudioInputControllerFactory() |
| 31 : controller_(NULL) { | 31 : controller_(NULL) { |
| 32 } | 32 } |
| 33 | 33 |
| 34 AudioInputController* TestAudioInputControllerFactory::Create( | 34 AudioInputController* TestAudioInputControllerFactory::Create( |
| 35 AudioManager* audio_manager, | 35 AudioManager* audio_manager, |
| 36 AudioInputController::EventHandler* event_handler, | 36 AudioInputController::EventHandler* event_handler, |
| 37 AudioParameters params) { | 37 AudioParameters params) { |
| 38 DCHECK(!controller_); // Only one test instance managed at a time. | 38 DCHECK(!controller_); // Only one test instance managed at a time. |
| 39 controller_ = new TestAudioInputController(this, audio_manager, | 39 controller_ = new TestAudioInputController(this, audio_manager, |
| 40 event_handler, NULL); | 40 event_handler, NULL); |
| 41 return controller_; | 41 return controller_; |
| 42 } | 42 } |
| 43 | 43 |
| 44 void TestAudioInputControllerFactory::OnTestAudioInputControllerDestroyed( | 44 void TestAudioInputControllerFactory::OnTestAudioInputControllerDestroyed( |
| 45 TestAudioInputController* controller) { | 45 TestAudioInputController* controller) { |
| 46 DCHECK_EQ(controller_, controller); | 46 DCHECK_EQ(controller_, controller); |
| 47 controller_ = NULL; | 47 controller_ = NULL; |
| 48 } | 48 } |
| 49 | 49 |
| 50 } // namespace media | 50 } // namespace media |
| OLD | NEW |