| OLD | NEW |
| 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 "media/base/pipeline.h" | 5 #include "media/base/pipeline.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 | 193 |
| 194 void Pipeline::SetTimeDeltaInterpolatorForTesting( | 194 void Pipeline::SetTimeDeltaInterpolatorForTesting( |
| 195 TimeDeltaInterpolator* interpolator) { | 195 TimeDeltaInterpolator* interpolator) { |
| 196 interpolator_.reset(interpolator); | 196 interpolator_.reset(interpolator); |
| 197 } | 197 } |
| 198 | 198 |
| 199 void Pipeline::SetErrorForTesting(PipelineStatus status) { | 199 void Pipeline::SetErrorForTesting(PipelineStatus status) { |
| 200 OnError(status); | 200 OnError(status); |
| 201 } | 201 } |
| 202 | 202 |
| 203 bool Pipeline::HasWeakPtrsForTesting() const { |
| 204 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 205 return weak_factory_.HasWeakPtrs(); |
| 206 } |
| 207 |
| 203 void Pipeline::SetState(State next_state) { | 208 void Pipeline::SetState(State next_state) { |
| 204 DVLOG(1) << GetStateString(state_) << " -> " << GetStateString(next_state); | 209 DVLOG(1) << GetStateString(state_) << " -> " << GetStateString(next_state); |
| 205 | 210 |
| 206 state_ = next_state; | 211 state_ = next_state; |
| 207 media_log_->AddEvent(media_log_->CreatePipelineStateChangedEvent(next_state)); | 212 media_log_->AddEvent(media_log_->CreatePipelineStateChangedEvent(next_state)); |
| 208 } | 213 } |
| 209 | 214 |
| 210 #define RETURN_STRING(state) case state: return #state; | 215 #define RETURN_STRING(state) case state: return #state; |
| 211 | 216 |
| 212 const char* Pipeline::GetStateString(State state) { | 217 const char* Pipeline::GetStateString(State state) { |
| (...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 595 } | 600 } |
| 596 | 601 |
| 597 StateTransitionTask(PIPELINE_OK); | 602 StateTransitionTask(PIPELINE_OK); |
| 598 } | 603 } |
| 599 | 604 |
| 600 void Pipeline::StopTask(const base::Closure& stop_cb) { | 605 void Pipeline::StopTask(const base::Closure& stop_cb) { |
| 601 DCHECK(task_runner_->BelongsToCurrentThread()); | 606 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 602 DCHECK(stop_cb_.is_null()); | 607 DCHECK(stop_cb_.is_null()); |
| 603 | 608 |
| 604 if (state_ == kStopped) { | 609 if (state_ == kStopped) { |
| 610 // Invalid all weak pointers so it's safe to destroy |this| on the render |
| 611 // main thread. |
| 612 weak_factory_.InvalidateWeakPtrs(); |
| 613 |
| 614 // NOTE: pipeline may be deleted at this point in time as a result of |
| 615 // executing |stop_cb|. |
| 605 stop_cb.Run(); | 616 stop_cb.Run(); |
| 617 |
| 606 return; | 618 return; |
| 607 } | 619 } |
| 608 | 620 |
| 609 stop_cb_ = stop_cb; | 621 stop_cb_ = stop_cb; |
| 610 | 622 |
| 611 // We may already be stopping due to a runtime error. | 623 // We may already be stopping due to a runtime error. |
| 612 if (state_ == kStopping) | 624 if (state_ == kStopping) |
| 613 return; | 625 return; |
| 614 | 626 |
| 615 SetState(kStopping); | 627 SetState(kStopping); |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 911 void Pipeline::StartClockIfWaitingForTimeUpdate_Locked() { | 923 void Pipeline::StartClockIfWaitingForTimeUpdate_Locked() { |
| 912 lock_.AssertAcquired(); | 924 lock_.AssertAcquired(); |
| 913 if (interpolation_state_ != INTERPOLATION_WAITING_FOR_AUDIO_TIME_UPDATE) | 925 if (interpolation_state_ != INTERPOLATION_WAITING_FOR_AUDIO_TIME_UPDATE) |
| 914 return; | 926 return; |
| 915 | 927 |
| 916 interpolation_state_ = INTERPOLATION_STARTED; | 928 interpolation_state_ = INTERPOLATION_STARTED; |
| 917 interpolator_->StartInterpolating(); | 929 interpolator_->StartInterpolating(); |
| 918 } | 930 } |
| 919 | 931 |
| 920 } // namespace media | 932 } // namespace media |
| OLD | NEW |