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

Unified Diff: webrtc/modules/audio_coding/neteq/packet_buffer.cc

Issue 2969123003: NetEq: Rectify the implementation of PacketBuffer::DiscardOldPackets (Closed)
Patch Set: Updates after review Created 3 years, 5 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 | « no previous file | webrtc/modules/audio_coding/neteq/packet_buffer_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/modules/audio_coding/neteq/packet_buffer.cc
diff --git a/webrtc/modules/audio_coding/neteq/packet_buffer.cc b/webrtc/modules/audio_coding/neteq/packet_buffer.cc
index cea6b3dbfbfdfc76164c7c0ccfedb51fff01c340..4c8c462a2466ca192bdacc187077abc16a8c2125 100644
--- a/webrtc/modules/audio_coding/neteq/packet_buffer.cc
+++ b/webrtc/modules/audio_coding/neteq/packet_buffer.cc
@@ -221,15 +221,13 @@ int PacketBuffer::DiscardNextPacket(StatisticsCalculator* stats) {
void PacketBuffer::DiscardOldPackets(uint32_t timestamp_limit,
uint32_t horizon_samples,
StatisticsCalculator* stats) {
- // TODO(minyue): the following implementation is wrong. It won't discard
- // old packets if the buffer_.front() is newer than timestamp_limit -
- // horizon_samples. https://bugs.chromium.org/p/webrtc/issues/detail?id=7937
- while (!Empty() && timestamp_limit != buffer_.front().timestamp &&
- IsObsoleteTimestamp(buffer_.front().timestamp, timestamp_limit,
- horizon_samples)) {
- if (DiscardNextPacket(stats) != kOK) {
- assert(false); // Must be ok by design.
- }
+ const size_t old_size = buffer_.size();
+ buffer_.remove_if([timestamp_limit, horizon_samples](const Packet& p) {
+ return timestamp_limit != p.timestamp &&
+ IsObsoleteTimestamp(p.timestamp, timestamp_limit, horizon_samples);
+ });
+ if (old_size > buffer_.size()) {
+ stats->PacketsDiscarded(old_size - buffer_.size());
}
}
« no previous file with comments | « no previous file | webrtc/modules/audio_coding/neteq/packet_buffer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698