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

Unified Diff: media/audio/simple_sources.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 | « media/audio/simple_sources.h ('k') | media/audio/simple_sources_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/audio/simple_sources.cc
diff --git a/media/audio/simple_sources.cc b/media/audio/simple_sources.cc
index f20343a4ee49c6c8bb25bc99e8a3d79e1d4189d2..fde0509d979f0dc24aa45a062620d7583425738b 100644
--- a/media/audio/simple_sources.cc
+++ b/media/audio/simple_sources.cc
@@ -152,12 +152,13 @@ void SineWaveAudioSource::Reset() {
}
FileSource::FileSource(const AudioParameters& params,
- const base::FilePath& path_to_wav_file)
+ const base::FilePath& path_to_wav_file,
+ bool loop)
: params_(params),
path_to_wav_file_(path_to_wav_file),
wav_file_read_pos_(0),
- load_failed_(false) {
-}
+ load_failed_(false),
+ looping_(loop) {}
FileSource::~FileSource() {
}
@@ -213,15 +214,22 @@ int FileSource::OnMoreData(AudioBus* audio_bus,
DCHECK(wav_audio_handler_.get());
- // Stop playing if we've played out the whole file.
- if (wav_audio_handler_->AtEnd(wav_file_read_pos_))
- return 0;
+ if (wav_audio_handler_->AtEnd(wav_file_read_pos_)) {
+ if (looping_)
+ Rewind();
+ else
+ return 0;
+ }
// This pulls data from ProvideInput.
file_audio_converter_->Convert(audio_bus);
return audio_bus->frames();
}
+void FileSource::Rewind() {
+ wav_file_read_pos_ = 0;
+}
+
double FileSource::ProvideInput(AudioBus* audio_bus_into_converter,
uint32_t frames_delayed) {
// Unfilled frames will be zeroed by CopyTo.
« no previous file with comments | « media/audio/simple_sources.h ('k') | media/audio/simple_sources_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698