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

Side by Side Diff: media/renderers/renderer_impl_unittest.cc

Issue 2558213002: Fix crash in renderer initialization when media pipeline is stopped (Closed)
Patch Set: Added a comment for DemuxerStreamProvider::GetStream Created 4 years 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 | « media/renderers/renderer_impl.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 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 <stdint.h> 5 #include <stdint.h>
6 6
7 #include <memory> 7 #include <memory>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 void CreateEncryptedVideoStream() { CreateVideoStream(true); } 143 void CreateEncryptedVideoStream() { CreateVideoStream(true); }
144 144
145 void CreateAudioAndVideoStream() { 145 void CreateAudioAndVideoStream() {
146 CreateAudioStream(); 146 CreateAudioStream();
147 CreateVideoStream(); 147 CreateVideoStream();
148 } 148 }
149 149
150 void InitializeWithAudio() { 150 void InitializeWithAudio() {
151 CreateAudioStream(); 151 CreateAudioStream();
152 SetAudioRendererInitializeExpectations(PIPELINE_OK); 152 SetAudioRendererInitializeExpectations(PIPELINE_OK);
153 // There is a potential race between HTMLMediaElement/WMPI shutdown and
154 // renderers being initialized which might result in DemuxerStreamProvider
155 // GetStream suddenly returning NULL (see crbug.com/668604). So we are going
156 // to check here that GetStream will be invoked exactly 3 times during
157 // RendererImpl initialization to help catch potential issues. Currently the
158 // GetStream is invoked once directly from RendererImpl::Initialize, once
159 // indirectly from RendererImpl::Initialize via HasEncryptedStream and once
160 // from RendererImpl::InitializeAudioRenderer.
161 EXPECT_CALL(*demuxer_, GetStream(DemuxerStream::AUDIO))
162 .Times(2)
163 .WillRepeatedly(Return(audio_stream_.get()));
153 InitializeAndExpect(PIPELINE_OK); 164 InitializeAndExpect(PIPELINE_OK);
154 } 165 }
155 166
156 void InitializeWithVideo() { 167 void InitializeWithVideo() {
157 CreateVideoStream(); 168 CreateVideoStream();
158 SetVideoRendererInitializeExpectations(PIPELINE_OK); 169 SetVideoRendererInitializeExpectations(PIPELINE_OK);
170 // There is a potential race between HTMLMediaElement/WMPI shutdown and
171 // renderers being initialized which might result in DemuxerStreamProvider
172 // GetStream suddenly returning NULL (see crbug.com/668604). So we are going
173 // to check here that GetStream will be invoked exactly 3 times during
174 // RendererImpl initialization to help catch potential issues. Currently the
175 // GetStream is invoked once directly from RendererImpl::Initialize, once
176 // indirectly from RendererImpl::Initialize via HasEncryptedStream and once
177 // from RendererImpl::InitializeVideoRenderer.
178 EXPECT_CALL(*demuxer_, GetStream(DemuxerStream::VIDEO))
179 .Times(2)
180 .WillRepeatedly(Return(video_stream_.get()));
159 InitializeAndExpect(PIPELINE_OK); 181 InitializeAndExpect(PIPELINE_OK);
160 } 182 }
161 183
162 void InitializeWithAudioAndVideo() { 184 void InitializeWithAudioAndVideo() {
163 CreateAudioAndVideoStream(); 185 CreateAudioAndVideoStream();
164 SetAudioRendererInitializeExpectations(PIPELINE_OK); 186 SetAudioRendererInitializeExpectations(PIPELINE_OK);
165 SetVideoRendererInitializeExpectations(PIPELINE_OK); 187 SetVideoRendererInitializeExpectations(PIPELINE_OK);
166 InitializeAndExpect(PIPELINE_OK); 188 InitializeAndExpect(PIPELINE_OK);
167 } 189 }
168 190
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after
736 EXPECT_CALL(*audio_renderer_, Flush(_)).WillOnce(RunClosure<0>()); 758 EXPECT_CALL(*audio_renderer_, Flush(_)).WillOnce(RunClosure<0>());
737 EXPECT_CALL(*audio_renderer_, StartPlaying()).Times(1); 759 EXPECT_CALL(*audio_renderer_, StartPlaying()).Times(1);
738 audio_stream_status_change_cb.Run(false, time0); 760 audio_stream_status_change_cb.Run(false, time0);
739 761
740 EXPECT_CALL(*video_renderer_, Flush(_)).WillOnce(RunClosure<0>()); 762 EXPECT_CALL(*video_renderer_, Flush(_)).WillOnce(RunClosure<0>());
741 EXPECT_CALL(*video_renderer_, StartPlayingFrom(_)).Times(1); 763 EXPECT_CALL(*video_renderer_, StartPlayingFrom(_)).Times(1);
742 video_stream_status_change_cb.Run(false, time0); 764 video_stream_status_change_cb.Run(false, time0);
743 } 765 }
744 766
745 } // namespace media 767 } // namespace media
OLDNEW
« no previous file with comments | « media/renderers/renderer_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698