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

Unified Diff: webrtc/modules/audio_coding/neteq/tools/input_audio_file.cc

Issue 1290113002: NetEq: Implement logging of Delayed Packet Outage Events (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Rename InputAudioFile::Move to InputAudioFile::Seek Created 5 years, 4 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
« no previous file with comments | « webrtc/modules/audio_coding/neteq/tools/input_audio_file.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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) {
« no previous file with comments | « webrtc/modules/audio_coding/neteq/tools/input_audio_file.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698