OLD | NEW |
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 "media/filters/renderer_impl.h" | 5 #include "media/filters/renderer_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 RendererImpl::~RendererImpl() { | 45 RendererImpl::~RendererImpl() { |
46 DVLOG(1) << __FUNCTION__; | 46 DVLOG(1) << __FUNCTION__; |
47 DCHECK(task_runner_->BelongsToCurrentThread()); | 47 DCHECK(task_runner_->BelongsToCurrentThread()); |
48 | 48 |
49 audio_renderer_.reset(); | 49 audio_renderer_.reset(); |
50 video_renderer_.reset(); | 50 video_renderer_.reset(); |
51 | 51 |
52 FireAllPendingCallbacks(); | 52 FireAllPendingCallbacks(); |
53 } | 53 } |
54 | 54 |
55 void RendererImpl::Initialize(const PipelineStatusCB& init_cb, | 55 void RendererImpl::Initialize(const base::Closure& init_cb, |
56 const StatisticsCB& statistics_cb, | 56 const StatisticsCB& statistics_cb, |
57 const base::Closure& ended_cb, | 57 const base::Closure& ended_cb, |
58 const PipelineStatusCB& error_cb, | 58 const PipelineStatusCB& error_cb, |
59 const BufferingStateCB& buffering_state_cb, | 59 const BufferingStateCB& buffering_state_cb, |
60 const TimeDeltaCB& get_duration_cb) { | 60 const TimeDeltaCB& get_duration_cb) { |
61 DVLOG(1) << __FUNCTION__; | 61 DVLOG(1) << __FUNCTION__; |
62 DCHECK(task_runner_->BelongsToCurrentThread()); | 62 DCHECK(task_runner_->BelongsToCurrentThread()); |
63 DCHECK_EQ(state_, STATE_UNINITIALIZED) << state_; | 63 DCHECK_EQ(state_, STATE_UNINITIALIZED) << state_; |
64 DCHECK(!init_cb.is_null()); | 64 DCHECK(!init_cb.is_null()); |
65 DCHECK(!statistics_cb.is_null()); | 65 DCHECK(!statistics_cb.is_null()); |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 } | 214 } |
215 | 215 |
216 void RendererImpl::OnAudioRendererInitializeDone(PipelineStatus status) { | 216 void RendererImpl::OnAudioRendererInitializeDone(PipelineStatus status) { |
217 DVLOG(1) << __FUNCTION__ << ": " << status; | 217 DVLOG(1) << __FUNCTION__ << ": " << status; |
218 DCHECK(task_runner_->BelongsToCurrentThread()); | 218 DCHECK(task_runner_->BelongsToCurrentThread()); |
219 DCHECK_EQ(state_, STATE_INITIALIZING) << state_; | 219 DCHECK_EQ(state_, STATE_INITIALIZING) << state_; |
220 DCHECK(!init_cb_.is_null()); | 220 DCHECK(!init_cb_.is_null()); |
221 | 221 |
222 if (status != PIPELINE_OK) { | 222 if (status != PIPELINE_OK) { |
223 audio_renderer_.reset(); | 223 audio_renderer_.reset(); |
224 state_ = STATE_ERROR; | 224 OnError(status); |
225 base::ResetAndReturn(&init_cb_).Run(status); | |
226 return; | 225 return; |
227 } | 226 } |
228 | 227 |
229 if (audio_renderer_) | 228 if (audio_renderer_) |
230 time_source_ = audio_renderer_->GetTimeSource(); | 229 time_source_ = audio_renderer_->GetTimeSource(); |
231 | 230 |
232 InitializeVideoRenderer(); | 231 InitializeVideoRenderer(); |
233 } | 232 } |
234 | 233 |
235 void RendererImpl::InitializeVideoRenderer() { | 234 void RendererImpl::InitializeVideoRenderer() { |
(...skipping 27 matching lines...) Expand all Loading... |
263 | 262 |
264 void RendererImpl::OnVideoRendererInitializeDone(PipelineStatus status) { | 263 void RendererImpl::OnVideoRendererInitializeDone(PipelineStatus status) { |
265 DVLOG(1) << __FUNCTION__ << ": " << status; | 264 DVLOG(1) << __FUNCTION__ << ": " << status; |
266 DCHECK(task_runner_->BelongsToCurrentThread()); | 265 DCHECK(task_runner_->BelongsToCurrentThread()); |
267 DCHECK_EQ(state_, STATE_INITIALIZING) << state_; | 266 DCHECK_EQ(state_, STATE_INITIALIZING) << state_; |
268 DCHECK(!init_cb_.is_null()); | 267 DCHECK(!init_cb_.is_null()); |
269 | 268 |
270 if (status != PIPELINE_OK) { | 269 if (status != PIPELINE_OK) { |
271 audio_renderer_.reset(); | 270 audio_renderer_.reset(); |
272 video_renderer_.reset(); | 271 video_renderer_.reset(); |
273 state_ = STATE_ERROR; | 272 OnError(status); |
274 base::ResetAndReturn(&init_cb_).Run(status); | |
275 return; | 273 return; |
276 } | 274 } |
277 | 275 |
278 state_ = STATE_PLAYING; | 276 state_ = STATE_PLAYING; |
279 DCHECK(audio_renderer_ || video_renderer_); | 277 DCHECK(audio_renderer_ || video_renderer_); |
280 base::ResetAndReturn(&init_cb_).Run(PIPELINE_OK); | 278 base::ResetAndReturn(&init_cb_).Run(); |
281 } | 279 } |
282 | 280 |
283 void RendererImpl::FlushAudioRenderer() { | 281 void RendererImpl::FlushAudioRenderer() { |
284 DVLOG(1) << __FUNCTION__; | 282 DVLOG(1) << __FUNCTION__; |
285 DCHECK(task_runner_->BelongsToCurrentThread()); | 283 DCHECK(task_runner_->BelongsToCurrentThread()); |
286 DCHECK_EQ(state_, STATE_FLUSHING) << state_; | 284 DCHECK_EQ(state_, STATE_FLUSHING) << state_; |
287 DCHECK(!flush_cb_.is_null()); | 285 DCHECK(!flush_cb_.is_null()); |
288 | 286 |
289 if (!audio_renderer_) { | 287 if (!audio_renderer_) { |
290 OnAudioRendererFlushDone(); | 288 OnAudioRendererFlushDone(); |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
557 // Pipeline will destroy |this| as the result of error. | 555 // Pipeline will destroy |this| as the result of error. |
558 base::ResetAndReturn(&error_cb_).Run(error); | 556 base::ResetAndReturn(&error_cb_).Run(error); |
559 | 557 |
560 FireAllPendingCallbacks(); | 558 FireAllPendingCallbacks(); |
561 } | 559 } |
562 | 560 |
563 void RendererImpl::FireAllPendingCallbacks() { | 561 void RendererImpl::FireAllPendingCallbacks() { |
564 DCHECK(task_runner_->BelongsToCurrentThread()); | 562 DCHECK(task_runner_->BelongsToCurrentThread()); |
565 | 563 |
566 if (!init_cb_.is_null()) | 564 if (!init_cb_.is_null()) |
567 base::ResetAndReturn(&init_cb_).Run(PIPELINE_ERROR_ABORT); | 565 base::ResetAndReturn(&init_cb_).Run(); |
568 | 566 |
569 if (!flush_cb_.is_null()) | 567 if (!flush_cb_.is_null()) |
570 base::ResetAndReturn(&flush_cb_).Run(); | 568 base::ResetAndReturn(&flush_cb_).Run(); |
571 } | 569 } |
572 | 570 |
573 } // namespace media | 571 } // namespace media |
OLD | NEW |