Index: media/base/composite_filter.cc |
diff --git a/media/base/composite_filter.cc b/media/base/composite_filter.cc |
index 5c4b1c5c2be1fbdffb8a03dc6c62c26d692fc460..0b9e87e43a81836c3409bacf69178b16b3d170cd 100644 |
--- a/media/base/composite_filter.cc |
+++ b/media/base/composite_filter.cc |
@@ -57,6 +57,8 @@ CompositeFilter::~CompositeFilter() { |
} |
bool CompositeFilter::AddFilter(scoped_refptr<Filter> filter) { |
+ // TODO(fischman,scherkus): s/bool/void/ the return type and CHECK on failure |
+ // of the sanity-checks that return false today. |
DCHECK_EQ(message_loop_, MessageLoop::current()); |
if (!filter.get() || state_ != kCreated || !host()) |
return false; |
@@ -67,6 +69,22 @@ bool CompositeFilter::AddFilter(scoped_refptr<Filter> filter) { |
return true; |
} |
+void CompositeFilter::RemoveFilter(scoped_refptr<Filter> filter) { |
+ DCHECK_EQ(message_loop_, MessageLoop::current()); |
+ if (!filter.get() || state_ != kCreated || !host()) |
+ LOG(FATAL) << "Unknown filter, or in unexpected state."; |
+ |
+ for (FilterVector::iterator it = filters_.begin(); |
+ it != filters_.end(); ++it) { |
+ if (it->get() != filter.get()) |
+ continue; |
+ filters_.erase(it); |
+ filter->clear_host(); |
+ return; |
+ } |
+ NOTREACHED() << "Filter missing."; |
+} |
+ |
void CompositeFilter::set_host(FilterHost* host) { |
DCHECK_EQ(message_loop_, MessageLoop::current()); |
DCHECK(host); |
@@ -337,7 +355,6 @@ void CompositeFilter::SerialCallback() { |
DispatchPendingCallback(status_); |
return; |
} |
- |
if (!filters_.empty()) |
sequence_index_++; |
@@ -375,7 +392,6 @@ void CompositeFilter::ParallelCallback() { |
void CompositeFilter::OnCallSequenceDone() { |
State next_state = GetNextState(state_); |
- |
if (next_state == kInvalid) { |
// We somehow got into an unexpected state. |
ChangeState(kError); |