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

Unified Diff: media/audio/simple_sources.cc

Issue 1453233002: Improve input handling for WaveAudioHandler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Remove VLOG()s Created 5 years, 1 month 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 877f9fd5bdac20866823b14574e1c46e03c7e23e..347b21305fe0fa0a3bdf7bc78fdacc6a3a030724 100644
--- a/media/audio/simple_sources.cc
+++ b/media/audio/simple_sources.cc
@@ -49,17 +49,6 @@ static scoped_ptr<uint8[]> ReadWavFile(const base::FilePath& wav_filename,
return scoped_ptr<uint8[]>(wav_file_data);
}
-// Opens |wav_filename|, reads it and loads it as a wav file. This function will
-// bluntly trigger CHECKs if we can't read the file or if it's malformed.
-static scoped_ptr<WavAudioHandler> CreateWavAudioHandler(
- const base::FilePath& wav_filename, const uint8* wav_file_data,
- size_t wav_file_length, const AudioParameters& expected_params) {
- base::StringPiece wav_data(reinterpret_cast<const char*>(wav_file_data),
- wav_file_length);
- scoped_ptr<WavAudioHandler> wav_audio_handler(new WavAudioHandler(wav_data));
- return wav_audio_handler.Pass();
-}
-
// These values are based on experiments for local-to-local
// PeerConnection to demonstrate audio/video synchronization.
static const int kBeepDurationMilliseconds = 20;
@@ -179,8 +168,14 @@ void FileSource::LoadWavFile(const base::FilePath& path_to_wav_file) {
return;
}
- wav_audio_handler_ = CreateWavAudioHandler(
- path_to_wav_file, wav_file_data_.get(), file_length, params_);
+ // Attempt to create a handler with this data. If the data is invalid, return.
+ wav_audio_handler_ = WavAudioHandler::Create(base::StringPiece(
+ reinterpret_cast<const char*>(wav_file_data_.get()), file_length));
+ if (!wav_audio_handler_) {
+ LOG(ERROR) << "WAV data could be read but is not valid";
+ load_failed_ = true;
+ return;
+ }
// Hook us up so we pull in data from the file into the converter. We need to
// modify the wav file's audio parameters since we'll be reading small slices

Powered by Google App Engine
This is Rietveld 408576698