Commit 55e0406b authored by Antonio Gomes's avatar Antonio Gomes Committed by Commit Bot

Onion Soup AudioRendererSinkCache

This CL moves audio_renderer_sink_cache.h temporarily to
third_party/blink/public/web/modules/media/.

The declaration of its ObserveFrame() static method is also
temporarily moved to audio_renderer_sink_cache_impl.h.

This step corresponds to phase 2.2 in the design doc [1].

[1] https://docs.google.com/document/d/19Zk6Fv1E-6QTQ2c33rpBjDNEkzlsSKvjb3hWkvZAE80/

BUG=787252
R=guidou@chromium.org, haraken@chromium.org

Change-Id: I0757c99a4c30e792ca61c9d1c8a3f8acc01aea26
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2412133
Auto-Submit: Antonio Gomes (GMT-4) <tonikitoo@igalia.com>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarGuido Urdaneta <guidou@chromium.org>
Commit-Queue: Kentaro Hara <haraken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#807301}
parent 938b217a
...@@ -22,10 +22,10 @@ target(link_target_type, "renderer") { ...@@ -22,10 +22,10 @@ target(link_target_type, "renderer") {
# internal content ones) should depend on the public one. # internal content ones) should depend on the public one.
visibility = [ visibility = [
":for_content_tests", ":for_content_tests",
"//chromecast/media/audio:*",
"//content/app:*", "//content/app:*",
"//content/public/renderer:renderer_sources", "//content/public/renderer:renderer_sources",
"//content/renderer:audio_decoder_fuzzer", "//content/renderer:audio_decoder_fuzzer",
"//chromecast/media/audio:*",
] ]
sources = [ sources = [
...@@ -137,7 +137,6 @@ target(link_target_type, "renderer") { ...@@ -137,7 +137,6 @@ target(link_target_type, "renderer") {
"media/audio/audio_device_factory.h", "media/audio/audio_device_factory.h",
"media/audio/audio_renderer_mixer_manager.cc", "media/audio/audio_renderer_mixer_manager.cc",
"media/audio/audio_renderer_mixer_manager.h", "media/audio/audio_renderer_mixer_manager.h",
"media/audio/audio_renderer_sink_cache.h",
"media/audio/audio_renderer_sink_cache_impl.cc", "media/audio/audio_renderer_sink_cache_impl.cc",
"media/audio/audio_renderer_sink_cache_impl.h", "media/audio/audio_renderer_sink_cache_impl.h",
"media/audio_decoder.cc", "media/audio_decoder.cc",
......
...@@ -90,7 +90,7 @@ struct AudioRendererSinkCacheImpl::CacheEntry { ...@@ -90,7 +90,7 @@ struct AudioRendererSinkCacheImpl::CacheEntry {
}; };
// static // static
void AudioRendererSinkCache::ObserveFrame(RenderFrame* frame) { void AudioRendererSinkCacheImpl::ObserveFrame(RenderFrame* frame) {
new AudioRendererSinkCacheImpl::FrameObserver(frame); new AudioRendererSinkCacheImpl::FrameObserver(frame);
} }
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#ifndef CONTENT_RENDERER_MEDIA_AUDIO_AUDIO_RENDERER_SINK_CACHE_IMPL_H_ #ifndef CONTENT_RENDERER_MEDIA_AUDIO_AUDIO_RENDERER_SINK_CACHE_IMPL_H_
#define CONTENT_RENDERER_MEDIA_AUDIO_AUDIO_RENDERER_SINK_CACHE_IMPL_H_ #define CONTENT_RENDERER_MEDIA_AUDIO_AUDIO_RENDERER_SINK_CACHE_IMPL_H_
#include "content/renderer/media/audio/audio_renderer_sink_cache.h" #include "third_party/blink/public/web/modules/media/audio/audio_renderer_sink_cache.h"
#include <string> #include <string>
#include <vector> #include <vector>
...@@ -20,9 +20,11 @@ ...@@ -20,9 +20,11 @@
namespace content { namespace content {
class RenderFrame;
// AudioRendererSinkCache implementation. // AudioRendererSinkCache implementation.
class CONTENT_EXPORT AudioRendererSinkCacheImpl class CONTENT_EXPORT AudioRendererSinkCacheImpl
: public AudioRendererSinkCache { : public blink::AudioRendererSinkCache {
public: public:
class FrameObserver; class FrameObserver;
...@@ -32,6 +34,14 @@ class CONTENT_EXPORT AudioRendererSinkCacheImpl ...@@ -32,6 +34,14 @@ class CONTENT_EXPORT AudioRendererSinkCacheImpl
const blink::LocalFrameToken& frame_token, const blink::LocalFrameToken& frame_token,
const media::AudioSinkParameters& params)>; const media::AudioSinkParameters& params)>;
// If called, the cache will drop sinks belonging to the specified frame on
// navigation.
//
// TODO(https://crbug.com/787252): Move the declaration back to
// AudioRendererSinkCache when this header moves to
// blink/renderer/modules/media/audio.
static void ObserveFrame(RenderFrame* frame);
// |cleanup_task_runner| will be used to delete sinks when they are unused, // |cleanup_task_runner| will be used to delete sinks when they are unused,
// AudioRendererSinkCacheImpl must outlive any tasks posted to it. Since // AudioRendererSinkCacheImpl must outlive any tasks posted to it. Since
// the sink cache is normally a process-wide singleton, this isn't a problem. // the sink cache is normally a process-wide singleton, this isn't a problem.
...@@ -42,7 +52,7 @@ class CONTENT_EXPORT AudioRendererSinkCacheImpl ...@@ -42,7 +52,7 @@ class CONTENT_EXPORT AudioRendererSinkCacheImpl
~AudioRendererSinkCacheImpl() final; ~AudioRendererSinkCacheImpl() final;
// AudioSinkCache implementation: // AudioRendererSinkCache implementation:
media::OutputDeviceInfo GetSinkInfo( media::OutputDeviceInfo GetSinkInfo(
const blink::LocalFrameToken& source_frame_token, const blink::LocalFrameToken& source_frame_token,
const base::UnguessableToken& session_id, const base::UnguessableToken& session_id,
......
...@@ -372,7 +372,7 @@ TEST_F(AudioRendererSinkCacheTest, MultithreadedAccess) { ...@@ -372,7 +372,7 @@ TEST_F(AudioRendererSinkCacheTest, MultithreadedAccess) {
// Release the sink on the second thread. // Release the sink on the second thread.
PostAndWaitUntilDone( PostAndWaitUntilDone(
thread2, thread2,
base::BindOnce(&AudioRendererSinkCache::ReleaseSink, base::BindOnce(&blink::AudioRendererSinkCache::ReleaseSink,
base::Unretained(cache_.get()), base::RetainedRef(sink))); base::Unretained(cache_.get()), base::RetainedRef(sink)));
EXPECT_EQ(0, sink_count()); EXPECT_EQ(0, sink_count());
......
...@@ -109,7 +109,7 @@ ...@@ -109,7 +109,7 @@
#include "content/renderer/loader/web_url_request_util.h" #include "content/renderer/loader/web_url_request_util.h"
#include "content/renderer/loader/web_worker_fetch_context_impl.h" #include "content/renderer/loader/web_worker_fetch_context_impl.h"
#include "content/renderer/media/audio/audio_device_factory.h" #include "content/renderer/media/audio/audio_device_factory.h"
#include "content/renderer/media/audio/audio_renderer_sink_cache.h" #include "content/renderer/media/audio/audio_renderer_sink_cache_impl.h"
#include "content/renderer/media/media_permission_dispatcher.h" #include "content/renderer/media/media_permission_dispatcher.h"
#include "content/renderer/mhtml_handle_writer.h" #include "content/renderer/mhtml_handle_writer.h"
#include "content/renderer/mojo/blink_interface_registry_impl.h" #include "content/renderer/mojo/blink_interface_registry_impl.h"
...@@ -2051,7 +2051,7 @@ void RenderFrameImpl::Initialize(blink::WebFrame* parent) { ...@@ -2051,7 +2051,7 @@ void RenderFrameImpl::Initialize(blink::WebFrame* parent) {
GetBrowserInterfaceBroker()); GetBrowserInterfaceBroker());
} }
AudioRendererSinkCache::ObserveFrame(this); AudioRendererSinkCacheImpl::ObserveFrame(this);
const base::CommandLine& command_line = const base::CommandLine& command_line =
*base::CommandLine::ForCurrentProcess(); *base::CommandLine::ForCurrentProcess();
......
...@@ -278,6 +278,7 @@ source_set("blink_headers") { ...@@ -278,6 +278,7 @@ source_set("blink_headers") {
"platform/websocket_handshake_throttle.h", "platform/websocket_handshake_throttle.h",
"web/blink.h", "web/blink.h",
"web/modules/autofill/web_form_element_observer.h", "web/modules/autofill/web_form_element_observer.h",
"web/modules/media/audio/audio_renderer_sink_cache.h",
"web/modules/media/audio/web_audio_input_ipc_factory.h", "web/modules/media/audio/web_audio_input_ipc_factory.h",
"web/modules/media/audio/web_audio_output_ipc_factory.h", "web/modules/media/audio/web_audio_output_ipc_factory.h",
"web/modules/media/webmediaplayer_util.h", "web/modules/media/webmediaplayer_util.h",
......
...@@ -2,40 +2,38 @@ ...@@ -2,40 +2,38 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef CONTENT_RENDERER_MEDIA_AUDIO_AUDIO_RENDERER_SINK_CACHE_H_ #ifndef THIRD_PARTY_BLINK_PUBLIC_WEB_MODULES_MEDIA_AUDIO_AUDIO_RENDERER_SINK_CACHE_H_
#define CONTENT_RENDERER_MEDIA_AUDIO_AUDIO_RENDERER_SINK_CACHE_H_ #define THIRD_PARTY_BLINK_PUBLIC_WEB_MODULES_MEDIA_AUDIO_AUDIO_RENDERER_SINK_CACHE_H_
#include <memory> #include <memory>
#include <string> #include <string>
#include "base/memory/scoped_refptr.h" #include "base/memory/scoped_refptr.h"
#include "base/unguessable_token.h" #include "base/unguessable_token.h"
#include "content/common/content_export.h"
#include "media/base/output_device_info.h" #include "media/base/output_device_info.h"
#include "third_party/blink/public/common/tokens/tokens.h" #include "third_party/blink/public/common/tokens/tokens.h"
#include "third_party/blink/public/platform/web_common.h"
namespace media { namespace media {
class AudioRendererSink; class AudioRendererSink;
} }
namespace content { namespace blink {
class RenderFrame;
// Caches AudioRendererSink instances, provides them to the clients for usage, // Caches AudioRendererSink instances, provides them to the clients for usage,
// tracks their used/unused state, reuses them to obtain output device // tracks their used/unused state, reuses them to obtain output device
// information, garbage-collects unused sinks. // information, garbage-collects unused sinks.
// Must live on the main render thread. Thread safe. // Must live on the main render thread. Thread safe.
class CONTENT_EXPORT AudioRendererSinkCache { //
// TODO(https://crrev.com/787252): Move this header out of the Blink public API
// layer.
class BLINK_MODULES_EXPORT AudioRendererSinkCache {
public: public:
virtual ~AudioRendererSinkCache() {} virtual ~AudioRendererSinkCache() {}
// If called, the cache will drop sinks belonging to the specified frame on
// navigation.
static void ObserveFrame(RenderFrame* frame);
// Returns output device information for a specified sink. // Returns output device information for a specified sink.
virtual media::OutputDeviceInfo GetSinkInfo( virtual media::OutputDeviceInfo GetSinkInfo(
const blink::LocalFrameToken& source_frame_token, const LocalFrameToken& source_frame_token,
const base::UnguessableToken& session_id, const base::UnguessableToken& session_id,
const std::string& device_id) = 0; const std::string& device_id) = 0;
...@@ -43,7 +41,7 @@ class CONTENT_EXPORT AudioRendererSinkCache { ...@@ -43,7 +41,7 @@ class CONTENT_EXPORT AudioRendererSinkCache {
// calling ReleaseSink(). The sink must be stopped by the user before // calling ReleaseSink(). The sink must be stopped by the user before
// deletion, but after releasing it from the cache. // deletion, but after releasing it from the cache.
virtual scoped_refptr<media::AudioRendererSink> GetSink( virtual scoped_refptr<media::AudioRendererSink> GetSink(
const blink::LocalFrameToken& source_frame_token, const LocalFrameToken& source_frame_token,
const std::string& device_id) = 0; const std::string& device_id) = 0;
// Notifies the cache that the sink is not in use any more. Must be // Notifies the cache that the sink is not in use any more. Must be
...@@ -58,6 +56,6 @@ class CONTENT_EXPORT AudioRendererSinkCache { ...@@ -58,6 +56,6 @@ class CONTENT_EXPORT AudioRendererSinkCache {
DISALLOW_COPY_AND_ASSIGN(AudioRendererSinkCache); DISALLOW_COPY_AND_ASSIGN(AudioRendererSinkCache);
}; };
} // namespace content } // namespace blink
#endif // CONTENT_RENDERER_MEDIA_AUDIO_AUDIO_RENDERER_SINK_CACHE_H_ #endif // THIRD_PARTY_BLINK_PUBLIC_WEB_MODULES_MEDIA_AUDIO_AUDIO_RENDERER_SINK_CACHE_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment