Fix Alsa softvol linear mapping (#950)

Use `--volume-range` overrides
This commit is contained in:
Roderick van Domburg 2022-01-27 18:39:28 +01:00 committed by GitHub
parent 03e71f6e0a
commit c8971dce63
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 2 deletions

View file

@ -30,6 +30,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [main] `--alsa-mixer-device` and `--alsa-mixer-index` now fallback to the card and index specified in `--device`.
- [core] Removed unsafe code (breaking)
- [playback] Adhere to ReplayGain spec when calculating gain normalisation factor.
- [playback] `alsa`: Use `--volume-range` overrides for softvol controls
### Removed
- [playback] `alsamixer`: previously deprecated option `mixer-card` has been removed.

View file

@ -84,7 +84,7 @@ impl Mixer for AlsaMixer {
warn!("Alsa rounding error detected, setting maximum dB to {:.2} instead of {:.2}", ZERO_DB.to_db(), max_millibel.to_db());
max_millibel = ZERO_DB;
} else {
warn!("Please manually set with `--volume-ctrl` if this is incorrect");
warn!("Please manually set `--volume-range` if this is incorrect");
}
}
(min_millibel, max_millibel)
@ -104,12 +104,23 @@ impl Mixer for AlsaMixer {
let min_db = min_millibel.to_db() as f64;
let max_db = max_millibel.to_db() as f64;
let db_range = f64::abs(max_db - min_db);
let mut db_range = f64::abs(max_db - min_db);
// Synchronize the volume control dB range with the mixer control,
// unless it was already set with a command line option.
if !config.volume_ctrl.range_ok() {
if db_range > 100.0 {
debug!("Alsa mixer reported dB range > 100, which is suspect");
warn!("Please manually set `--volume-range` if this is incorrect");
}
config.volume_ctrl.set_db_range(db_range);
} else {
let db_range_override = config.volume_ctrl.db_range();
debug!(
"Alsa dB volume range was detected as {} but overridden as {}",
db_range, db_range_override
);
db_range = db_range_override;
}
// For hardware controls with a small range (24 dB or less),