Chromium Code Reviews| Index: media/audio/audio_output_dispatcher_impl.cc |
| diff --git a/media/audio/audio_output_dispatcher_impl.cc b/media/audio/audio_output_dispatcher_impl.cc |
| index b538acde82cdb67b8a9117f0ba4b530091a2ddcc..f2b6c58a6ff48c45c6a4f412967eb739d6f856c8 100644 |
| --- a/media/audio/audio_output_dispatcher_impl.cc |
| +++ b/media/audio/audio_output_dispatcher_impl.cc |
| @@ -19,9 +19,7 @@ AudioOutputDispatcherImpl::AudioOutputDispatcherImpl( |
| const AudioParameters& params, |
| const std::string& output_device_id, |
| const base::TimeDelta& close_delay) |
| - : AudioOutputDispatcher(audio_manager, |
| - params, |
| - output_device_id), |
| + : AudioOutputDispatcher(audio_manager, params, output_device_id), |
| idle_proxies_(0), |
| close_timer_(FROM_HERE, |
| close_delay, |
| @@ -29,18 +27,26 @@ AudioOutputDispatcherImpl::AudioOutputDispatcherImpl( |
| &AudioOutputDispatcherImpl::CloseAllIdleStreams), |
| audio_log_( |
| audio_manager->CreateAudioLog(AudioLogFactory::AUDIO_OUTPUT_STREAM)), |
| - audio_stream_id_(0) {} |
| + audio_stream_id_(0), |
| + weak_factory_(this) {} |
| AudioOutputDispatcherImpl::~AudioOutputDispatcherImpl() { |
| CHECK(task_runner_->BelongsToCurrentThread()); |
| + // Stop all active streams. |
| + for (auto iter = proxy_to_physical_map_.begin(); |
| + iter != proxy_to_physical_map_.end();) { |
| + // Note: Stopping the stream will invalidate the iterator. |
| + // Increment the iterator before stopping the stream. |
| + AudioOutputProxy* stream_proxy = iter->first; |
| + ++iter; |
| + StopStream(stream_proxy); |
|
DaleCurtis
2017/01/10 23:46:34
Note this call does a search over the proxy map, s
alokp
2017/01/11 00:12:50
Done.
|
| + } |
| + |
| // Close all idle streams immediately. The |close_timer_| will handle |
| // invalidating any outstanding tasks upon its destruction. |
| CloseAllIdleStreams(); |
| - // There must be no idle proxy streams. |
| - CHECK_EQ(idle_proxies_, 0u); |
| - |
| // There must be no active proxy streams. |
| CHECK(proxy_to_physical_map_.empty()); |
| @@ -48,6 +54,11 @@ AudioOutputDispatcherImpl::~AudioOutputDispatcherImpl() { |
| CHECK(idle_streams_.empty()); |
| } |
| +AudioOutputProxy* AudioOutputDispatcherImpl::CreateStreamProxy() { |
| + DCHECK(task_runner_->BelongsToCurrentThread()); |
| + return new AudioOutputProxy(weak_factory_.GetWeakPtr()); |
| +} |
| + |
| bool AudioOutputDispatcherImpl::OpenStream() { |
| DCHECK(task_runner_->BelongsToCurrentThread()); |