| Index: webrtc/modules/audio_coding/neteq/tools/input_audio_file.cc
|
| diff --git a/webrtc/modules/audio_coding/neteq/tools/input_audio_file.cc b/webrtc/modules/audio_coding/neteq/tools/input_audio_file.cc
|
| index 6bbb3286e4943b38d32e4a7244458cf90518e9d9..e2ec419b24d828b2fd1ff1af50ccb0f27906d22d 100644
|
| --- a/webrtc/modules/audio_coding/neteq/tools/input_audio_file.cc
|
| +++ b/webrtc/modules/audio_coding/neteq/tools/input_audio_file.cc
|
| @@ -10,6 +10,8 @@
|
|
|
| #include "webrtc/modules/audio_coding/neteq/tools/input_audio_file.h"
|
|
|
| +#include "webrtc/base/checks.h"
|
| +
|
| namespace webrtc {
|
| namespace test {
|
|
|
| @@ -37,6 +39,25 @@ bool InputAudioFile::Read(size_t samples, int16_t* destination) {
|
| return true;
|
| }
|
|
|
| +bool InputAudioFile::Seek(int samples) {
|
| + if (!fp_) {
|
| + return false;
|
| + }
|
| + // Find file boundaries.
|
| + const long current_pos = ftell(fp_);
|
| + CHECK_NE(EOF, current_pos) << "Error returned when getting file position.";
|
| + CHECK_EQ(0, fseek(fp_, 0, SEEK_END)); // Move to end of file.
|
| + const long file_size = ftell(fp_);
|
| + CHECK_NE(EOF, file_size) << "Error returned when getting file position.";
|
| + // Find new position.
|
| + long new_pos = current_pos + sizeof(int16_t) * samples; // Samples to bytes.
|
| + CHECK_GE(new_pos, 0) << "Trying to move to before the beginning of the file";
|
| + new_pos = new_pos % file_size; // Wrap around the end of the file.
|
| + // Move to new position relative to the beginning of the file.
|
| + CHECK_EQ(0, fseek(fp_, new_pos, SEEK_SET));
|
| + return true;
|
| +}
|
| +
|
| void InputAudioFile::DuplicateInterleaved(const int16_t* source, size_t samples,
|
| size_t channels,
|
| int16_t* destination) {
|
|
|