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

Side by Side Diff: media/base/audio_discard_helper.cc

Issue 2884383003: Replace DCHECK with conditional and error. (Closed)
Patch Set: Created 3 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/base/audio_discard_helper.h" 5 #include "media/base/audio_discard_helper.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "media/base/audio_buffer.h" 10 #include "media/base/audio_buffer.h"
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 187
188 // Handle end discard padding. 188 // Handle end discard padding.
189 if (current_discard_padding.second > base::TimeDelta()) { 189 if (current_discard_padding.second > base::TimeDelta()) {
190 const size_t decoded_frames = decoded_buffer->frame_count(); 190 const size_t decoded_frames = decoded_buffer->frame_count();
191 size_t end_frames_to_discard = 191 size_t end_frames_to_discard =
192 TimeDeltaToFrames(current_discard_padding.second); 192 TimeDeltaToFrames(current_discard_padding.second);
193 193
194 if (decoder_delay_) { 194 if (decoder_delay_) {
195 // Delayed end discard only works if the decoder delay is less than a 195 // Delayed end discard only works if the decoder delay is less than a
196 // single buffer. 196 // single buffer.
197 DCHECK_LT(decoder_delay_, original_frame_count); 197 if (decoder_delay_ >= original_frame_count) {
198 DLOG(ERROR) << "Encountered invalid discard padding value.";
199 return false;
200 }
198 201
199 // If the discard is >= the decoder delay, trim everything we can off the 202 // If the discard is >= the decoder delay, trim everything we can off the
200 // end of this buffer and the rest from the start of the next. 203 // end of this buffer and the rest from the start of the next.
201 if (end_frames_to_discard >= decoder_delay_) { 204 if (end_frames_to_discard >= decoder_delay_) {
202 DCHECK(!discard_frames_); 205 DCHECK(!discard_frames_);
203 discard_frames_ = decoder_delay_; 206 discard_frames_ = decoder_delay_;
204 end_frames_to_discard -= decoder_delay_; 207 end_frames_to_discard -= decoder_delay_;
205 } else { 208 } else {
206 DCHECK(!delayed_end_discard_); 209 DCHECK(!delayed_end_discard_);
207 std::swap(delayed_end_discard_, end_frames_to_discard); 210 std::swap(delayed_end_discard_, end_frames_to_discard);
(...skipping 22 matching lines...) Expand all
230 DVLOG(3) << __func__ << " ts: " << timestamp_helper_.GetTimestamp() 233 DVLOG(3) << __func__ << " ts: " << timestamp_helper_.GetTimestamp()
231 << " frames: " << decoded_buffer->frame_count(); 234 << " frames: " << decoded_buffer->frame_count();
232 235
233 // Assign timestamp to the buffer. 236 // Assign timestamp to the buffer.
234 decoded_buffer->set_timestamp(timestamp_helper_.GetTimestamp()); 237 decoded_buffer->set_timestamp(timestamp_helper_.GetTimestamp());
235 timestamp_helper_.AddFrames(decoded_buffer->frame_count()); 238 timestamp_helper_.AddFrames(decoded_buffer->frame_count());
236 return true; 239 return true;
237 } 240 }
238 241
239 } // namespace media 242 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698