#include "third_party/blink/renderer/modules/media/audio/audio_renderer_sink_cache.h"
#include <memory>
#include <utility>
#include "base/location.h"
#include "base/memory/ptr_util.h"
#include "base/metrics/histogram_macros.h"
#include "base/ranges/algorithm.h"
#include "base/synchronization/lock.h"
#include "base/task/sequenced_task_runner.h"
#include "base/trace_event/trace_event.h"
#include "media/audio/audio_device_description.h"
#include "media/base/audio_renderer_sink.h"
#include "third_party/blink/public/web/modules/media/audio/audio_device_factory.h"
#include "third_party/blink/public/web/web_local_frame.h"
#include "third_party/blink/renderer/core/execution_context/execution_context_lifecycle_observer.h"
#include "third_party/blink/renderer/core/frame/local_dom_window.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/platform/scheduler/public/post_cross_thread_task.h"
#include "third_party/blink/renderer/platform/supplementable.h"
#include "third_party/blink/renderer/platform/wtf/cross_thread_functional.h"
namespace blink {
AudioRendererSinkCache* AudioRendererSinkCache::instance_ = …;
class AudioRendererSinkCache::WindowObserver final
: public GarbageCollected<AudioRendererSinkCache::WindowObserver>,
public Supplement<LocalDOMWindow>,
public ExecutionContextLifecycleObserver { … };
const char AudioRendererSinkCache::WindowObserver::kSupplementName[] = …;
namespace {
bool SinkIsHealthy(media::AudioRendererSink* sink) { … }
}
struct AudioRendererSinkCache::CacheEntry { … };
void AudioRendererSinkCache::InstallWindowObserver(LocalDOMWindow& window) { … }
AudioRendererSinkCache::AudioRendererSinkCache(
scoped_refptr<base::SequencedTaskRunner> cleanup_task_runner,
CreateSinkCallback create_sink_cb,
base::TimeDelta delete_timeout)
: … { … }
AudioRendererSinkCache::~AudioRendererSinkCache() { … }
media::OutputDeviceInfo AudioRendererSinkCache::GetSinkInfo(
const LocalFrameToken& source_frame_token,
const std::string& device_id) { … }
void AudioRendererSinkCache::DeleteLater(
scoped_refptr<media::AudioRendererSink> sink) { … }
void AudioRendererSinkCache::DeleteSink(
const media::AudioRendererSink* sink_ptr) { … }
AudioRendererSinkCache::CacheContainer::iterator
AudioRendererSinkCache::FindCacheEntry_Locked(
const LocalFrameToken& source_frame_token,
const std::string& device_id) { … }
void AudioRendererSinkCache::MaybeCacheSink(
const LocalFrameToken& source_frame_token,
const std::string& device_id,
scoped_refptr<media::AudioRendererSink> sink) { … }
void AudioRendererSinkCache::DropSinksForFrame(
const LocalFrameToken& source_frame_token) { … }
wtf_size_t AudioRendererSinkCache::GetCacheSizeForTesting() { … }
}