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

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: String handling is hard 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
« no previous file with comments | « chrome/browser/media/webrtc_audio_quality_browsertest.cc ('k') | media/audio/simple_sources.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..48ca3e55534189dc55d76aade213635eed50b767 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,24 @@ 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));
+ base::CommandLine::StringVector parameters =
+ base::SplitString(switch_value, FILE_PATH_LITERAL("%"),
+ 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] == FILE_PATH_LITERAL("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_));
}
« no previous file with comments | « chrome/browser/media/webrtc_audio_quality_browsertest.cc ('k') | media/audio/simple_sources.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698