Skip to content

Commit

Permalink
Add chromecast flag and check for volume control of single volume
Browse files Browse the repository at this point in the history
platforms.

Bug: b/111922445
Test: Successfully build CastShell.
Change-Id: Iaf61f099001370fb3b948654e126ffa91f6e57d7
Reviewed-on: https://chromium-review.googlesource.com/1186147
Reviewed-by: Luke Halliwell <halliwell@chromium.org>
Reviewed-by: Kenneth MacKay <kmackay@chromium.org>
Commit-Queue: Melisa Carranza Zúñiga <melisacz@google.com>
Cr-Commit-Position: refs/heads/master@{#585940}
  • Loading branch information
melcz authored and Commit Bot committed Aug 24, 2018
1 parent 7b13c53 commit 43ffcb0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions chromecast/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,7 @@ buildflag_header("chromecast_buildflags") {
"ENABLE_CHROMECAST_EXTENSIONS=$enable_chromecast_extensions",
"ENABLE_CAST_FRAGMENT=$enable_cast_fragment",
"IS_ANDROID_THINGS_NON_PUBLIC=$is_android_things_non_public",
"IS_SINGLE_VOLUME=$is_single_volume",
"USE_ANDROID_USER_AGENT=$use_android_user_agent",
"USE_CHROMECAST_CDMS=$use_chromecast_cdms",
]
Expand Down
4 changes: 4 additions & 0 deletions chromecast/chromecast.gni
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ declare_args() {
# Set true for builds targeting Android Things.
is_android_things = false

# Set true if the platform works as a single volume device, mapping all
# volume streams to a single one.
is_single_volume = false

# Set to true to start music apps in headless mode.
enable_headless_music_mode = false

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,12 +189,14 @@ void VolumeControlAndroid::InitializeOnThread() {
<< " mute=" << muted_[type];
}

#if !BUILDFLAG(IS_SINGLE_VOLUME)
// The kOther content type should not have any type-wide volume control or
// mute (volume control for kOther is per-stream only). Therefore, ensure
// that the global volume and mute state fo kOther is initialized correctly
// (100% volume, and not muted).
SetVolumeOnThread(AudioContentType::kOther, 1.0f, false /* from_android */);
SetMutedOnThread(AudioContentType::kOther, false, false /* from_android */);
#endif

initialize_complete_event_.Signal();
}
Expand Down Expand Up @@ -266,27 +268,31 @@ void VolumeControlAndroid::SetMutedOnThread(AudioContentType type,
void VolumeControlAndroid::ReportVolumeChangeOnThread(AudioContentType type,
float level) {
DCHECK(thread_.task_runner()->BelongsToCurrentThread());
#if !BUILDFLAG(IS_SINGLE_VOLUME)
if (type == AudioContentType::kOther) {
// Volume for AudioContentType::kOther should stay at 1.0.
Java_VolumeControl_setVolume(base::android::AttachCurrentThread(),
j_volume_control_, static_cast<int>(type),
1.0f);
return;
}
#endif

SetVolumeOnThread(type, level, true /* from android */);
}

void VolumeControlAndroid::ReportMuteChangeOnThread(AudioContentType type,
bool muted) {
DCHECK(thread_.task_runner()->BelongsToCurrentThread());
#if !BUILDFLAG(IS_SINGLE_VOLUME)
if (type == AudioContentType::kOther) {
// Mute state for AudioContentType::kOther should always be false.
Java_VolumeControl_setMuted(base::android::AttachCurrentThread(),
j_volume_control_, static_cast<int>(type),
false);
return;
}
#endif

SetMutedOnThread(type, muted, true /* from_android */);
}
Expand Down

0 comments on commit 43ffcb0

Please sign in to comment.