| 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/fake_audio_input_stream.h" | 5 #include "media/audio/fake_audio_input_stream.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 return false; | 92 return false; |
| 93 } | 93 } |
| 94 | 94 |
| 95 void FakeAudioInputStream::ReadAudioFromSource() { | 95 void FakeAudioInputStream::ReadAudioFromSource() { |
| 96 DCHECK(audio_manager_->GetWorkerTaskRunner()->BelongsToCurrentThread()); | 96 DCHECK(audio_manager_->GetWorkerTaskRunner()->BelongsToCurrentThread()); |
| 97 DCHECK(callback_); | 97 DCHECK(callback_); |
| 98 | 98 |
| 99 if (!audio_source_) | 99 if (!audio_source_) |
| 100 audio_source_ = ChooseSource(); | 100 audio_source_ = ChooseSource(); |
| 101 | 101 |
| 102 const int kNoDelay = 0; | 102 audio_source_->OnMoreData(base::TimeDelta(), base::TimeTicks::Now(), 0, |
| 103 audio_source_->OnMoreData(audio_bus_.get(), kNoDelay, 0); | 103 audio_bus_.get()); |
| 104 callback_->OnData(this, audio_bus_.get(), 0, 1.0); | 104 callback_->OnData(this, audio_bus_.get(), 0, 1.0); |
| 105 } | 105 } |
| 106 | 106 |
| 107 using AudioSourceCallback = AudioOutputStream::AudioSourceCallback; | 107 using AudioSourceCallback = AudioOutputStream::AudioSourceCallback; |
| 108 std::unique_ptr<AudioSourceCallback> FakeAudioInputStream::ChooseSource() { | 108 std::unique_ptr<AudioSourceCallback> FakeAudioInputStream::ChooseSource() { |
| 109 DCHECK(audio_manager_->GetWorkerTaskRunner()->BelongsToCurrentThread()); | 109 DCHECK(audio_manager_->GetWorkerTaskRunner()->BelongsToCurrentThread()); |
| 110 | 110 |
| 111 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 111 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 112 switches::kUseFileForFakeAudioCapture)) { | 112 switches::kUseFileForFakeAudioCapture)) { |
| 113 base::CommandLine::StringType switch_value = | 113 base::CommandLine::StringType switch_value = |
| (...skipping 16 matching lines...) Expand all Loading... |
| 130 return base::MakeUnique<FileSource>(params_, path_to_wav_file, looping); | 130 return base::MakeUnique<FileSource>(params_, path_to_wav_file, looping); |
| 131 } | 131 } |
| 132 return base::MakeUnique<BeepingSource>(params_); | 132 return base::MakeUnique<BeepingSource>(params_); |
| 133 } | 133 } |
| 134 | 134 |
| 135 void FakeAudioInputStream::BeepOnce() { | 135 void FakeAudioInputStream::BeepOnce() { |
| 136 BeepingSource::BeepOnce(); | 136 BeepingSource::BeepOnce(); |
| 137 } | 137 } |
| 138 | 138 |
| 139 } // namespace media | 139 } // namespace media |
| OLD | NEW |