Commit 474b839d authored by Chris Kuiper's avatar Chris Kuiper Committed by Commit Bot

[Chromecast] Set proper default ducking multiplier in AThings speakers

This sets a proper default ducking multiplier used in Chromium's MediaSession
(see Chromium change 942055 for reference).

Two cases:

1)
On AThings speakers running CMA backend, which does its own ducking, disable
ducking in the Chromium MediaSession by setting its ducking multiplier to 1.0.

2)
For speakers not running CMA backend and relying on the Chromium MediaSession
to duck, set an appropriate ducking multiplier (-30dB) that is inline with
Cast's ducking levels [-35..-20]dB.

Note that this is a simplification of Cast's ducking logic and more fine-tuning
of this is desirable.

Bug: internal b/69630398, internal b/73907369
Test: Ran on Android Things speakers w/ and w/o CMA backend, observed proper
      ducking.

Change-Id: I5fe5a7e46750b88a7d44af1b38ec3f094a7c387d
Reviewed-on: https://chromium-review.googlesource.com/979261
Commit-Queue: Chris Kuiper <ckuiper@chromium.org>
Reviewed-by: default avatarLuke Halliwell <halliwell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#545709}
parent 9c03e780
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "chromecast/chromecast_buildflags.h" #include "chromecast/chromecast_buildflags.h"
#include "chromecast/public/cast_media_shlib.h" #include "chromecast/public/cast_media_shlib.h"
#include "content/public/browser/media_capture_devices.h" #include "content/public/browser/media_capture_devices.h"
#include "content/public/browser/media_session.h"
#include "content/public/browser/navigation_handle.h" #include "content/public/browser/navigation_handle.h"
#include "content/public/browser/render_frame_host.h" #include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_view_host.h" #include "content/public/browser/render_view_host.h"
...@@ -86,6 +87,23 @@ CastWebViewDefault::CastWebViewDefault( ...@@ -86,6 +87,23 @@ CastWebViewDefault::CastWebViewDefault(
content::WebContentsObserver::Observe(web_contents_.get()); content::WebContentsObserver::Observe(web_contents_.get());
web_contents_->SetDelegate(this); web_contents_->SetDelegate(this);
#if BUILDFLAG(IS_ANDROID_THINGS)
// Configure the ducking multiplier for AThings speakers. When CMA backend is
// used we don't want the Chromium MediaSession to duck since we are doing
// our own ducking. When no CMA backend is used we rely on the MediaSession
// for ducking. In that case set it to a proper value to match the ducking
// done in CMA backend.
#if BUILDFLAG(IS_CAST_USING_CMA_BACKEND)
// passthrough, i.e., disable ducking
constexpr double kDuckingMultiplier = 1.0;
#else
// duck by -30dB
constexpr double kDuckingMultiplier = 0.03;
#endif
content::MediaSession::Get(web_contents_.get())
->SetDuckingVolumeMultiplier(kDuckingMultiplier);
#endif
// If this CastWebView is enabled for development, start the remote debugger. // If this CastWebView is enabled for development, start the remote debugger.
if (enabled_for_dev_) { if (enabled_for_dev_) {
LOG(INFO) << "Enabling dev console for " << web_contents_->GetVisibleURL(); LOG(INFO) << "Enabling dev console for " << web_contents_->GetVisibleURL();
......
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