Commit 2aa05df7 authored by Yuri Wiitala's avatar Yuri Wiitala Committed by Commit Bot

Fix unintended local audio "blips" when using the Mirroring Service.

Fixes a bug where local audio unmutes briefly for a second when the
Mirroring Service switches between mirroring and remoting. This is
accomplished by holding a "Muter" sentinel throughout the whole session
to ensure no accidental audio leakage happens while loopback capture is
closed/re-started.

In my quest to fix the bug, it became clear that the
content::AudioLoopbackStreamCreator does not provide the
granularity-of-control needed for the muting bugfix. Thus, this change
has CastMirroringServiceHost invoke the Audio Service mojo APIs
directly.

Bug: 1111026
Change-Id: I9b3e60814306be2179d46a5daeb4c7e8ccee1bdb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2504636Reviewed-by: default avatarJordan Bayles <jophba@chromium.org>
Commit-Queue: Yuri Wiitala <miu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#824740}
parent 67f02bba
......@@ -19,14 +19,19 @@
#include "content/public/browser/media_stream_request.h"
#include "content/public/browser/web_contents_observer.h"
#include "extensions/buildflags/buildflags.h"
#include "mojo/public/cpp/bindings/associated_remote.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "services/audio/public/mojom/stream_factory.mojom.h"
#include "ui/gfx/geometry/size.h"
namespace base {
class UnguessableToken;
}
namespace content {
class AudioLoopbackStreamCreator;
class BrowserContext;
struct DesktopMediaID;
class WebContents;
......@@ -96,13 +101,23 @@ class CastMirroringServiceHost final : public mojom::MirroringServiceHost,
void GetNetworkContext(
mojo::PendingReceiver<network::mojom::NetworkContext> receiver) override;
void CreateAudioStream(
mojo::PendingRemote<mojom::AudioStreamCreatorClient> client,
mojo::PendingRemote<mojom::AudioStreamCreatorClient> requestor,
const media::AudioParameters& params,
uint32_t total_segments) override;
void ConnectToRemotingSource(
mojo::PendingRemote<media::mojom::Remoter> remoter,
mojo::PendingReceiver<media::mojom::RemotingSource> receiver) override;
void CreateAudioStreamForTab(
mojo::PendingRemote<mojom::AudioStreamCreatorClient> requestor,
const media::AudioParameters& params,
uint32_t total_segments,
const base::UnguessableToken& group_id);
void CreateAudioStreamForDesktop(
mojo::PendingRemote<mojom::AudioStreamCreatorClient> requestor,
const media::AudioParameters& params,
uint32_t total_segments);
// content::WebContentsObserver implementation.
void WebContentsDestroyed() override;
......@@ -136,8 +151,14 @@ class CastMirroringServiceHost final : public mojom::MirroringServiceHost,
// any.
std::unique_ptr<viz::GpuClient, base::OnTaskRunnerDeleter> gpu_client_;
// Used to create an audio loopback stream through the Audio Service.
std::unique_ptr<content::AudioLoopbackStreamCreator> audio_stream_creator_;
// Used to create WebContents loopback capture streams, or system-wide desktop
// capture streams, from the Audio Service.
mojo::Remote<audio::mojom::StreamFactory> audio_stream_factory_;
// Used to mute local audio from the WebContents being mirrored (in the tab
// mirrorng case). See the comments in the implementation of
// CreateAudioStream() for further explanation.
mojo::AssociatedRemote<audio::mojom::LocalMuter> web_contents_audio_muter_;
// The lifetime of the capture indicator icon on the tabstrip is tied to that
// of |media_stream_ui_|.
......
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