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

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: 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/simple_sources.cc
diff --git a/media/audio/simple_sources.cc b/media/audio/simple_sources.cc
index f20343a4ee49c6c8bb25bc99e8a3d79e1d4189d2..8d44d9cd37c657fa787be7ffb8bab00509fb7af3 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 looping)
: params_(params),
path_to_wav_file_(path_to_wav_file),
wav_file_read_pos_(0),
- load_failed_(false) {
-}
+ load_failed_(false),
+ looping_(looping) {}
FileSource::~FileSource() {
}
@@ -213,15 +214,21 @@ 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_)) {
+ Rewind();
+ if (!looping_)
+ 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.

Powered by Google App Engine
This is Rietveld 408576698