| 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" |
| 11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
| 12 #include "base/single_thread_task_runner.h" | 12 #include "base/single_thread_task_runner.h" |
| 13 #include "base/strings/string_split.h" |
| 13 #include "base/time/time.h" | 14 #include "base/time/time.h" |
| 14 #include "media/audio/audio_manager_base.h" | 15 #include "media/audio/audio_manager_base.h" |
| 15 #include "media/audio/simple_sources.h" | 16 #include "media/audio/simple_sources.h" |
| 16 #include "media/base/audio_bus.h" | 17 #include "media/base/audio_bus.h" |
| 17 #include "media/base/media_switches.h" | 18 #include "media/base/media_switches.h" |
| 18 | 19 |
| 19 namespace media { | 20 namespace media { |
| 20 | 21 |
| 21 AudioInputStream* FakeAudioInputStream::MakeFakeStream( | 22 AudioInputStream* FakeAudioInputStream::MakeFakeStream( |
| 22 AudioManagerBase* manager, | 23 AudioManagerBase* manager, |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 audio_source_->OnMoreData(audio_bus_.get(), kNoDelay, 0); | 103 audio_source_->OnMoreData(audio_bus_.get(), kNoDelay, 0); |
| 103 callback_->OnData(this, audio_bus_.get(), 0, 1.0); | 104 callback_->OnData(this, audio_bus_.get(), 0, 1.0); |
| 104 } | 105 } |
| 105 | 106 |
| 106 using AudioSourceCallback = AudioOutputStream::AudioSourceCallback; | 107 using AudioSourceCallback = AudioOutputStream::AudioSourceCallback; |
| 107 std::unique_ptr<AudioSourceCallback> FakeAudioInputStream::ChooseSource() { | 108 std::unique_ptr<AudioSourceCallback> FakeAudioInputStream::ChooseSource() { |
| 108 DCHECK(audio_manager_->GetWorkerTaskRunner()->BelongsToCurrentThread()); | 109 DCHECK(audio_manager_->GetWorkerTaskRunner()->BelongsToCurrentThread()); |
| 109 | 110 |
| 110 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 111 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 111 switches::kUseFileForFakeAudioCapture)) { | 112 switches::kUseFileForFakeAudioCapture)) { |
| 112 base::FilePath path_to_wav_file = | 113 base::CommandLine::StringType switch_value = |
| 113 base::CommandLine::ForCurrentProcess()->GetSwitchValuePath( | 114 base::CommandLine::ForCurrentProcess()->GetSwitchValueNative( |
| 114 switches::kUseFileForFakeAudioCapture); | 115 switches::kUseFileForFakeAudioCapture); |
| 115 CHECK(!path_to_wav_file.empty()) | 116 base::CommandLine::StringVector parameters = |
| 116 << "You must pass the file to use as argument to --" | 117 base::SplitString(switch_value, FILE_PATH_LITERAL("%"), |
| 117 << switches::kUseFileForFakeAudioCapture << "."; | 118 base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY); |
| 118 | 119 CHECK(parameters.size() > 0) << "You must pass <file>[%noloop] to --" |
| 119 return base::WrapUnique(new FileSource(params_, path_to_wav_file)); | 120 << switches::kUseFileForFakeAudioCapture |
| 121 << "."; |
| 122 base::FilePath path_to_wav_file = base::FilePath(parameters[0]); |
| 123 bool looping = true; |
| 124 if (parameters.size() == 2) { |
| 125 CHECK(parameters[1] == FILE_PATH_LITERAL("noloop")) |
| 126 << "Unknown parameter " << parameters[1] << " to " |
| 127 << switches::kUseFileForFakeAudioCapture << "."; |
| 128 looping = false; |
| 129 } |
| 130 return base::WrapUnique(new FileSource(params_, path_to_wav_file, looping)); |
| 120 } | 131 } |
| 121 return base::WrapUnique(new BeepingSource(params_)); | 132 return base::WrapUnique(new BeepingSource(params_)); |
| 122 } | 133 } |
| 123 | 134 |
| 124 void FakeAudioInputStream::BeepOnce() { | 135 void FakeAudioInputStream::BeepOnce() { |
| 125 BeepingSource::BeepOnce(); | 136 BeepingSource::BeepOnce(); |
| 126 } | 137 } |
| 127 | 138 |
| 128 } // namespace media | 139 } // namespace media |
| OLD | NEW |