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

Unified Diff: content/renderer/media/audio_renderer_sink_cache.h

Issue 1942803002: Caching AudioOutputDevice instances in mixer manager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Make WebAudioSourceProvider to always return real sink info reguardless the client - to avoid behavior change. Created 4 years, 7 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
Index: content/renderer/media/audio_renderer_sink_cache.h
diff --git a/content/renderer/media/audio_renderer_sink_cache.h b/content/renderer/media/audio_renderer_sink_cache.h
new file mode 100644
index 0000000000000000000000000000000000000000..25ab762e8b29e4eaf0050cf5c214acae8820bfb8
--- /dev/null
+++ b/content/renderer/media/audio_renderer_sink_cache.h
@@ -0,0 +1,62 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_RENDERER_MEDIA_AUDIO_RENDERER_SINK_CACHE_H_
+#define CONTENT_RENDERER_MEDIA_AUDIO_RENDERER_SINK_CACHE_H_
+
+#include <string>
+
+#include "content/common/content_export.h"
+#include "media/base/output_device_info.h"
+
+namespace url {
+class Origin;
+}
+
+namespace media {
+class AudioRendererSink;
+}
+
+namespace content {
+
+// Caches AudioRendererSink instances, provides them to the clients for usage,
+// tracks their used/unused state, reuses them to obtain output device
+// information, garbage-collects unused sinks.
+// Thread safe.
+class CONTENT_EXPORT AudioRendererSinkCache {
+ public:
+ virtual ~AudioRendererSinkCache() {}
+
+ // Creates default cache, to be used by AudioRendererMixerManager.
+ static std::unique_ptr<AudioRendererSinkCache> Create();
+
+ // Returns output device information for a specified sink.
+ virtual media::OutputDeviceInfo GetSinkInfo(
+ int source_render_frame_id,
+ int session_id,
+ const std::string& device_id,
+ const url::Origin& security_origin) = 0;
+
+ // Provides a sink for usage. The sink must be returned to the cache by
+ // calling ReleaseSink(). The sink must be stopped by the user before
+ // deletion, but after releasing it from the cache.
+ virtual scoped_refptr<media::AudioRendererSink> GetSink(
+ int source_render_frame_id,
+ const std::string& device_id,
+ const url::Origin& security_origin) = 0;
+
+ // Notifies the cache that the sink is not in use any more. Must be
+ // called by the client, so that the cache can garbage-collect the sink
+ // reference.
+ virtual void ReleaseSink(const media::AudioRendererSink* sink_ptr) = 0;
+
+ protected:
+ AudioRendererSinkCache() {}
+
+ DISALLOW_COPY_AND_ASSIGN(AudioRendererSinkCache);
+};
+
+} // namespace content
+
+#endif // CONTENT_RENDERER_MEDIA_AUDIO_RENDERER_SINK_CACHE_H_

Powered by Google App Engine
This is Rietveld 408576698