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

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

Issue 440803002: Don't crash when splices are in the past due to bad media. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | media/base/audio_splicer_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_splicer.h" 5 #include "media/base/audio_splicer.h"
6 6
7 #include <cstdlib> 7 #include <cstdlib>
8 #include <deque> 8 #include <deque>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 // Ensure |output_sanitizer_| has a valid base timestamp so we can use it for 295 // Ensure |output_sanitizer_| has a valid base timestamp so we can use it for
296 // timestamp calculations. 296 // timestamp calculations.
297 if (output_ts_helper.base_timestamp() == kNoTimestamp()) { 297 if (output_ts_helper.base_timestamp() == kNoTimestamp()) {
298 output_sanitizer_->ResetTimestampState( 298 output_sanitizer_->ResetTimestampState(
299 0, pre_splice_sanitizer_->timestamp_helper().base_timestamp()); 299 0, pre_splice_sanitizer_->timestamp_helper().base_timestamp());
300 } 300 }
301 301
302 // If a splice frame was incorrectly marked due to poor demuxed timestamps, we 302 // If a splice frame was incorrectly marked due to poor demuxed timestamps, we
303 // may not actually have a splice. Here we check if any frames exist before 303 // may not actually have a splice. Here we check if any frames exist before
304 // the splice. In this case, just transfer all data to the output sanitizer. 304 // the splice. In this case, just transfer all data to the output sanitizer.
305 if (pre_splice_sanitizer_->GetFrameCount() <= 305 const int frames_before_splice =
wolenetz 2014/08/05 01:00:28 I'm trying to grok which part of this condition pr
DaleCurtis 2014/08/05 01:03:10 If frames_before_splice is negative this condition
wolenetz 2014/08/07 23:12:12 Acknowledged.
306 output_ts_helper.GetFramesToTarget(splice_timestamp_)) { 306 output_ts_helper.GetFramesToTarget(splice_timestamp_);
307 if (frames_before_splice < 0 ||
308 pre_splice_sanitizer_->GetFrameCount() <= frames_before_splice) {
307 CHECK(pre_splice_sanitizer_->DrainInto(output_sanitizer_.get())); 309 CHECK(pre_splice_sanitizer_->DrainInto(output_sanitizer_.get()));
308 310
309 // If the file contains incorrectly muxed timestamps, there may be huge gaps 311 // If the file contains incorrectly muxed timestamps, there may be huge gaps
310 // between the demuxed and decoded timestamps. 312 // between the demuxed and decoded timestamps.
311 if (!post_splice_sanitizer_->DrainInto(output_sanitizer_.get())) 313 if (!post_splice_sanitizer_->DrainInto(output_sanitizer_.get()))
312 return false; 314 return false;
313 315
314 reset_splice_timestamps(); 316 reset_splice_timestamps();
315 return true; 317 return true;
316 } 318 }
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 AccurateTrimStart(frames_to_trim, remainder, output_ts_helper); 500 AccurateTrimStart(frames_to_trim, remainder, output_ts_helper);
499 CHECK(output_sanitizer_->AddInput(remainder)); 501 CHECK(output_sanitizer_->AddInput(remainder));
500 } 502 }
501 503
502 // Transfer all remaining buffers out and reset once empty. 504 // Transfer all remaining buffers out and reset once empty.
503 CHECK(post_splice_sanitizer_->DrainInto(output_sanitizer_.get())); 505 CHECK(post_splice_sanitizer_->DrainInto(output_sanitizer_.get()));
504 post_splice_sanitizer_->Reset(); 506 post_splice_sanitizer_->Reset();
505 } 507 }
506 508
507 } // namespace media 509 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | media/base/audio_splicer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698