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 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
436 | 436 |
437 void CompositeFilter::OnStatusCB(const base::Closure& callback, | 437 void CompositeFilter::OnStatusCB(const base::Closure& callback, |
438 PipelineStatus status) { | 438 PipelineStatus status) { |
439 if (status != PIPELINE_OK) | 439 if (status != PIPELINE_OK) |
440 SetError(status); | 440 SetError(status); |
441 | 441 |
442 callback.Run(); | 442 callback.Run(); |
443 } | 443 } |
444 | 444 |
445 void CompositeFilter::SetError(PipelineStatus error) { | 445 void CompositeFilter::SetError(PipelineStatus error) { |
446 // TODO(acolwell): Temporary hack to handle errors that occur | |
447 // during filter initialization. In this case we just forward | |
448 // the error to the host even if it is on the wrong thread. We | |
449 // have to do this because if we defer the call, we can't be | |
450 // sure the host will get the error before the "init done" callback | |
451 // is executed. This will be cleaned up when filter init is refactored. | |
452 if (state_ == kCreated) { | |
453 SendErrorToHost(error); | |
454 return; | |
455 } | |
456 | |
457 if (message_loop_ != MessageLoop::current()) { | 446 if (message_loop_ != MessageLoop::current()) { |
458 message_loop_->PostTask(FROM_HERE, | 447 message_loop_->PostTask(FROM_HERE, |
459 base::Bind(&CompositeFilter::SetError, this, error)); | 448 base::Bind(&CompositeFilter::SetError, this, error)); |
460 return; | 449 return; |
461 } | 450 } |
462 | 451 |
463 DCHECK_EQ(message_loop_, MessageLoop::current()); | 452 DCHECK_EQ(message_loop_, MessageLoop::current()); |
| 453 DCHECK_NE(state_, kCreated); |
464 | 454 |
465 // Drop errors recieved while stopping or stopped. | 455 // Drop errors recieved while stopping or stopped. |
466 // This shields the owner of this object from having | 456 // This shields the owner of this object from having |
467 // to deal with errors it can't do anything about. | 457 // to deal with errors it can't do anything about. |
468 if (state_ == kStopPending || state_ == kStopped) | 458 if (state_ == kStopPending || state_ == kStopped) |
469 return; | 459 return; |
470 | 460 |
471 status_ = error; | 461 status_ = error; |
472 if (CanForwardError()) | 462 if (CanForwardError()) |
473 SendErrorToHost(error); | 463 SendErrorToHost(error); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
507 | 497 |
508 void CompositeFilter::FilterHostImpl::NotifyEnded() { | 498 void CompositeFilter::FilterHostImpl::NotifyEnded() { |
509 host_->NotifyEnded(); | 499 host_->NotifyEnded(); |
510 } | 500 } |
511 | 501 |
512 void CompositeFilter::FilterHostImpl::DisableAudioRenderer() { | 502 void CompositeFilter::FilterHostImpl::DisableAudioRenderer() { |
513 host_->DisableAudioRenderer(); | 503 host_->DisableAudioRenderer(); |
514 } | 504 } |
515 | 505 |
516 } // namespace media | 506 } // namespace media |
OLD | NEW |