Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(164)

Side by Side Diff: media/audio/fake_audio_input_stream.cc

Issue 2043353002: Make fake audio file playback loop by default. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 std::vector<std::string> parameters = base::SplitString(
116 << "You must pass the file to use as argument to --" 117 switch_value, "!", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY);
117 << switches::kUseFileForFakeAudioCapture << "."; 118 CHECK(parameters.size() > 0) << "You must pass <file>[!noloop] to --"
118 119 << switches::kUseFileForFakeAudioCapture
119 return base::WrapUnique(new FileSource(params_, path_to_wav_file)); 120 << ".";
121 base::FilePath path_to_wav_file = base::FilePath(parameters[0]);
122 bool looping = true;
123 if (parameters.size() == 2) {
124 CHECK(parameters[1] == "noloop")
125 << "Unknown parameter " << parameters[1] << " to "
126 << switches::kUseFileForFakeAudioCapture << ".";
127 looping = false;
128 }
129 return base::WrapUnique(new FileSource(params_, path_to_wav_file, looping));
120 } 130 }
121 return base::WrapUnique(new BeepingSource(params_)); 131 return base::WrapUnique(new BeepingSource(params_));
122 } 132 }
123 133
124 void FakeAudioInputStream::BeepOnce() { 134 void FakeAudioInputStream::BeepOnce() {
125 BeepingSource::BeepOnce(); 135 BeepingSource::BeepOnce();
126 } 136 }
127 137
128 } // namespace media 138 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698