| 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_input_writer.h" | 6 #include "media/audio/audio_input_writer.h" |
| 7 #include "media/audio/audio_io.h" | 7 #include "media/audio/audio_io.h" |
| 8 | 8 |
| 9 namespace media { | 9 namespace media { |
| 10 | 10 |
| 11 TestAudioInputController::TestAudioInputController( | 11 TestAudioInputController::TestAudioInputController( |
| 12 TestAudioInputControllerFactory* factory, | 12 TestAudioInputControllerFactory* factory, |
| 13 AudioManager* audio_manager, | 13 AudioManager* audio_manager, |
| 14 const AudioParameters& audio_parameters, | 14 const AudioParameters& audio_parameters, |
| 15 EventHandler* event_handler, | 15 EventHandler* event_handler, |
| 16 SyncWriter* sync_writer, | 16 SyncWriter* sync_writer, |
| 17 UserInputMonitor* user_input_monitor) | 17 UserInputMonitor* user_input_monitor) |
| 18 : AudioInputController(event_handler, | 18 : AudioInputController(audio_manager->GetTaskRunner(), |
| 19 event_handler, |
| 19 sync_writer, | 20 sync_writer, |
| 20 nullptr, | 21 nullptr, |
| 21 user_input_monitor, | 22 user_input_monitor, |
| 22 false), | 23 false), |
| 23 audio_parameters_(audio_parameters), | 24 audio_parameters_(audio_parameters), |
| 24 factory_(factory), | 25 factory_(factory), |
| 25 event_handler_(event_handler) { | 26 event_handler_(event_handler) {} |
| 26 task_runner_ = audio_manager->GetTaskRunner(); | |
| 27 } | |
| 28 | 27 |
| 29 TestAudioInputController::~TestAudioInputController() { | 28 TestAudioInputController::~TestAudioInputController() { |
| 30 // Inform the factory so that it allows creating new instances in future. | 29 // Inform the factory so that it allows creating new instances in future. |
| 31 factory_->OnTestAudioInputControllerDestroyed(this); | 30 factory_->OnTestAudioInputControllerDestroyed(this); |
| 32 } | 31 } |
| 33 | 32 |
| 34 void TestAudioInputController::Record() { | 33 void TestAudioInputController::Record() { |
| 35 if (factory_->delegate_) | 34 if (factory_->delegate_) |
| 36 factory_->delegate_->TestAudioControllerOpened(this); | 35 factory_->delegate_->TestAudioControllerOpened(this); |
| 37 } | 36 } |
| 38 | 37 |
| 39 void TestAudioInputController::Close(const base::Closure& closed_task) { | 38 void TestAudioInputController::Close(const base::Closure& closed_task) { |
| 40 task_runner_->PostTask(FROM_HERE, closed_task); | 39 GetTaskRunnerForTesting()->PostTask(FROM_HERE, closed_task); |
| 41 if (factory_->delegate_) | 40 if (factory_->delegate_) |
| 42 factory_->delegate_->TestAudioControllerClosed(this); | 41 factory_->delegate_->TestAudioControllerClosed(this); |
| 43 } | 42 } |
| 44 | 43 |
| 45 TestAudioInputControllerFactory::TestAudioInputControllerFactory() | 44 TestAudioInputControllerFactory::TestAudioInputControllerFactory() |
| 46 : controller_(NULL), | 45 : controller_(NULL), |
| 47 delegate_(NULL) { | 46 delegate_(NULL) { |
| 48 } | 47 } |
| 49 | 48 |
| 50 TestAudioInputControllerFactory::~TestAudioInputControllerFactory() { | 49 TestAudioInputControllerFactory::~TestAudioInputControllerFactory() { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 64 return controller_; | 63 return controller_; |
| 65 } | 64 } |
| 66 | 65 |
| 67 void TestAudioInputControllerFactory::OnTestAudioInputControllerDestroyed( | 66 void TestAudioInputControllerFactory::OnTestAudioInputControllerDestroyed( |
| 68 TestAudioInputController* controller) { | 67 TestAudioInputController* controller) { |
| 69 DCHECK_EQ(controller_, controller); | 68 DCHECK_EQ(controller_, controller); |
| 70 controller_ = NULL; | 69 controller_ = NULL; |
| 71 } | 70 } |
| 72 | 71 |
| 73 } // namespace media | 72 } // namespace media |
| OLD | NEW |