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

Unified Diff: media/audio/audio_output_dispatcher_impl.cc

Issue 2621993002: Makes AudioOutputProxy -> AudioOutputDispatcher reference weak. (Closed)
Patch Set: adds StopPhysicalStream 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..8630c6f7f45156a86e6f612de53afeae44891261 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,25 +27,30 @@ 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_) {
+ StopPhysicalStream(iter.second);
+ }
+
// 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());
-
// All idle physical streams must have been closed during shutdown.
CHECK(idle_streams_.empty());
}
+AudioOutputProxy* AudioOutputDispatcherImpl::CreateStreamProxy() {
+ DCHECK(task_runner_->BelongsToCurrentThread());
+ return new AudioOutputProxy(weak_factory_.GetWeakPtr());
+}
+
bool AudioOutputDispatcherImpl::OpenStream() {
DCHECK(task_runner_->BelongsToCurrentThread());
@@ -94,15 +97,9 @@ void AudioOutputDispatcherImpl::StopStream(AudioOutputProxy* stream_proxy) {
AudioStreamMap::iterator it = proxy_to_physical_map_.find(stream_proxy);
DCHECK(it != proxy_to_physical_map_.end());
- AudioOutputStream* physical_stream = it->second;
+ StopPhysicalStream(it->second);
proxy_to_physical_map_.erase(it);
-
- physical_stream->Stop();
- audio_log_->OnStopped(audio_stream_ids_[physical_stream]);
++idle_proxies_;
- idle_streams_.push_back(physical_stream);
-
- close_timer_.Reset();
}
void AudioOutputDispatcherImpl::StreamVolumeSet(AudioOutputProxy* stream_proxy,
@@ -177,4 +174,12 @@ void AudioOutputDispatcherImpl::CloseIdleStreams(size_t keep_alive) {
idle_streams_.erase(idle_streams_.begin() + keep_alive, idle_streams_.end());
}
+void AudioOutputDispatcherImpl::StopPhysicalStream(AudioOutputStream* stream) {
+ DCHECK(task_runner_->BelongsToCurrentThread());
+ stream->Stop();
+ audio_log_->OnStopped(audio_stream_ids_[stream]);
+ idle_streams_.push_back(stream);
+ close_timer_.Reset();
+}
+
} // namespace media
« 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