Fix a bug in InputAudioFile::Read

When the file was rewound, the remaining audio read was inserted at
the start of the destination array, not where the first reading
attempt ended.

R=ivoc@webrtc.org

Review URL: https://codereview.webrtc.org/1612053002

Cr-Commit-Position: refs/heads/master@{#11343}
This commit is contained in:
henrik.lundin
2016-01-21 08:19:57 -08:00
committed by Commit bot
parent af9e6637c0
commit fea3dd83fc

View File

@ -30,8 +30,8 @@ bool InputAudioFile::Read(size_t samples, int16_t* destination) {
// Rewind and read the missing samples.
rewind(fp_);
size_t missing_samples = samples - samples_read;
if (fread(destination, sizeof(int16_t), missing_samples, fp_) <
missing_samples) {
if (fread(destination + samples_read, sizeof(int16_t), missing_samples,
fp_) < missing_samples) {
// Could not read enough even after rewinding the file.
return false;
}