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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: media/audio/fake_audio_input_stream.cc
diff --git a/media/audio/fake_audio_input_stream.cc b/media/audio/fake_audio_input_stream.cc
index af4f7e1b2761a6f25bde438f5d486c29400e54ba..48c7d203d45c5cc2449f7089a696935a449aa6d7 100644
--- a/media/audio/fake_audio_input_stream.cc
+++ b/media/audio/fake_audio_input_stream.cc
@@ -10,6 +10,7 @@
#include "base/files/file_path.h"
#include "base/memory/ptr_util.h"
#include "base/single_thread_task_runner.h"
+#include "base/strings/string_split.h"
#include "base/time/time.h"
#include "media/audio/audio_manager_base.h"
#include "media/audio/simple_sources.h"
@@ -109,14 +110,23 @@ std::unique_ptr<AudioSourceCallback> FakeAudioInputStream::ChooseSource() {
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kUseFileForFakeAudioCapture)) {
- base::FilePath path_to_wav_file =
- base::CommandLine::ForCurrentProcess()->GetSwitchValuePath(
+ base::CommandLine::StringType switch_value =
+ base::CommandLine::ForCurrentProcess()->GetSwitchValueNative(
switches::kUseFileForFakeAudioCapture);
- CHECK(!path_to_wav_file.empty())
- << "You must pass the file to use as argument to --"
- << switches::kUseFileForFakeAudioCapture << ".";
-
- return base::WrapUnique(new FileSource(params_, path_to_wav_file));
+ std::vector<std::string> parameters = base::SplitString(
+ switch_value, "!", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY);
+ CHECK(parameters.size() > 0) << "You must pass <file>[!noloop] to --"
+ << switches::kUseFileForFakeAudioCapture
+ << ".";
+ base::FilePath path_to_wav_file = base::FilePath(parameters[0]);
+ bool looping = true;
+ if (parameters.size() == 2) {
+ CHECK(parameters[1] == "noloop")
+ << "Unknown parameter " << parameters[1] << " to "
+ << switches::kUseFileForFakeAudioCapture << ".";
+ looping = false;
+ }
+ return base::WrapUnique(new FileSource(params_, path_to_wav_file, looping));
}
return base::WrapUnique(new BeepingSource(params_));
}

Powered by Google App Engine
This is Rietveld 408576698