Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(173)

Unified Diff: media/audio/audio_output_dispatcher_impl.cc

Issue 2621993002: Makes AudioOutputProxy -> AudioOutputDispatcher reference weak. (Closed)
Patch Set: adds CreateStreamProxy Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/audio/audio_output_dispatcher_impl.h ('k') | media/audio/audio_output_proxy.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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());
« no previous file with comments | « media/audio/audio_output_dispatcher_impl.h ('k') | media/audio/audio_output_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698