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 { ...@@ -154,7 +154,7 @@ class VolumeControlInternal : public SystemVolumeControl::Delegate {
AudioContentType type, AudioContentType type,
float level) { float level) {
if (type == AudioContentType::kOther) { if (type == AudioContentType::kOther) {
DLOG(ERROR) << "Can't set volume for content type kOther"; NOTREACHED() << "Can't set volume for content type kOther";
return; return;
} }
...@@ -167,19 +167,20 @@ class VolumeControlInternal : public SystemVolumeControl::Delegate { ...@@ -167,19 +167,20 @@ class VolumeControlInternal : public SystemVolumeControl::Delegate {
void SetVolumeMultiplier(AudioContentType type, float multiplier) { void SetVolumeMultiplier(AudioContentType type, float multiplier) {
if (type == AudioContentType::kOther) { 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; return;
} }
#if BUILDFLAG(SYSTEM_OWNS_VOLUME) if (BUILDFLAG(SYSTEM_OWNS_VOLUME)) {
LOG(INFO) << "Ignore global volume multiplier since volume is externally " LOG(INFO) << "Ignore global volume multiplier since volume is externally "
<< "controlled"; << "controlled";
#else return;
}
thread_.task_runner()->PostTask( thread_.task_runner()->PostTask(
FROM_HERE, FROM_HERE,
base::BindOnce(&VolumeControlInternal::SetVolumeMultiplierOnThread, base::BindOnce(&VolumeControlInternal::SetVolumeMultiplierOnThread,
base::Unretained(this), type, multiplier)); base::Unretained(this), type, multiplier));
#endif
} }
bool IsMuted(AudioContentType type) { bool IsMuted(AudioContentType type) {
...@@ -189,7 +190,7 @@ class VolumeControlInternal : public SystemVolumeControl::Delegate { ...@@ -189,7 +190,7 @@ class VolumeControlInternal : public SystemVolumeControl::Delegate {
void SetMuted(VolumeChangeSource source, AudioContentType type, bool muted) { void SetMuted(VolumeChangeSource source, AudioContentType type, bool muted) {
if (type == AudioContentType::kOther) { 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; return;
} }
...@@ -201,7 +202,7 @@ class VolumeControlInternal : public SystemVolumeControl::Delegate { ...@@ -201,7 +202,7 @@ class VolumeControlInternal : public SystemVolumeControl::Delegate {
void SetOutputLimit(AudioContentType type, float limit) { void SetOutputLimit(AudioContentType type, float limit) {
if (type == AudioContentType::kOther) { 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; return;
} }
...@@ -233,27 +234,28 @@ class VolumeControlInternal : public SystemVolumeControl::Delegate { ...@@ -233,27 +234,28 @@ class VolumeControlInternal : public SystemVolumeControl::Delegate {
volume_multipliers_[type] = 1.0f; volume_multipliers_[type] = 1.0f;
#if BUILDFLAG(SYSTEM_OWNS_VOLUME) #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. // multiplier.
mixer_->SetVolume(type, 1.0f); mixer_->SetVolume(type, 1.0f);
#else #else // BUILDFLAG(SYSTEM_OWNS_VOLUME)
mixer_->SetVolume(type, DbFsToScale(dbfs)); mixer_->SetVolume(type, DbFsToScale(dbfs));
#endif #endif // BUILDFLAG(SYSTEM_OWNS_VOLUME)
// Note that mute state is not persisted across reboots. // Note that mute state is not persisted across reboots.
muted_[type] = false; muted_[type] = false;
} }
#if BUILDFLAG(SYSTEM_OWNS_VOLUME) #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(); volumes_[AudioContentType::kMedia] = system_volume_control_->GetVolume();
muted_[AudioContentType::kMedia] = system_volume_control_->IsMuted(); muted_[AudioContentType::kMedia] = system_volume_control_->IsMuted();
#else #else // BUILDFLAG(SYSTEM_OWNS_VOLUME)
// Make sure the ALSA mixer element correctly reflects the current volume // Otherwise, make sure the ALSA mixer element correctly reflects the
// state. // current volume state.
system_volume_control_->SetVolume(volumes_[AudioContentType::kMedia]); system_volume_control_->SetVolume(volumes_[AudioContentType::kMedia]);
system_volume_control_->SetMuted(false); system_volume_control_->SetMuted(false);
#endif #endif // BUILDFLAG(SYSTEM_OWNS_VOLUME)
volumes_[AudioContentType::kOther] = 1.0; volumes_[AudioContentType::kOther] = 1.0;
muted_[AudioContentType::kOther] = false; muted_[AudioContentType::kOther] = false;
...@@ -266,7 +268,7 @@ class VolumeControlInternal : public SystemVolumeControl::Delegate { ...@@ -266,7 +268,7 @@ class VolumeControlInternal : public SystemVolumeControl::Delegate {
float level, float level,
bool from_system) { bool from_system) {
DCHECK(thread_.task_runner()->BelongsToCurrentThread()); DCHECK(thread_.task_runner()->BelongsToCurrentThread());
DCHECK_NE(AudioContentType::kOther, type); DCHECK(type != AudioContentType::kOther);
DCHECK(!from_system || type == AudioContentType::kMedia); DCHECK(!from_system || type == AudioContentType::kMedia);
DCHECK(volume_multipliers_.find(type) != volume_multipliers_.end()); DCHECK(volume_multipliers_.find(type) != volume_multipliers_.end());
...@@ -283,9 +285,9 @@ class VolumeControlInternal : public SystemVolumeControl::Delegate { ...@@ -283,9 +285,9 @@ class VolumeControlInternal : public SystemVolumeControl::Delegate {
} }
float dbfs = VolumeControl::VolumeToDbFS(level); float dbfs = VolumeControl::VolumeToDbFS(level);
#if !BUILDFLAG(SYSTEM_OWNS_VOLUME) if (!BUILDFLAG(SYSTEM_OWNS_VOLUME)) {
mixer_->SetVolume(type, DbFsToScale(dbfs) * volume_multipliers_[type]); mixer_->SetVolume(type, DbFsToScale(dbfs) * volume_multipliers_[type]);
#endif }
if (!from_system && type == AudioContentType::kMedia) { if (!from_system && type == AudioContentType::kMedia) {
system_volume_control_->SetVolume(level); system_volume_control_->SetVolume(level);
...@@ -304,15 +306,13 @@ class VolumeControlInternal : public SystemVolumeControl::Delegate { ...@@ -304,15 +306,13 @@ class VolumeControlInternal : public SystemVolumeControl::Delegate {
void SetVolumeMultiplierOnThread(AudioContentType type, float multiplier) { void SetVolumeMultiplierOnThread(AudioContentType type, float multiplier) {
DCHECK(thread_.task_runner()->BelongsToCurrentThread()); DCHECK(thread_.task_runner()->BelongsToCurrentThread());
DCHECK_NE(AudioContentType::kOther, type); DCHECK(type != AudioContentType::kOther);
#if BUILDFLAG(SYSTEM_OWNS_VOLUME) DCHECK(!BUILDFLAG(SYSTEM_OWNS_VOLUME));
NOTREACHED();
#else
volume_multipliers_[type] = multiplier; volume_multipliers_[type] = multiplier;
float scale = float scale =
DbFsToScale(VolumeControl::VolumeToDbFS(volumes_[type])) * multiplier; DbFsToScale(VolumeControl::VolumeToDbFS(volumes_[type])) * multiplier;
mixer_->SetVolume(type, scale); mixer_->SetVolume(type, scale);
#endif
} }
void SetMutedOnThread(VolumeChangeSource source, void SetMutedOnThread(VolumeChangeSource source,
...@@ -320,7 +320,7 @@ class VolumeControlInternal : public SystemVolumeControl::Delegate { ...@@ -320,7 +320,7 @@ class VolumeControlInternal : public SystemVolumeControl::Delegate {
bool muted, bool muted,
bool from_system) { bool from_system) {
DCHECK(thread_.task_runner()->BelongsToCurrentThread()); DCHECK(thread_.task_runner()->BelongsToCurrentThread());
DCHECK_NE(AudioContentType::kOther, type); DCHECK(type != AudioContentType::kOther);
{ {
base::AutoLock lock(volume_lock_); base::AutoLock lock(volume_lock_);
...@@ -330,9 +330,9 @@ class VolumeControlInternal : public SystemVolumeControl::Delegate { ...@@ -330,9 +330,9 @@ class VolumeControlInternal : public SystemVolumeControl::Delegate {
muted_[type] = muted; muted_[type] = muted;
} }
#if !BUILDFLAG(SYSTEM_OWNS_VOLUME) if (!BUILDFLAG(SYSTEM_OWNS_VOLUME)) {
mixer_->SetMuted(type, muted); mixer_->SetMuted(type, muted);
#endif }
if (!from_system && type == AudioContentType::kMedia) { if (!from_system && type == AudioContentType::kMedia) {
system_volume_control_->SetMuted(muted); system_volume_control_->SetMuted(muted);
...@@ -348,11 +348,13 @@ class VolumeControlInternal : public SystemVolumeControl::Delegate { ...@@ -348,11 +348,13 @@ class VolumeControlInternal : public SystemVolumeControl::Delegate {
void SetOutputLimitOnThread(AudioContentType type, float limit) { void SetOutputLimitOnThread(AudioContentType type, float limit) {
if (type == AudioContentType::kOther) { 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; return;
} }
#if !BUILDFLAG(SYSTEM_OWNS_VOLUME) if (BUILDFLAG(SYSTEM_OWNS_VOLUME)) {
return;
}
limit = base::ClampToRange(limit, 0.0f, 1.0f); limit = base::ClampToRange(limit, 0.0f, 1.0f);
mixer_->SetVolumeLimit(type, mixer_->SetVolumeLimit(type,
DbFsToScale(VolumeControl::VolumeToDbFS(limit))); DbFsToScale(VolumeControl::VolumeToDbFS(limit)));
...@@ -360,7 +362,6 @@ class VolumeControlInternal : public SystemVolumeControl::Delegate { ...@@ -360,7 +362,6 @@ class VolumeControlInternal : public SystemVolumeControl::Delegate {
if (type == AudioContentType::kMedia) { if (type == AudioContentType::kMedia) {
system_volume_control_->SetLimit(limit); system_volume_control_->SetLimit(limit);
} }
#endif
} }
void SetPowerSaveModeOnThread(bool power_save_on) { 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