diff --git a/CHANGELOG.md b/CHANGELOG.md index e06242a..507275c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,11 +44,13 @@ * dwl module reporting only the last part of the title ([#251][251]) * i3/sway: regression; persistent workspaces shown twice ([#253][253]). +* pipewire: use roundf instead of ceilf for more accuracy ([#262][262]) [239]: https://codeberg.org/dnkl/yambar/issues/239 [241]: https://codeberg.org/dnkl/yambar/issues/241 [251]: https://codeberg.org/dnkl/yambar/pulls/251 [253]: https://codeberg.org/dnkl/yambar/issues/253 +[262]: https://codeberg.org/dnkl/yambar/issues/262 ### Security diff --git a/modules/pipewire.c b/modules/pipewire.c index 0cc641d..2300e7c 100644 --- a/modules/pipewire.c +++ b/modules/pipewire.c @@ -35,8 +35,8 @@ struct output_informations { /* informations */ bool muted; - uint8_t linear_volume; /* classic volume */ - uint8_t cubic_volume; /* volume a la pulseaudio */ + uint16_t linear_volume; /* classic volume */ + uint16_t cubic_volume; /* volume a la pulseaudio */ char *name; char *description; char *form_factor; /* headset, headphone, speaker, ..., can be null */ @@ -478,8 +478,8 @@ node_events_param(void *userdata, __attribute__((unused)) int seq, __attribute__ total += values[i]; float base_volume = total / n_values; - output_informations->linear_volume = ceilf(base_volume * 100); - output_informations->cubic_volume = ceilf(cbrtf(base_volume) * 100); + output_informations->linear_volume = roundf(base_volume * 100); + output_informations->cubic_volume = roundf(cbrtf(base_volume) * 100); } }