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

Side by Side Diff: content/renderer/media/audio_renderer_sink_cache_impl.cc

Issue 2275343002: Stopping cached AudioOutputDevices on AudioRendererSinkCache destruction. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 3 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 <algorithm> 5 #include <algorithm>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/metrics/histogram_macros.h" 10 #include "base/metrics/histogram_macros.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 const CreateSinkCallback& create_sink_cb, 61 const CreateSinkCallback& create_sink_cb,
62 base::TimeDelta delete_timeout) 62 base::TimeDelta delete_timeout)
63 : task_runner_(std::move(task_runner)), 63 : task_runner_(std::move(task_runner)),
64 create_sink_cb_(create_sink_cb), 64 create_sink_cb_(create_sink_cb),
65 delete_timeout_(delete_timeout), 65 delete_timeout_(delete_timeout),
66 weak_ptr_factory_(this) { 66 weak_ptr_factory_(this) {
67 weak_this_ = weak_ptr_factory_.GetWeakPtr(); 67 weak_this_ = weak_ptr_factory_.GetWeakPtr();
68 } 68 }
69 69
70 AudioRendererSinkCacheImpl::~AudioRendererSinkCacheImpl() { 70 AudioRendererSinkCacheImpl::~AudioRendererSinkCacheImpl() {
71 // We just release all the cached sinks here. 71 DCHECK(task_runner_->BelongsToCurrentThread());
72 // We just release all the cached sinks here. Stop them first.
73 // We can stop all the sinks, no matter they are used or not, since everything
74 // is being destroyed anyways.
75 for (auto& entry : cache_)
76 entry.sink->Stop();
72 } 77 }
73 78
74 media::OutputDeviceInfo AudioRendererSinkCacheImpl::GetSinkInfo( 79 media::OutputDeviceInfo AudioRendererSinkCacheImpl::GetSinkInfo(
75 int source_render_frame_id, 80 int source_render_frame_id,
76 int session_id, 81 int session_id,
77 const std::string& device_id, 82 const std::string& device_id,
78 const url::Origin& security_origin) { 83 const url::Origin& security_origin) {
79 CacheEntry cache_entry = {source_render_frame_id, 84 CacheEntry cache_entry = {source_render_frame_id,
80 std::string() /* device_id */, security_origin, 85 std::string() /* device_id */, security_origin,
81 nullptr /* sink */, false /* not used */}; 86 nullptr /* sink */, false /* not used */};
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 return val.device_id == device_id && 286 return val.device_id == device_id &&
282 val.security_origin == security_origin; 287 val.security_origin == security_origin;
283 }); 288 });
284 }; 289 };
285 290
286 int AudioRendererSinkCacheImpl::GetCacheSizeForTesting() { 291 int AudioRendererSinkCacheImpl::GetCacheSizeForTesting() {
287 return cache_.size(); 292 return cache_.size();
288 } 293 }
289 294
290 } // namespace content 295 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698