| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |