Commit aa998003 authored by crogers@google.com's avatar crogers@google.com

Fix crash in AudioFileReader::Read() by checking for properly initialized AVCodec

Review URL: http://codereview.chromium.org/7785003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@98863 0039d316-1c4b-4281-b951-d872f2087c98
parent 5d904b9e
...@@ -90,7 +90,15 @@ bool AudioFileReader::Open() { ...@@ -90,7 +90,15 @@ bool AudioFileReader::Open() {
return false; return false;
} }
result = av_seek_frame(format_context_, 0, 0, 0); if ((result = av_seek_frame(format_context_, 0, 0, 0)) < 0) {
DLOG(WARNING) << "AudioFileReader::Open() : could not seek frame -"
<< " result: " << result;
return false;
}
} else {
DLOG(WARNING) << "AudioFileReader::Open() : could not find codec -"
<< " result: " << result;
return false;
} }
return true; return true;
...@@ -116,8 +124,8 @@ bool AudioFileReader::Read(const std::vector<float*>& audio_data, ...@@ -116,8 +124,8 @@ bool AudioFileReader::Read(const std::vector<float*>& audio_data,
if (audio_data.size() != channels) if (audio_data.size() != channels)
return false; return false;
DCHECK(format_context_ && codec_context_); DCHECK(format_context_ && codec_context_ && codec_);
if (!format_context_ || !codec_context_) { if (!format_context_ || !codec_context_ || !codec_) {
DLOG(WARNING) << "AudioFileReader::Read() : reader is not opened!"; DLOG(WARNING) << "AudioFileReader::Read() : reader is not opened!";
return false; return false;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment