Prepare to convert various types to size_t.
This makes some behaviorally-invariant changes to make certain code that
currently only works correctly with signed types work safely regardless of the
signedness of the types in question. This is preparation for a future change
that will convert a variety of types to size_t.
There are also some formatting changes (e.g. converting "enum hack" usage to real consts) to make it simpler to just change "int" to "size_t" in the future to change the types of those constants.
BUG=none
R=andrew@webrtc.org, juberti@webrtc.org, kwiberg@webrtc.org
TBR=ajm
Review URL: https://codereview.webrtc.org/1174813003
Cr-Commit-Position: refs/heads/master@{#9413}
diff --git a/webrtc/modules/audio_coding/neteq/neteq_impl.cc b/webrtc/modules/audio_coding/neteq/neteq_impl.cc
index 8cd9aeb..2d4ff27 100644
--- a/webrtc/modules/audio_coding/neteq/neteq_impl.cc
+++ b/webrtc/modules/audio_coding/neteq/neteq_impl.cc
@@ -1520,10 +1520,10 @@
borrowed_samples_per_channel = static_cast<int>(required_samples -
decoded_length_per_channel);
// Calculate how many of these were already played out.
- old_borrowed_samples_per_channel = static_cast<int>(
- borrowed_samples_per_channel - sync_buffer_->FutureLength());
- old_borrowed_samples_per_channel = std::max(
- 0, old_borrowed_samples_per_channel);
+ const int future_length = static_cast<int>(sync_buffer_->FutureLength());
+ old_borrowed_samples_per_channel =
+ (borrowed_samples_per_channel > future_length) ?
+ (borrowed_samples_per_channel - future_length) : 0;
memmove(&decoded_buffer[borrowed_samples_per_channel * num_channels],
decoded_buffer,
sizeof(int16_t) * decoded_length);