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

Unified Diff: media/base/audio_discard_helper.cc

Issue 293053005: Add support for complete buffer discards. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comments. Created 6 years, 7 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 | media/base/audio_discard_helper_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/audio_discard_helper.cc
diff --git a/media/base/audio_discard_helper.cc b/media/base/audio_discard_helper.cc
index f7279d72cfa8e3b2e7d9e455f485a7350d260289..303ee79f0cc40d8fbe4ced96d8b123c2f7ffa84b 100644
--- a/media/base/audio_discard_helper.cc
+++ b/media/base/audio_discard_helper.cc
@@ -86,8 +86,13 @@ bool AudioDiscardHelper::ProcessBuffers(
// buffer's discard padding for processing with the current decoded buffer.
DecoderBuffer::DiscardPadding current_discard_padding =
encoded_buffer->discard_padding();
- if (delayed_discard_)
+ if (delayed_discard_) {
+ // For simplicity disallow cases where decoder delay is present with delayed
+ // discard (no codecs at present). Doing so allows us to avoid complexity
+ // around endpoint tracking when handling complete buffer discards.
+ DCHECK_EQ(decoder_delay_, 0u);
std::swap(current_discard_padding, delayed_discard_padding_);
+ }
if (discard_frames_ > 0) {
const size_t decoded_frames = decoded_buffer->frame_count();
@@ -110,8 +115,17 @@ bool AudioDiscardHelper::ProcessBuffers(
// Handle front discard padding.
if (current_discard_padding.first > base::TimeDelta()) {
const size_t decoded_frames = decoded_buffer->frame_count();
+
+ // If a complete buffer discard is requested and there's no decoder delay,
+ // just discard all remaining frames from this buffer. With decoder delay
+ // we have to estimate the correct number of frames to discard based on the
+ // duration of the encoded buffer.
const size_t start_frames_to_discard =
- TimeDeltaToFrames(current_discard_padding.first);
+ current_discard_padding.first == kInfiniteDuration()
+ ? (decoder_delay_ > 0
+ ? TimeDeltaToFrames(encoded_buffer->duration())
+ : decoded_frames)
+ : TimeDeltaToFrames(current_discard_padding.first);
// Regardless of the timestamp on the encoded buffer, the corresponding
// decoded output will appear |decoder_delay_| frames later.
« no previous file with comments | « no previous file | media/base/audio_discard_helper_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698