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

Unified Diff: media/base/audio_splicer_unittest.cc

Issue 339433006: Don't crash on splice frame failure with bad content. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comments. Created 6 years, 6 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 | « media/base/audio_splicer.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/audio_splicer_unittest.cc
diff --git a/media/base/audio_splicer_unittest.cc b/media/base/audio_splicer_unittest.cc
index 2e46b9fb12753ecaef1b55fdb8bef1534fc829ac..e6de2c62ed330ad9433993bd62b5dfbd0ce80ac5 100644
--- a/media/base/audio_splicer_unittest.cc
+++ b/media/base/audio_splicer_unittest.cc
@@ -682,4 +682,42 @@ TEST_F(AudioSplicerTest, IncorrectlyMarkedSpliceWithGap) {
EXPECT_FALSE(splicer_.HasNextBuffer());
}
+// Test behavior when a splice frame is incorrectly marked and there is a gap
+// between what's in the pre splice and post splice that is too large to recover
+// from.
+// +--------+
+// |11111111|
+// +--------+
+// +------+
+// |222222|
+// +------+
+// Results in an error and not a crash.
+TEST_F(AudioSplicerTest, IncorrectlyMarkedSpliceWithBadGap) {
+ const int kBufferSize =
+ input_timestamp_helper_.GetFramesToTarget(max_crossfade_duration()) * 2;
+ const int kGapSize = kBufferSize +
+ input_timestamp_helper_.GetFramesToTarget(
+ base::TimeDelta::FromMilliseconds(
+ AudioSplicer::kMaxTimeDeltaInMilliseconds + 1));
+
+ scoped_refptr<AudioBuffer> first_buffer =
+ GetNextInputBuffer(1.0f, kBufferSize);
+ scoped_refptr<AudioBuffer> gap_buffer =
+ GetNextInputBuffer(0.0f, kGapSize);
+ splicer_.SetSpliceTimestamp(input_timestamp_helper_.GetTimestamp());
+ scoped_refptr<AudioBuffer> second_buffer =
+ GetNextInputBuffer(0.0f, kBufferSize);
+
+ // The splicer should pass through the first buffer since it's not part of the
+ // splice.
+ EXPECT_TRUE(AddInput(first_buffer));
+ VerifyNextBuffer(first_buffer);
+
+ // Do not add |gap_buffer|.
+
+ // |second_buffer| will complete the supposed splice.
+ splicer_.SetSpliceTimestamp(kNoTimestamp());
+ EXPECT_FALSE(AddInput(second_buffer));
+}
+
} // namespace media
« 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