Commit 4e4b503b authored by Miyoung Shin's avatar Miyoung Shin Committed by Commit Bot

Convert AudioLog to new Mojo types

This CL converts AudioLog{Ptr, Request} in content and services to
the new Mojo type, and usese pending_receiver<AudioLog> in
audio_logging.mojom.

Bug: 955171
Change-Id: I34ac38228c93723dc258f87c36aa2938d4d7bc1b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1872090
Commit-Queue: Miyoung Shin <myid.shin@igalia.com>
Reviewed-by: default avatarKen Rockot <rockot@google.com>
Reviewed-by: default avatarSam McNally <sammc@chromium.org>
Reviewed-by: default avatarOlga Sharonova <olka@chromium.org>
Cr-Commit-Position: refs/heads/master@{#709010}
parent d6485b57
...@@ -169,11 +169,9 @@ void AudioInputStreamBroker::CreateStream( ...@@ -169,11 +169,9 @@ void AudioInputStreamBroker::CreateStream(
constexpr int log_component_id = 0; constexpr int log_component_id = 0;
factory->CreateInputStream( factory->CreateInputStream(
std::move(stream_receiver), std::move(client), std::move(observer), std::move(stream_receiver), std::move(client), std::move(observer),
MediaInternals::GetInstance() MediaInternals::GetInstance()->CreateMojoAudioLog(
->CreateMojoAudioLog( media::AudioLogFactory::AudioComponent::AUDIO_INPUT_CONTROLLER,
media::AudioLogFactory::AudioComponent::AUDIO_INPUT_CONTROLLER, log_component_id, render_process_id(), render_frame_id()),
log_component_id, render_process_id(), render_frame_id())
.PassInterface(),
device_id_, params_, shared_memory_count_, enable_agc_, device_id_, params_, shared_memory_count_, enable_agc_,
mojo::WrapReadOnlySharedMemoryRegion(std::move(key_press_count_buffer)), mojo::WrapReadOnlySharedMemoryRegion(std::move(key_press_count_buffer)),
std::move(processing_config_), std::move(processing_config_),
......
...@@ -94,7 +94,7 @@ class MockStreamFactory : public audio::FakeStreamFactory { ...@@ -94,7 +94,7 @@ class MockStreamFactory : public audio::FakeStreamFactory {
mojo::PendingReceiver<media::mojom::AudioInputStream> stream_receiver; mojo::PendingReceiver<media::mojom::AudioInputStream> stream_receiver;
media::mojom::AudioInputStreamClientPtr client; media::mojom::AudioInputStreamClientPtr client;
media::mojom::AudioInputStreamObserverPtr observer; media::mojom::AudioInputStreamObserverPtr observer;
media::mojom::AudioLogPtr log; mojo::Remote<media::mojom::AudioLog> log;
const std::string device_id; const std::string device_id;
const media::AudioParameters params; const media::AudioParameters params;
uint32_t shared_memory_count; uint32_t shared_memory_count;
......
...@@ -16,10 +16,10 @@ AudioLogFactory::~AudioLogFactory() = default; ...@@ -16,10 +16,10 @@ AudioLogFactory::~AudioLogFactory() = default;
void AudioLogFactory::CreateAudioLog( void AudioLogFactory::CreateAudioLog(
media::mojom::AudioLogComponent component, media::mojom::AudioLogComponent component,
int32_t component_id, int32_t component_id,
media::mojom::AudioLogRequest audio_log_request) { mojo::PendingReceiver<media::mojom::AudioLog> audio_log_receiver) {
MediaInternals::GetInstance()->CreateMojoAudioLog( MediaInternals::GetInstance()->CreateMojoAudioLog(
static_cast<media::AudioLogFactory::AudioComponent>(component), static_cast<media::AudioLogFactory::AudioComponent>(component),
component_id, std::move(audio_log_request)); component_id, std::move(audio_log_receiver));
} }
} // namespace content } // namespace content
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#define CONTENT_BROWSER_MEDIA_AUDIO_LOG_FACTORY_H_ #define CONTENT_BROWSER_MEDIA_AUDIO_LOG_FACTORY_H_
#include "media/mojo/mojom/audio_logging.mojom.h" #include "media/mojo/mojom/audio_logging.mojom.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
namespace content { namespace content {
...@@ -17,7 +18,8 @@ class AudioLogFactory : public media::mojom::AudioLogFactory { ...@@ -17,7 +18,8 @@ class AudioLogFactory : public media::mojom::AudioLogFactory {
// media::mojom::AudioLogFactory implementation. // media::mojom::AudioLogFactory implementation.
void CreateAudioLog(media::mojom::AudioLogComponent component, void CreateAudioLog(media::mojom::AudioLogComponent component,
int32_t component_id, int32_t component_id,
media::mojom::AudioLogRequest audio_log_request) override; mojo::PendingReceiver<media::mojom::AudioLog>
audio_log_receiver) override;
private: private:
DISALLOW_COPY_AND_ASSIGN(AudioLogFactory); DISALLOW_COPY_AND_ASSIGN(AudioLogFactory);
......
...@@ -147,11 +147,9 @@ void AudioOutputStreamBroker::CreateStream( ...@@ -147,11 +147,9 @@ void AudioOutputStreamBroker::CreateStream(
constexpr int log_component_id = 0; constexpr int log_component_id = 0;
factory->CreateOutputStream( factory->CreateOutputStream(
std::move(stream_receiver), std::move(observer), std::move(stream_receiver), std::move(observer),
MediaInternals::GetInstance() MediaInternals::GetInstance()->CreateMojoAudioLog(
->CreateMojoAudioLog( media::AudioLogFactory::AudioComponent::AUDIO_OUTPUT_CONTROLLER,
media::AudioLogFactory::AudioComponent::AUDIO_OUTPUT_CONTROLLER, log_component_id, render_process_id(), render_frame_id()),
log_component_id, render_process_id(), render_frame_id())
.PassInterface(),
output_device_id_, params_, group_id_, processing_id_, output_device_id_, params_, group_id_, processing_id_,
base::BindOnce(&AudioOutputStreamBroker::StreamCreated, base::BindOnce(&AudioOutputStreamBroker::StreamCreated,
weak_ptr_factory_.GetWeakPtr(), std::move(stream))); weak_ptr_factory_.GetWeakPtr(), std::move(stream)));
......
...@@ -101,7 +101,7 @@ class MockStreamFactory : public audio::FakeStreamFactory { ...@@ -101,7 +101,7 @@ class MockStreamFactory : public audio::FakeStreamFactory {
bool requested = false; bool requested = false;
mojo::PendingReceiver<media::mojom::AudioOutputStream> stream_receiver; mojo::PendingReceiver<media::mojom::AudioOutputStream> stream_receiver;
media::mojom::AudioOutputStreamObserverAssociatedPtrInfo observer_info; media::mojom::AudioOutputStreamObserverAssociatedPtrInfo observer_info;
media::mojom::AudioLogPtr log; mojo::Remote<media::mojom::AudioLog> log;
const std::string output_device_id; const std::string output_device_id;
const media::AudioParameters params; const media::AudioParameters params;
const base::UnguessableToken group_id; const base::UnguessableToken group_id;
......
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
#include "media/base/audio_parameters.h" #include "media/base/audio_parameters.h"
#include "media/base/media_log_event.h" #include "media/base/media_log_event.h"
#include "media/webrtc/webrtc_switches.h" #include "media/webrtc/webrtc_switches.h"
#include "mojo/public/cpp/bindings/strong_binding.h" #include "mojo/public/cpp/bindings/self_owned_receiver.h"
#include "services/service_manager/sandbox/features.h" #include "services/service_manager/sandbox/features.h"
#include "services/service_manager/sandbox/sandbox_type.h" #include "services/service_manager/sandbox/sandbox_type.h"
...@@ -529,27 +529,28 @@ std::unique_ptr<media::AudioLog> MediaInternals::CreateAudioLog( ...@@ -529,27 +529,28 @@ std::unique_ptr<media::AudioLog> MediaInternals::CreateAudioLog(
return CreateAudioLogImpl(component, component_id, -1, MSG_ROUTING_NONE); return CreateAudioLogImpl(component, component_id, -1, MSG_ROUTING_NONE);
} }
media::mojom::AudioLogPtr MediaInternals::CreateMojoAudioLog( mojo::PendingRemote<media::mojom::AudioLog> MediaInternals::CreateMojoAudioLog(
media::AudioLogFactory::AudioComponent component, media::AudioLogFactory::AudioComponent component,
int component_id, int component_id,
int render_process_id, int render_process_id,
int render_frame_id) { int render_frame_id) {
media::mojom::AudioLogPtr audio_log_ptr; mojo::PendingRemote<media::mojom::AudioLog> audio_log;
CreateMojoAudioLog(component, component_id, mojo::MakeRequest(&audio_log_ptr), CreateMojoAudioLog(component, component_id,
audio_log.InitWithNewPipeAndPassReceiver(),
render_process_id, render_frame_id); render_process_id, render_frame_id);
return audio_log_ptr; return audio_log;
} }
void MediaInternals::CreateMojoAudioLog( void MediaInternals::CreateMojoAudioLog(
media::AudioLogFactory::AudioComponent component, media::AudioLogFactory::AudioComponent component,
int component_id, int component_id,
media::mojom::AudioLogRequest request, mojo::PendingReceiver<media::mojom::AudioLog> receiver,
int render_process_id, int render_process_id,
int render_frame_id) { int render_frame_id) {
mojo::MakeStrongBinding( mojo::MakeSelfOwnedReceiver(
CreateAudioLogImpl(component, component_id, render_process_id, CreateAudioLogImpl(component, component_id, render_process_id,
render_frame_id), render_frame_id),
std::move(request)); std::move(receiver));
} }
std::unique_ptr<MediaInternals::AudioLogImpl> std::unique_ptr<MediaInternals::AudioLogImpl>
......
...@@ -27,6 +27,8 @@ ...@@ -27,6 +27,8 @@
#include "media/capture/video/video_capture_device_descriptor.h" #include "media/capture/video/video_capture_device_descriptor.h"
#include "media/capture/video_capture_types.h" #include "media/capture/video_capture_types.h"
#include "media/mojo/mojom/audio_logging.mojom.h" #include "media/mojo/mojom/audio_logging.mojom.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
namespace media { namespace media {
struct MediaLogEvent; struct MediaLogEvent;
...@@ -97,21 +99,22 @@ class CONTENT_EXPORT MediaInternals : public media::AudioLogFactory, ...@@ -97,21 +99,22 @@ class CONTENT_EXPORT MediaInternals : public media::AudioLogFactory,
std::unique_ptr<media::AudioLog> CreateAudioLog(AudioComponent component, std::unique_ptr<media::AudioLog> CreateAudioLog(AudioComponent component,
int component_id) override; int component_id) override;
// Creates a media::mojom::AudioLogPtr strongly bound to a new // Creates a PendingRemote<media::mojom::AudioLog> strongly bound to a new
// media::mojom::AudioLog instance. Safe to call from any thread. // media::mojom::AudioLog instance. Safe to call from any thread.
media::mojom::AudioLogPtr CreateMojoAudioLog( mojo::PendingRemote<media::mojom::AudioLog> CreateMojoAudioLog(
AudioComponent component, AudioComponent component,
int component_id, int component_id,
int render_process_id = -1, int render_process_id = -1,
int render_frame_id = MSG_ROUTING_NONE); int render_frame_id = MSG_ROUTING_NONE);
// Strongly bounds |request| to a new media::mojom::AudioLog instance. Safe to // Strongly bounds |receiver| to a new media::mojom::AudioLog instance. Safe
// call from any thread. // to call from any thread.
void CreateMojoAudioLog(AudioComponent component, void CreateMojoAudioLog(
int component_id, AudioComponent component,
media::mojom::AudioLogRequest request, int component_id,
int render_process_id = -1, mojo::PendingReceiver<media::mojom::AudioLog> receiver,
int render_frame_id = MSG_ROUTING_NONE); int render_process_id = -1,
int render_frame_id = MSG_ROUTING_NONE);
private: private:
// Needs access to SendUpdate. // Needs access to SendUpdate.
......
...@@ -109,7 +109,7 @@ std::unique_ptr<media::AudioInputDelegate> AudioInputDelegateImpl::Create( ...@@ -109,7 +109,7 @@ std::unique_ptr<media::AudioInputDelegate> AudioInputDelegateImpl::Create(
int render_process_id, int render_process_id,
int render_frame_id, int render_frame_id,
AudioInputDeviceManager* audio_input_device_manager, AudioInputDeviceManager* audio_input_device_manager,
media::mojom::AudioLogPtr audio_log, mojo::PendingRemote<media::mojom::AudioLog> audio_log,
AudioInputDeviceManager::KeyboardMicRegistration keyboard_mic_registration, AudioInputDeviceManager::KeyboardMicRegistration keyboard_mic_registration,
uint32_t shared_memory_count, uint32_t shared_memory_count,
int stream_id, int stream_id,
...@@ -165,7 +165,7 @@ AudioInputDelegateImpl::AudioInputDelegateImpl( ...@@ -165,7 +165,7 @@ AudioInputDelegateImpl::AudioInputDelegateImpl(
media::UserInputMonitor* user_input_monitor, media::UserInputMonitor* user_input_monitor,
const media::AudioParameters& audio_parameters, const media::AudioParameters& audio_parameters,
int render_process_id, int render_process_id,
media::mojom::AudioLogPtr audio_log, mojo::PendingRemote<media::mojom::AudioLog> audio_log,
AudioInputDeviceManager::KeyboardMicRegistration keyboard_mic_registration, AudioInputDeviceManager::KeyboardMicRegistration keyboard_mic_registration,
int stream_id, int stream_id,
bool automatic_gain_control, bool automatic_gain_control,
......
...@@ -14,6 +14,8 @@ ...@@ -14,6 +14,8 @@
#include "content/common/content_export.h" #include "content/common/content_export.h"
#include "media/audio/audio_input_delegate.h" #include "media/audio/audio_input_delegate.h"
#include "media/mojo/mojom/audio_logging.mojom.h" #include "media/mojo/mojom/audio_logging.mojom.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/remote.h"
namespace media { namespace media {
class AudioManager; class AudioManager;
...@@ -46,7 +48,7 @@ class CONTENT_EXPORT AudioInputDelegateImpl : public media::AudioInputDelegate { ...@@ -46,7 +48,7 @@ class CONTENT_EXPORT AudioInputDelegateImpl : public media::AudioInputDelegate {
int render_process_id, int render_process_id,
int render_frame_id, int render_frame_id,
AudioInputDeviceManager* audio_input_device_manager, AudioInputDeviceManager* audio_input_device_manager,
media::mojom::AudioLogPtr audio_log, mojo::PendingRemote<media::mojom::AudioLog> audio_log,
AudioInputDeviceManager::KeyboardMicRegistration AudioInputDeviceManager::KeyboardMicRegistration
keyboard_mic_registration, keyboard_mic_registration,
uint32_t shared_memory_count, uint32_t shared_memory_count,
...@@ -70,7 +72,7 @@ class CONTENT_EXPORT AudioInputDelegateImpl : public media::AudioInputDelegate { ...@@ -70,7 +72,7 @@ class CONTENT_EXPORT AudioInputDelegateImpl : public media::AudioInputDelegate {
media::UserInputMonitor* user_input_monitor, media::UserInputMonitor* user_input_monitor,
const media::AudioParameters& audio_parameters, const media::AudioParameters& audio_parameters,
int render_process_id, int render_process_id,
media::mojom::AudioLogPtr audio_log, mojo::PendingRemote<media::mojom::AudioLog> audio_log,
AudioInputDeviceManager::KeyboardMicRegistration AudioInputDeviceManager::KeyboardMicRegistration
keyboard_mic_registration, keyboard_mic_registration,
int stream_id, int stream_id,
...@@ -95,7 +97,7 @@ class CONTENT_EXPORT AudioInputDelegateImpl : public media::AudioInputDelegate { ...@@ -95,7 +97,7 @@ class CONTENT_EXPORT AudioInputDelegateImpl : public media::AudioInputDelegate {
std::unique_ptr<ControllerEventHandler> controller_event_handler_; std::unique_ptr<ControllerEventHandler> controller_event_handler_;
std::unique_ptr<media::AudioInputSyncWriter> writer_; std::unique_ptr<media::AudioInputSyncWriter> writer_;
std::unique_ptr<base::CancelableSyncSocket> foreign_socket_; std::unique_ptr<base::CancelableSyncSocket> foreign_socket_;
media::mojom::AudioLogPtr const audio_log_; mojo::Remote<media::mojom::AudioLog> const audio_log_;
scoped_refptr<media::AudioInputController> controller_; scoped_refptr<media::AudioInputController> controller_;
const AudioInputDeviceManager::KeyboardMicRegistration const AudioInputDeviceManager::KeyboardMicRegistration
keyboard_mic_registration_; keyboard_mic_registration_;
......
...@@ -97,7 +97,7 @@ void AudioOutputDelegateImpl::ControllerEventHandler::OnLog( ...@@ -97,7 +97,7 @@ void AudioOutputDelegateImpl::ControllerEventHandler::OnLog(
std::unique_ptr<media::AudioOutputDelegate> AudioOutputDelegateImpl::Create( std::unique_ptr<media::AudioOutputDelegate> AudioOutputDelegateImpl::Create(
EventHandler* handler, EventHandler* handler,
media::AudioManager* audio_manager, media::AudioManager* audio_manager,
media::mojom::AudioLogPtr audio_log, mojo::PendingRemote<media::mojom::AudioLog> audio_log,
MediaObserver* media_observer, MediaObserver* media_observer,
int stream_id, int stream_id,
int render_frame_id, int render_frame_id,
...@@ -124,7 +124,7 @@ AudioOutputDelegateImpl::AudioOutputDelegateImpl( ...@@ -124,7 +124,7 @@ AudioOutputDelegateImpl::AudioOutputDelegateImpl(
std::unique_ptr<base::CancelableSyncSocket> foreign_socket, std::unique_ptr<base::CancelableSyncSocket> foreign_socket,
EventHandler* handler, EventHandler* handler,
media::AudioManager* audio_manager, media::AudioManager* audio_manager,
media::mojom::AudioLogPtr audio_log, mojo::PendingRemote<media::mojom::AudioLog> audio_log,
MediaObserver* media_observer, MediaObserver* media_observer,
int stream_id, int stream_id,
int render_frame_id, int render_frame_id,
......
...@@ -39,7 +39,7 @@ class CONTENT_EXPORT AudioOutputDelegateImpl ...@@ -39,7 +39,7 @@ class CONTENT_EXPORT AudioOutputDelegateImpl
static std::unique_ptr<AudioOutputDelegate> Create( static std::unique_ptr<AudioOutputDelegate> Create(
EventHandler* handler, EventHandler* handler,
media::AudioManager* audio_manager, media::AudioManager* audio_manager,
media::mojom::AudioLogPtr audio_log, mojo::PendingRemote<media::mojom::AudioLog> audio_log,
MediaObserver* media_observer, MediaObserver* media_observer,
int stream_id, int stream_id,
int render_frame_id, int render_frame_id,
...@@ -54,7 +54,7 @@ class CONTENT_EXPORT AudioOutputDelegateImpl ...@@ -54,7 +54,7 @@ class CONTENT_EXPORT AudioOutputDelegateImpl
std::unique_ptr<base::CancelableSyncSocket> foreign_socket, std::unique_ptr<base::CancelableSyncSocket> foreign_socket,
EventHandler* handler, EventHandler* handler,
media::AudioManager* audio_manager, media::AudioManager* audio_manager,
media::mojom::AudioLogPtr audio_log, mojo::PendingRemote<media::mojom::AudioLog> audio_log,
MediaObserver* media_observer, MediaObserver* media_observer,
int stream_id, int stream_id,
int render_frame_id, int render_frame_id,
...@@ -86,7 +86,7 @@ class CONTENT_EXPORT AudioOutputDelegateImpl ...@@ -86,7 +86,7 @@ class CONTENT_EXPORT AudioOutputDelegateImpl
// This is the event handler which |this| send notifications to. // This is the event handler which |this| send notifications to.
EventHandler* subscriber_; EventHandler* subscriber_;
const media::mojom::AudioLogPtr audio_log_; const mojo::Remote<media::mojom::AudioLog> audio_log_;
// |controller_event_handler_| proxies events from controller to |this|. // |controller_event_handler_| proxies events from controller to |this|.
// |controller_event_handler_|, and |reader_| will outlive |this|, see the // |controller_event_handler_|, and |reader_| will outlive |this|, see the
// destructor for details. // destructor for details.
......
...@@ -30,7 +30,6 @@ ...@@ -30,7 +30,6 @@
#include "media/mojo/mojom/audio_output_stream.mojom.h" #include "media/mojo/mojom/audio_output_stream.mojom.h"
#include "mojo/public/cpp/bindings/pending_remote.h" #include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/self_owned_receiver.h" #include "mojo/public/cpp/bindings/self_owned_receiver.h"
#include "mojo/public/cpp/bindings/strong_binding.h"
#include "testing/gmock/include/gmock/gmock.h" #include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
...@@ -138,11 +137,11 @@ class DummyMojoAudioLogImpl : public media::mojom::AudioLog { ...@@ -138,11 +137,11 @@ class DummyMojoAudioLogImpl : public media::mojom::AudioLog {
void OnLogMessage(const std::string& message) override {} void OnLogMessage(const std::string& message) override {}
}; };
media::mojom::AudioLogPtr CreateDummyMojoAudioLog() { mojo::PendingRemote<media::mojom::AudioLog> CreateDummyMojoAudioLog() {
media::mojom::AudioLogPtr audio_log_ptr; mojo::PendingRemote<media::mojom::AudioLog> audio_log;
mojo::MakeStrongBinding(std::make_unique<DummyMojoAudioLogImpl>(), mojo::MakeSelfOwnedReceiver(std::make_unique<DummyMojoAudioLogImpl>(),
mojo::MakeRequest(&audio_log_ptr)); audio_log.InitWithNewPipeAndPassReceiver());
return audio_log_ptr; return audio_log;
} }
} // namespace } // namespace
......
...@@ -161,7 +161,7 @@ void OldRenderFrameAudioInputStreamFactory::DoCreateStream( ...@@ -161,7 +161,7 @@ void OldRenderFrameAudioInputStreamFactory::DoCreateStream(
DCHECK_CURRENTLY_ON(BrowserThread::IO); DCHECK_CURRENTLY_ON(BrowserThread::IO);
int stream_id = ++next_stream_id_; int stream_id = ++next_stream_id_;
media::mojom::AudioLogPtr audio_log_ptr = mojo::PendingRemote<media::mojom::AudioLog> audio_log =
MediaInternals::GetInstance()->CreateMojoAudioLog( MediaInternals::GetInstance()->CreateMojoAudioLog(
media::AudioLogFactory::AUDIO_INPUT_CONTROLLER, stream_id, media::AudioLogFactory::AUDIO_INPUT_CONTROLLER, stream_id,
render_process_id_, render_frame_id_); render_process_id_, render_frame_id_);
...@@ -172,7 +172,7 @@ void OldRenderFrameAudioInputStreamFactory::DoCreateStream( ...@@ -172,7 +172,7 @@ void OldRenderFrameAudioInputStreamFactory::DoCreateStream(
base::BindOnce( base::BindOnce(
create_delegate_callback_, create_delegate_callback_,
base::Unretained(media_stream_manager_->audio_input_device_manager()), base::Unretained(media_stream_manager_->audio_input_device_manager()),
std::move(audio_log_ptr), std::move(keyboard_mic_registration), std::move(audio_log), std::move(keyboard_mic_registration),
shared_memory_count, stream_id, session_id, automatic_gain_control, shared_memory_count, stream_id, session_id, automatic_gain_control,
audio_params), audio_params),
base::BindOnce(&OldRenderFrameAudioInputStreamFactory::RemoveStream, base::BindOnce(&OldRenderFrameAudioInputStreamFactory::RemoveStream,
......
...@@ -49,7 +49,7 @@ class CONTENT_EXPORT OldRenderFrameAudioInputStreamFactory ...@@ -49,7 +49,7 @@ class CONTENT_EXPORT OldRenderFrameAudioInputStreamFactory
using CreateDelegateCallback = using CreateDelegateCallback =
base::RepeatingCallback<std::unique_ptr<media::AudioInputDelegate>( base::RepeatingCallback<std::unique_ptr<media::AudioInputDelegate>(
AudioInputDeviceManager* audio_input_device_manager, AudioInputDeviceManager* audio_input_device_manager,
media::mojom::AudioLogPtr audio_log, mojo::PendingRemote<media::mojom::AudioLog> audio_log,
AudioInputDeviceManager::KeyboardMicRegistration AudioInputDeviceManager::KeyboardMicRegistration
keyboard_mic_registration, keyboard_mic_registration,
uint32_t shared_memory_count, uint32_t shared_memory_count,
......
...@@ -95,7 +95,7 @@ class MockRendererAudioInputStreamFactoryClient ...@@ -95,7 +95,7 @@ class MockRendererAudioInputStreamFactoryClient
std::unique_ptr<media::AudioInputDelegate> CreateFakeDelegate( std::unique_ptr<media::AudioInputDelegate> CreateFakeDelegate(
media::AudioInputDelegate::EventHandler** event_handler_out, media::AudioInputDelegate::EventHandler** event_handler_out,
AudioInputDeviceManager* audio_input_device_manager, AudioInputDeviceManager* audio_input_device_manager,
media::mojom::AudioLogPtr audio_log, mojo::PendingRemote<media::mojom::AudioLog> audio_log,
AudioInputDeviceManager::KeyboardMicRegistration keyboard_mic_registration, AudioInputDeviceManager::KeyboardMicRegistration keyboard_mic_registration,
uint32_t shared_memory_count, uint32_t shared_memory_count,
int stream_id, int stream_id,
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "content/public/common/content_features.h" #include "content/public/common/content_features.h"
#include "media/audio/audio_system.h" #include "media/audio/audio_system.h"
#include "media/mojo/mojom/audio_logging.mojom.h" #include "media/mojo/mojom/audio_logging.mojom.h"
#include "mojo/public/cpp/bindings/remote.h"
namespace content { namespace content {
...@@ -64,16 +65,16 @@ RendererAudioOutputStreamFactoryContextImpl::CreateDelegate( ...@@ -64,16 +65,16 @@ RendererAudioOutputStreamFactoryContextImpl::CreateDelegate(
MediaObserver* const media_observer = MediaObserver* const media_observer =
GetContentClient()->browser()->GetMediaObserver(); GetContentClient()->browser()->GetMediaObserver();
media::mojom::AudioLogPtr audio_log_ptr = mojo::Remote<media::mojom::AudioLog> audio_log(
MediaInternals::GetInstance()->CreateMojoAudioLog( MediaInternals::GetInstance()->CreateMojoAudioLog(
media::AudioLogFactory::AUDIO_OUTPUT_CONTROLLER, stream_id, media::AudioLogFactory::AUDIO_OUTPUT_CONTROLLER, stream_id,
render_process_id_, render_frame_id); render_process_id_, render_frame_id));
audio_log_ptr->OnCreated(params, unique_device_id); audio_log->OnCreated(params, unique_device_id);
return AudioOutputDelegateImpl::Create( return AudioOutputDelegateImpl::Create(
handler, audio_manager_, std::move(audio_log_ptr), media_observer, handler, audio_manager_, audio_log.Unbind(), media_observer, stream_id,
stream_id, render_frame_id, render_process_id_, params, render_frame_id, render_process_id_, params, std::move(stream_observer),
std::move(stream_observer), unique_device_id); unique_device_id);
} }
} // namespace content } // namespace content
...@@ -879,10 +879,9 @@ void SpeechRecognizerImpl::CreateAudioCapturerSource() { ...@@ -879,10 +879,9 @@ void SpeechRecognizerImpl::CreateAudioCapturerSource() {
if (connector) { if (connector) {
audio_capturer_source_ = audio::CreateInputDevice( audio_capturer_source_ = audio::CreateInputDevice(
connector->Clone(), device_id_, connector->Clone(), device_id_,
MediaInternals::GetInstance() MediaInternals::GetInstance()->CreateMojoAudioLog(
->CreateMojoAudioLog(media::AudioLogFactory::AUDIO_INPUT_CONTROLLER, media::AudioLogFactory::AUDIO_INPUT_CONTROLLER,
0 /* component_id */) 0 /* component_id */));
.PassInterface());
} }
} }
......
...@@ -53,8 +53,8 @@ enum AudioLogComponent { ...@@ -53,8 +53,8 @@ enum AudioLogComponent {
interface AudioLogFactory { interface AudioLogFactory {
// Creates an AudioLog object for tracking the behavior for one instance of // Creates an AudioLog object for tracking the behavior for one instance of
// the given |component|. Each instance of an "owning" class must create its // the given |component|. Each instance of an "owning" class must create its
// own AudioLog. The created AudioLog object is bound to |audio_log_request|. // own AudioLog. The created AudioLog object is bound to |audio_log_receiver|.
CreateAudioLog(AudioLogComponent component, CreateAudioLog(AudioLogComponent component,
int32 component_id, int32 component_id,
AudioLog& audio_log_request); pending_receiver<AudioLog> audio_log_receiver);
}; };
...@@ -17,7 +17,7 @@ class AudioParameters; ...@@ -17,7 +17,7 @@ class AudioParameters;
namespace audio { namespace audio {
// This class wraps a media::mojom::AudioLogPtr into a media::AudioLog. // This class wraps a Remote<media::mojom::AudioLog> into a media::AudioLog.
class LogAdapter : public media::AudioLog { class LogAdapter : public media::AudioLog {
public: public:
explicit LogAdapter(mojo::PendingRemote<media::mojom::AudioLog> audio_log); explicit LogAdapter(mojo::PendingRemote<media::mojom::AudioLog> audio_log);
......
...@@ -12,9 +12,10 @@ ...@@ -12,9 +12,10 @@
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
#include "base/test/task_environment.h" #include "base/test/task_environment.h"
#include "media/mojo/mojom/audio_logging.mojom.h" #include "media/mojo/mojom/audio_logging.mojom.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/receiver.h" #include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/remote.h" #include "mojo/public/cpp/bindings/remote.h"
#include "mojo/public/cpp/bindings/strong_binding.h" #include "mojo/public/cpp/bindings/self_owned_receiver.h"
#include "services/audio/traced_service_ref.h" #include "services/audio/traced_service_ref.h"
#include "services/service_manager/public/cpp/service_keepalive.h" #include "services/service_manager/public/cpp/service_keepalive.h"
#include "testing/gmock/include/gmock/gmock.h" #include "testing/gmock/include/gmock/gmock.h"
...@@ -56,13 +57,14 @@ class MockAudioLogFactory : public media::mojom::AudioLogFactory { ...@@ -56,13 +57,14 @@ class MockAudioLogFactory : public media::mojom::AudioLogFactory {
MOCK_METHOD2(MockCreateAudioLog, MOCK_METHOD2(MockCreateAudioLog,
void(media::mojom::AudioLogComponent, int32_t)); void(media::mojom::AudioLogComponent, int32_t));
void CreateAudioLog( void CreateAudioLog(media::mojom::AudioLogComponent component,
media::mojom::AudioLogComponent component, int32_t component_id,
int32_t component_id, mojo::PendingReceiver<media::mojom::AudioLog>
media::mojom::AudioLogRequest audio_log_request) override { audio_log_receiver) override {
MockCreateAudioLog(component, component_id); MockCreateAudioLog(component, component_id);
mojo::MakeStrongBinding(base::WrapUnique(mock_logs_[current_mock_log_++]), mojo::MakeSelfOwnedReceiver(
std::move(audio_log_request)); base::WrapUnique(mock_logs_[current_mock_log_++]),
std::move(audio_log_receiver));
} }
MockAudioLog* GetMockLog(size_t index) { return mock_logs_[index]; } MockAudioLog* GetMockLog(size_t index) { return mock_logs_[index]; }
......
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