Commit 92af36ee authored by calamity's avatar calamity Committed by Commit Bot

Revert "Eliminate unreachable code."

This reverts commit df07d66c.

Reason for revert: Causing compile failures on linux-chromeos-chrome
https://ci.chromium.org/p/chrome/builders/ci/linux-chromeos-chrome/4233

Original change's description:
> Eliminate unreachable code.
> 
> This converts runtime checking of BUILDFLAG output to compile-time
> checking.  It also converts NOTREACHED to DLOG(ERROR).
> 
> Bug: 346399
> Change-Id: I85dc2e655a1badccb117bb566f8812c6962416b6
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2114400
> Commit-Queue: Peter Kasting <pkasting@chromium.org>
> Reviewed-by: Kenneth MacKay <kmackay@chromium.org>
> Auto-Submit: Peter Kasting <pkasting@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#752603}

TBR=pkasting@chromium.org,rockot@google.com,kmackay@chromium.org

Change-Id: I6f2787f775d211322b8c200410a07f48f0782f9d
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 346399
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2116165Reviewed-by: default avatarcalamity <calamity@chromium.org>
Commit-Queue: calamity <calamity@chromium.org>
Cr-Commit-Position: refs/heads/master@{#752721}
parent 6af71a8d
......@@ -154,7 +154,7 @@ class VolumeControlInternal : public SystemVolumeControl::Delegate {
AudioContentType type,
float level) {
if (type == AudioContentType::kOther) {
DLOG(ERROR) << "Can't set volume for content type kOther";
NOTREACHED() << "Can't set volume for content type kOther";
return;
}
......@@ -167,19 +167,20 @@ class VolumeControlInternal : public SystemVolumeControl::Delegate {
void SetVolumeMultiplier(AudioContentType type, float multiplier) {
if (type == AudioContentType::kOther) {
DLOG(ERROR) << "Can't set volume multiplier for content type kOther";
NOTREACHED() << "Can't set volume multiplier for content type kOther";
return;
}
if (BUILDFLAG(SYSTEM_OWNS_VOLUME)) {
LOG(INFO) << "Ignore global volume multiplier since volume is externally "
<< "controlled";
return;
}
#if BUILDFLAG(SYSTEM_OWNS_VOLUME)
LOG(INFO) << "Ignore global volume multiplier since volume is externally "
<< "controlled";
#else
thread_.task_runner()->PostTask(
FROM_HERE,
base::BindOnce(&VolumeControlInternal::SetVolumeMultiplierOnThread,
base::Unretained(this), type, multiplier));
#endif
}
bool IsMuted(AudioContentType type) {
......@@ -189,7 +190,7 @@ class VolumeControlInternal : public SystemVolumeControl::Delegate {
void SetMuted(VolumeChangeSource source, AudioContentType type, bool muted) {
if (type == AudioContentType::kOther) {
DLOG(ERROR) << "Can't set mute state for content type kOther";
NOTREACHED() << "Can't set mute state for content type kOther";
return;
}
......@@ -201,7 +202,7 @@ class VolumeControlInternal : public SystemVolumeControl::Delegate {
void SetOutputLimit(AudioContentType type, float limit) {
if (type == AudioContentType::kOther) {
DLOG(ERROR) << "Can't set output limit for content type kOther";
NOTREACHED() << "Can't set output limit for content type kOther";
return;
}
......@@ -233,27 +234,28 @@ class VolumeControlInternal : public SystemVolumeControl::Delegate {
volume_multipliers_[type] = 1.0f;
#if BUILDFLAG(SYSTEM_OWNS_VOLUME)
// ALSA owns volume; our internal mixer should not apply any scaling
// If ALSA owns volume, our internal mixer should not apply any scaling
// multiplier.
mixer_->SetVolume(type, 1.0f);
#else
#else // BUILDFLAG(SYSTEM_OWNS_VOLUME)
mixer_->SetVolume(type, DbFsToScale(dbfs));
#endif
#endif // BUILDFLAG(SYSTEM_OWNS_VOLUME)
// Note that mute state is not persisted across reboots.
muted_[type] = false;
}
#if BUILDFLAG(SYSTEM_OWNS_VOLUME)
// Read the current volume and mute state from the ALSA mixer element(s).
// If ALSA owns the volume, then read the current volume and mute state
// from the ALSA mixer element(s).
volumes_[AudioContentType::kMedia] = system_volume_control_->GetVolume();
muted_[AudioContentType::kMedia] = system_volume_control_->IsMuted();
#else
// Make sure the ALSA mixer element correctly reflects the current volume
// state.
#else // BUILDFLAG(SYSTEM_OWNS_VOLUME)
// Otherwise, make sure the ALSA mixer element correctly reflects the
// current volume state.
system_volume_control_->SetVolume(volumes_[AudioContentType::kMedia]);
system_volume_control_->SetMuted(false);
#endif
#endif // BUILDFLAG(SYSTEM_OWNS_VOLUME)
volumes_[AudioContentType::kOther] = 1.0;
muted_[AudioContentType::kOther] = false;
......@@ -266,7 +268,7 @@ class VolumeControlInternal : public SystemVolumeControl::Delegate {
float level,
bool from_system) {
DCHECK(thread_.task_runner()->BelongsToCurrentThread());
DCHECK_NE(AudioContentType::kOther, type);
DCHECK(type != AudioContentType::kOther);
DCHECK(!from_system || type == AudioContentType::kMedia);
DCHECK(volume_multipliers_.find(type) != volume_multipliers_.end());
......@@ -283,9 +285,9 @@ class VolumeControlInternal : public SystemVolumeControl::Delegate {
}
float dbfs = VolumeControl::VolumeToDbFS(level);
#if !BUILDFLAG(SYSTEM_OWNS_VOLUME)
mixer_->SetVolume(type, DbFsToScale(dbfs) * volume_multipliers_[type]);
#endif
if (!BUILDFLAG(SYSTEM_OWNS_VOLUME)) {
mixer_->SetVolume(type, DbFsToScale(dbfs) * volume_multipliers_[type]);
}
if (!from_system && type == AudioContentType::kMedia) {
system_volume_control_->SetVolume(level);
......@@ -304,15 +306,13 @@ class VolumeControlInternal : public SystemVolumeControl::Delegate {
void SetVolumeMultiplierOnThread(AudioContentType type, float multiplier) {
DCHECK(thread_.task_runner()->BelongsToCurrentThread());
DCHECK_NE(AudioContentType::kOther, type);
#if BUILDFLAG(SYSTEM_OWNS_VOLUME)
NOTREACHED();
#else
DCHECK(type != AudioContentType::kOther);
DCHECK(!BUILDFLAG(SYSTEM_OWNS_VOLUME));
volume_multipliers_[type] = multiplier;
float scale =
DbFsToScale(VolumeControl::VolumeToDbFS(volumes_[type])) * multiplier;
mixer_->SetVolume(type, scale);
#endif
}
void SetMutedOnThread(VolumeChangeSource source,
......@@ -320,7 +320,7 @@ class VolumeControlInternal : public SystemVolumeControl::Delegate {
bool muted,
bool from_system) {
DCHECK(thread_.task_runner()->BelongsToCurrentThread());
DCHECK_NE(AudioContentType::kOther, type);
DCHECK(type != AudioContentType::kOther);
{
base::AutoLock lock(volume_lock_);
......@@ -330,9 +330,9 @@ class VolumeControlInternal : public SystemVolumeControl::Delegate {
muted_[type] = muted;
}
#if !BUILDFLAG(SYSTEM_OWNS_VOLUME)
mixer_->SetMuted(type, muted);
#endif
if (!BUILDFLAG(SYSTEM_OWNS_VOLUME)) {
mixer_->SetMuted(type, muted);
}
if (!from_system && type == AudioContentType::kMedia) {
system_volume_control_->SetMuted(muted);
......@@ -348,11 +348,13 @@ class VolumeControlInternal : public SystemVolumeControl::Delegate {
void SetOutputLimitOnThread(AudioContentType type, float limit) {
if (type == AudioContentType::kOther) {
DLOG(ERROR) << "Can't set output limit for content type kOther";
NOTREACHED() << "Can't set output limit for content type kOther";
return;
}
#if !BUILDFLAG(SYSTEM_OWNS_VOLUME)
if (BUILDFLAG(SYSTEM_OWNS_VOLUME)) {
return;
}
limit = base::ClampToRange(limit, 0.0f, 1.0f);
mixer_->SetVolumeLimit(type,
DbFsToScale(VolumeControl::VolumeToDbFS(limit)));
......@@ -360,7 +362,6 @@ class VolumeControlInternal : public SystemVolumeControl::Delegate {
if (type == AudioContentType::kMedia) {
system_volume_control_->SetLimit(limit);
}
#endif
}
void SetPowerSaveModeOnThread(bool power_save_on) {
......
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