Chromium Code Reviews| 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/audio/audio_output_dispatcher_impl.h" | 5 #include "media/audio/audio_output_dispatcher_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 27 close_delay, | 27 close_delay, |
| 28 this, | 28 this, |
| 29 &AudioOutputDispatcherImpl::CloseAllIdleStreams), | 29 &AudioOutputDispatcherImpl::CloseAllIdleStreams), |
| 30 audio_log_( | 30 audio_log_( |
| 31 audio_manager->CreateAudioLog(AudioLogFactory::AUDIO_OUTPUT_STREAM)), | 31 audio_manager->CreateAudioLog(AudioLogFactory::AUDIO_OUTPUT_STREAM)), |
| 32 audio_stream_id_(0) {} | 32 audio_stream_id_(0) {} |
| 33 | 33 |
| 34 AudioOutputDispatcherImpl::~AudioOutputDispatcherImpl() { | 34 AudioOutputDispatcherImpl::~AudioOutputDispatcherImpl() { |
| 35 CHECK(task_runner_->BelongsToCurrentThread()); | 35 CHECK(task_runner_->BelongsToCurrentThread()); |
| 36 | 36 |
| 37 // Stop all active streams. | |
| 38 for (auto iter = proxy_to_physical_map_.begin(); | |
| 39 iter != proxy_to_physical_map_.end();) { | |
| 40 // Note: Stopping the stream will invalidate the iterator. | |
| 41 // Increment the iterator before stopping the stream. | |
| 42 AudioOutputProxy* stream_proxy = iter->first; | |
| 43 ++iter; | |
| 44 StopStream(stream_proxy); | |
|
alokp
2017/01/10 20:33:59
Do you think it is worthwhile to trigger AudioSour
DaleCurtis
2017/01/10 20:54:41
No, this should be fine. Also, just use a for each
alokp
2017/01/10 22:51:26
I cannot use the for-each style because StopStream
DaleCurtis
2017/01/10 22:59:05
Hmm, for some reason I thought for-each is immune
alokp
2017/01/10 23:31:53
AFAICT none - for_each or c++11 range-based for-lo
| |
| 45 } | |
| 46 | |
| 37 // Close all idle streams immediately. The |close_timer_| will handle | 47 // Close all idle streams immediately. The |close_timer_| will handle |
| 38 // invalidating any outstanding tasks upon its destruction. | 48 // invalidating any outstanding tasks upon its destruction. |
| 39 CloseAllIdleStreams(); | 49 CloseAllIdleStreams(); |
| 40 | 50 |
| 41 // There must be no idle proxy streams. | |
| 42 CHECK_EQ(idle_proxies_, 0u); | |
| 43 | |
| 44 // There must be no active proxy streams. | 51 // There must be no active proxy streams. |
| 45 CHECK(proxy_to_physical_map_.empty()); | 52 CHECK(proxy_to_physical_map_.empty()); |
| 46 | 53 |
| 47 // All idle physical streams must have been closed during shutdown. | 54 // All idle physical streams must have been closed during shutdown. |
| 48 CHECK(idle_streams_.empty()); | 55 CHECK(idle_streams_.empty()); |
| 49 } | 56 } |
| 50 | 57 |
| 51 bool AudioOutputDispatcherImpl::OpenStream() { | 58 bool AudioOutputDispatcherImpl::OpenStream() { |
| 52 DCHECK(task_runner_->BelongsToCurrentThread()); | 59 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 53 | 60 |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 171 | 178 |
| 172 AudioStreamIDMap::iterator it = audio_stream_ids_.find(stream); | 179 AudioStreamIDMap::iterator it = audio_stream_ids_.find(stream); |
| 173 DCHECK(it != audio_stream_ids_.end()); | 180 DCHECK(it != audio_stream_ids_.end()); |
| 174 audio_log_->OnClosed(it->second); | 181 audio_log_->OnClosed(it->second); |
| 175 audio_stream_ids_.erase(it); | 182 audio_stream_ids_.erase(it); |
| 176 } | 183 } |
| 177 idle_streams_.erase(idle_streams_.begin() + keep_alive, idle_streams_.end()); | 184 idle_streams_.erase(idle_streams_.begin() + keep_alive, idle_streams_.end()); |
| 178 } | 185 } |
| 179 | 186 |
| 180 } // namespace media | 187 } // namespace media |
| OLD | NEW |