1
0
mirror of https://github.com/strawberrymusicplayer/strawberry synced 2025-02-06 12:25:10 +01:00

Mpris2: Fix incorrect rounding when setting volume

Fixes #894
This commit is contained in:
Jonas Kvinge 2022-02-11 20:26:41 +01:00
parent 1b8966b3a4
commit c9caa7f034
2 changed files with 7 additions and 3 deletions

View File

@ -410,9 +410,13 @@ void Mpris2::AlbumCoverLoaded(const Song &song, const AlbumCoverLoaderResult &re
}
double Mpris2::Volume() const { return app_->player()->GetVolume() / 100.0; }
double Mpris2::Volume() const {
return app_->player()->GetVolume() / 100.0;
}
void Mpris2::SetVolume(double value) { app_->player()->SetVolume(static_cast<int>(value * 100)); }
void Mpris2::SetVolume(const double value) {
app_->player()->SetVolume(static_cast<uint>(std::max(std::min(lround(value * 100.0), 100L), 0L)));
}
qint64 Mpris2::Position() const {
return app_->player()->engine()->position_nanosec() / kNsecPerUsec;

View File

@ -145,7 +145,7 @@ class Mpris2 : public QObject {
void SetShuffle(bool enable);
QVariantMap Metadata() const;
double Volume() const;
void SetVolume(double value);
void SetVolume(const double value);
qint64 Position() const;
double MaximumRate() const;
double MinimumRate() const;