| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/composite_filter.h" | 5 #include "media/base/composite_filter.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/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 break; | 166 break; |
| 167 case kSeekPending: | 167 case kSeekPending: |
| 168 ChangeState(kStopWhileSeekPending); | 168 ChangeState(kStopWhileSeekPending); |
| 169 break; | 169 break; |
| 170 default: | 170 default: |
| 171 SendErrorToHost(PIPELINE_ERROR_INVALID_STATE); | 171 SendErrorToHost(PIPELINE_ERROR_INVALID_STATE); |
| 172 stop_callback.Run(); | 172 stop_callback.Run(); |
| 173 return; | 173 return; |
| 174 } | 174 } |
| 175 | 175 |
| 176 if (!status_cb_.is_null()) { |
| 177 DCHECK_EQ(state_, kStopWhileSeekPending); |
| 178 status_cb_.Reset(); |
| 179 } |
| 180 |
| 176 callback_ = stop_callback; | 181 callback_ = stop_callback; |
| 177 if (state_ == kStopPending) { | 182 if (state_ == kStopPending) { |
| 178 StartSerialCallSequence(); | 183 StartSerialCallSequence(); |
| 179 } | 184 } |
| 180 } | 185 } |
| 181 | 186 |
| 182 void CompositeFilter::SetPlaybackRate(float playback_rate) { | 187 void CompositeFilter::SetPlaybackRate(float playback_rate) { |
| 183 DCHECK_EQ(message_loop_, MessageLoop::current()); | 188 DCHECK_EQ(message_loop_, MessageLoop::current()); |
| 184 for (FilterVector::iterator iter = filters_.begin(); | 189 for (FilterVector::iterator iter = filters_.begin(); |
| 185 iter != filters_.end(); | 190 iter != filters_.end(); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 filter->Flush(callback); | 266 filter->Flush(callback); |
| 262 break; | 267 break; |
| 263 case kStopPending: | 268 case kStopPending: |
| 264 filter->Stop(callback); | 269 filter->Stop(callback); |
| 265 break; | 270 break; |
| 266 case kSeekPending: | 271 case kSeekPending: |
| 267 filter->Seek(pending_seek_time_, | 272 filter->Seek(pending_seek_time_, |
| 268 base::Bind(&CompositeFilter::OnStatusCB, this, callback)); | 273 base::Bind(&CompositeFilter::OnStatusCB, this, callback)); |
| 269 break; | 274 break; |
| 270 default: | 275 default: |
| 271 | |
| 272 ChangeState(kError); | 276 ChangeState(kError); |
| 273 DispatchPendingCallback(PIPELINE_ERROR_INVALID_STATE); | 277 DispatchPendingCallback(PIPELINE_ERROR_INVALID_STATE); |
| 274 } | 278 } |
| 275 } | 279 } |
| 276 | 280 |
| 277 void CompositeFilter::DispatchPendingCallback(PipelineStatus status) { | 281 void CompositeFilter::DispatchPendingCallback(PipelineStatus status) { |
| 278 DCHECK(status_cb_.is_null() ^ callback_.is_null()); | 282 DCHECK(status_cb_.is_null() ^ callback_.is_null()); |
| 279 | 283 |
| 280 if (!status_cb_.is_null()) { | 284 if (!status_cb_.is_null()) { |
| 281 ResetAndRunCB(&status_cb_, status); | 285 ResetAndRunCB(&status_cb_, status); |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 | 426 |
| 423 return !callback_.is_null() || !status_cb_.is_null(); | 427 return !callback_.is_null() || !status_cb_.is_null(); |
| 424 } | 428 } |
| 425 | 429 |
| 426 void CompositeFilter::OnStatusCB(const base::Closure& callback, | 430 void CompositeFilter::OnStatusCB(const base::Closure& callback, |
| 427 PipelineStatus status) { | 431 PipelineStatus status) { |
| 428 if (status != PIPELINE_OK) | 432 if (status != PIPELINE_OK) |
| 429 SetError(status); | 433 SetError(status); |
| 430 | 434 |
| 431 callback.Run(); | 435 callback.Run(); |
| 432 | |
| 433 } | 436 } |
| 434 | 437 |
| 435 void CompositeFilter::SetError(PipelineStatus error) { | 438 void CompositeFilter::SetError(PipelineStatus error) { |
| 436 // TODO(acolwell): Temporary hack to handle errors that occur | 439 // TODO(acolwell): Temporary hack to handle errors that occur |
| 437 // during filter initialization. In this case we just forward | 440 // during filter initialization. In this case we just forward |
| 438 // the error to the host even if it is on the wrong thread. We | 441 // the error to the host even if it is on the wrong thread. We |
| 439 // have to do this because if we defer the call, we can't be | 442 // have to do this because if we defer the call, we can't be |
| 440 // sure the host will get the error before the "init done" callback | 443 // sure the host will get the error before the "init done" callback |
| 441 // is executed. This will be cleaned up when filter init is refactored. | 444 // is executed. This will be cleaned up when filter init is refactored. |
| 442 if (state_ == kCreated) { | 445 if (state_ == kCreated) { |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 535 | 538 |
| 536 void CompositeFilter::FilterHostImpl::SetCurrentReadPosition(int64 offset) { | 539 void CompositeFilter::FilterHostImpl::SetCurrentReadPosition(int64 offset) { |
| 537 host_->SetCurrentReadPosition(offset); | 540 host_->SetCurrentReadPosition(offset); |
| 538 } | 541 } |
| 539 | 542 |
| 540 int64 CompositeFilter::FilterHostImpl::GetCurrentReadPosition() { | 543 int64 CompositeFilter::FilterHostImpl::GetCurrentReadPosition() { |
| 541 return host_->GetCurrentReadPosition(); | 544 return host_->GetCurrentReadPosition(); |
| 542 } | 545 } |
| 543 | 546 |
| 544 } // namespace media | 547 } // namespace media |
| OLD | NEW |