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

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

Issue 405143003: Merge 279817 "Don't crash on splice frame failure with bad content." (Closed) Base URL: svn://svn.chromium.org/chrome/branches/2062/src/
Patch Set: Created 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « media/base/audio_splicer.cc ('k') | 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 (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 "base/memory/scoped_ptr.h" 5 #include "base/memory/scoped_ptr.h"
6 #include "media/base/audio_buffer.h" 6 #include "media/base/audio_buffer.h"
7 #include "media/base/audio_bus.h" 7 #include "media/base/audio_bus.h"
8 #include "media/base/audio_splicer.h" 8 #include "media/base/audio_splicer.h"
9 #include "media/base/audio_timestamp_helper.h" 9 #include "media/base/audio_timestamp_helper.h"
10 #include "media/base/buffers.h" 10 #include "media/base/buffers.h"
(...skipping 664 matching lines...) Expand 10 before | Expand all | Expand 10 after
675 675
676 // |second_buffer| will complete the supposed splice. 676 // |second_buffer| will complete the supposed splice.
677 splicer_.SetSpliceTimestamp(kNoTimestamp()); 677 splicer_.SetSpliceTimestamp(kNoTimestamp());
678 EXPECT_TRUE(AddInput(second_buffer)); 678 EXPECT_TRUE(AddInput(second_buffer));
679 679
680 VerifyNextBuffer(gap_buffer); 680 VerifyNextBuffer(gap_buffer);
681 VerifyNextBuffer(second_buffer); 681 VerifyNextBuffer(second_buffer);
682 EXPECT_FALSE(splicer_.HasNextBuffer()); 682 EXPECT_FALSE(splicer_.HasNextBuffer());
683 } 683 }
684 684
685 // Test behavior when a splice frame is incorrectly marked and there is a gap
686 // between what's in the pre splice and post splice that is too large to recover
687 // from.
688 // +--------+
689 // |11111111|
690 // +--------+
691 // +------+
692 // |222222|
693 // +------+
694 // Results in an error and not a crash.
695 TEST_F(AudioSplicerTest, IncorrectlyMarkedSpliceWithBadGap) {
696 const int kBufferSize =
697 input_timestamp_helper_.GetFramesToTarget(max_crossfade_duration()) * 2;
698 const int kGapSize = kBufferSize +
699 input_timestamp_helper_.GetFramesToTarget(
700 base::TimeDelta::FromMilliseconds(
701 AudioSplicer::kMaxTimeDeltaInMilliseconds + 1));
702
703 scoped_refptr<AudioBuffer> first_buffer =
704 GetNextInputBuffer(1.0f, kBufferSize);
705 scoped_refptr<AudioBuffer> gap_buffer =
706 GetNextInputBuffer(0.0f, kGapSize);
707 splicer_.SetSpliceTimestamp(input_timestamp_helper_.GetTimestamp());
708 scoped_refptr<AudioBuffer> second_buffer =
709 GetNextInputBuffer(0.0f, kBufferSize);
710
711 // The splicer should pass through the first buffer since it's not part of the
712 // splice.
713 EXPECT_TRUE(AddInput(first_buffer));
714 VerifyNextBuffer(first_buffer);
715
716 // Do not add |gap_buffer|.
717
718 // |second_buffer| will complete the supposed splice.
719 splicer_.SetSpliceTimestamp(kNoTimestamp());
720 EXPECT_FALSE(AddInput(second_buffer));
721 }
722
685 } // namespace media 723 } // namespace media
OLDNEW
« no previous file with comments | « media/base/audio_splicer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698