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

Side by Side Diff: media/filters/video_frame_stream_unittest.cc

Issue 2841553003: media: Discard the previous decoder immediately on fallback (Closed)
Patch Set: Remove out of date comments Created 3 years, 8 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
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 <utility> 5 #include <utility>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback_helpers.h" 8 #include "base/callback_helpers.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 959 matching lines...) Expand 10 before | Expand all | Expand 10 after
970 video_frame_stream_->get_pending_buffers_size_for_testing()); 970 video_frame_stream_->get_pending_buffers_size_for_testing());
971 971
972 decoder2_->SatisfyDecode(); 972 decoder2_->SatisfyDecode();
973 base::RunLoop().RunUntilIdle(); 973 base::RunLoop().RunUntilIdle();
974 974
975 // Make sure all buffers consumed by |decoder2_| have come from the fallback. 975 // Make sure all buffers consumed by |decoder2_| have come from the fallback.
976 // Pending buffers should not have been cleared yet. 976 // Pending buffers should not have been cleared yet.
977 EXPECT_EQ(0, video_frame_stream_->get_fallback_buffers_size_for_testing()); 977 EXPECT_EQ(0, video_frame_stream_->get_fallback_buffers_size_for_testing());
978 EXPECT_EQ(demuxer_reads_satisfied, 978 EXPECT_EQ(demuxer_reads_satisfied,
979 video_frame_stream_->get_pending_buffers_size_for_testing()); 979 video_frame_stream_->get_pending_buffers_size_for_testing());
980 EXPECT_EQ(video_frame_stream_->get_previous_decoder_for_testing(), decoder1_);
981 EXPECT_TRUE(pending_read_); 980 EXPECT_TRUE(pending_read_);
982 981
983 // Give the decoder one more buffer, enough to release a frame. 982 // Give the decoder one more buffer, enough to release a frame.
984 demuxer_stream_->SatisfyReadAndHoldNext(); 983 demuxer_stream_->SatisfyReadAndHoldNext();
985 base::RunLoop().RunUntilIdle(); 984 base::RunLoop().RunUntilIdle();
986 985
987 // New buffers should not have been added after the frame was released. 986 // New buffers should not have been added after the frame was released.
988 EXPECT_EQ(video_frame_stream_->get_pending_buffers_size_for_testing(), 0); 987 EXPECT_EQ(video_frame_stream_->get_pending_buffers_size_for_testing(), 0);
989 EXPECT_FALSE(pending_read_); 988 EXPECT_FALSE(pending_read_);
990 989
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
1076 ReadOneFrame(); 1075 ReadOneFrame();
1077 base::RunLoop().RunUntilIdle(); 1076 base::RunLoop().RunUntilIdle();
1078 EXPECT_FALSE(pending_read_); 1077 EXPECT_FALSE(pending_read_);
1079 } 1078 }
1080 EXPECT_EQ(VideoFrameStream::DECODE_ERROR, last_read_status_); 1079 EXPECT_EQ(VideoFrameStream::DECODE_ERROR, last_read_status_);
1081 } 1080 }
1082 1081
1083 TEST_P(VideoFrameStreamTest, FallbackDecoderSelectedOnFailureToReinitialize) { 1082 TEST_P(VideoFrameStreamTest, FallbackDecoderSelectedOnFailureToReinitialize) {
1084 Initialize(); 1083 Initialize();
1085 decoder1_->SimulateFailureToInit(); 1084 decoder1_->SimulateFailureToInit();
1086 // Holding decode, because large decoder delays might cause us to get rid of
1087 // |previous_decoder_| before we are in a pending state again.
1088 decoder2_->HoldDecode();
1089 ReadUntilDecoderReinitialized(decoder1_); 1085 ReadUntilDecoderReinitialized(decoder1_);
1090 ASSERT_TRUE(video_frame_stream_->get_previous_decoder_for_testing());
1091 decoder2_->SatisfyDecode();
1092 base::RunLoop().RunUntilIdle();
1093 ReadAllFrames(); 1086 ReadAllFrames();
1094 ASSERT_FALSE(video_frame_stream_->get_previous_decoder_for_testing()); 1087 ASSERT_GT(decoder2_->total_bytes_decoded(), 0);
1095 } 1088 }
1096 1089
1097 TEST_P(VideoFrameStreamTest, 1090 TEST_P(VideoFrameStreamTest,
1098 FallbackDecoderSelectedOnFailureToReinitialize_Twice) { 1091 FallbackDecoderSelectedOnFailureToReinitialize_Twice) {
1099 Initialize(); 1092 Initialize();
1100 decoder1_->SimulateFailureToInit(); 1093 decoder1_->SimulateFailureToInit();
1101 ReadUntilDecoderReinitialized(decoder1_); 1094 ReadUntilDecoderReinitialized(decoder1_);
1102 ReadOneFrame(); 1095 ReadOneFrame();
1103 decoder2_->SimulateFailureToInit(); 1096 decoder2_->SimulateFailureToInit();
1104 ReadUntilDecoderReinitialized(decoder2_); 1097 ReadUntilDecoderReinitialized(decoder2_);
(...skipping 17 matching lines...) Expand all
1122 1115
1123 TEST_P(VideoFrameStreamTest, Destroy_DuringFallbackDecoderSelection) { 1116 TEST_P(VideoFrameStreamTest, Destroy_DuringFallbackDecoderSelection) {
1124 Initialize(); 1117 Initialize();
1125 decoder1_->SimulateFailureToInit(); 1118 decoder1_->SimulateFailureToInit();
1126 EnterPendingState(DECODER_REINIT); 1119 EnterPendingState(DECODER_REINIT);
1127 decoder2_->HoldNextInit(); 1120 decoder2_->HoldNextInit();
1128 SatisfyPendingCallback(DECODER_REINIT); 1121 SatisfyPendingCallback(DECODER_REINIT);
1129 } 1122 }
1130 1123
1131 } // namespace media 1124 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698