Projects
Eulaceura:Mainline
mate-media
_service:obs_scm:mate-media_0001-gvc-stream-sta...
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File _service:obs_scm:mate-media_0001-gvc-stream-status-icon-fix-a-volume-rounding-error-1.patch of Package mate-media
From 6ff3b04db89743ba8b18ac1cc0797781903716c7 Mon Sep 17 00:00:00 2001 From: rbuj <robert.buj@gmail.com> Date: Wed, 3 Aug 2022 10:29:54 +0200 Subject: [PATCH] gvc-stream-status-icon: fix a volume rounding error (101% -> 100%) --- mate-volume-control/gvc-channel-bar.c | 9 +-------- mate-volume-control/gvc-stream-status-icon.c | 7 +++++-- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/mate-volume-control/gvc-channel-bar.c b/mate-volume-control/gvc-channel-bar.c index e787474..ab4deb2 100644 --- a/mate-volume-control/gvc-channel-bar.c +++ b/mate-volume-control/gvc-channel-bar.c @@ -369,18 +369,11 @@ update_adjustment_value (GvcChannelBar *bar) else value = mate_mixer_stream_control_get_volume (bar->priv->control); - gdouble maximum = gtk_adjustment_get_upper (bar->priv->adjustment); - gdouble minimum = gtk_adjustment_get_lower (bar->priv->adjustment); - gdouble range = maximum - minimum; - - /* round value to nearest hundreth of the range */ - gdouble new_value = minimum + round (((value - minimum) / range) * 100) * (range / 100); - g_signal_handlers_block_by_func (G_OBJECT (bar->priv->adjustment), on_adjustment_value_changed, bar); - gtk_adjustment_set_value (bar->priv->adjustment, new_value); + gtk_adjustment_set_value (bar->priv->adjustment, value); g_signal_handlers_unblock_by_func (G_OBJECT (bar->priv->adjustment), on_adjustment_value_changed, diff --git a/mate-volume-control/gvc-stream-status-icon.c b/mate-volume-control/gvc-stream-status-icon.c index 8ca2849..e857efe 100644 --- a/mate-volume-control/gvc-stream-status-icon.c +++ b/mate-volume-control/gvc-stream-status-icon.c @@ -380,6 +380,7 @@ static void update_icon (GvcStreamStatusIcon *icon) { guint volume = 0; + guint volume_percent = 0; gdouble decibel = 0; guint normal = 0; gboolean muted = FALSE; @@ -407,7 +408,7 @@ update_icon (GvcStreamStatusIcon *icon) /* Select an icon, they are expected to be sorted, the lowest index being * the mute icon and the rest being volume increments */ - if (volume <= 0 || muted) + if (volume == 0 || muted) n = 0; else n = CLAMP (3 * volume / normal + 1, 1, 3); @@ -424,7 +425,9 @@ update_icon (GvcStreamStatusIcon *icon) description = mate_mixer_stream_control_get_label (icon->priv->control); - guint volume_percent = (guint) round (100.0 * volume / normal); + if (normal != 0) + volume_percent = (guint) (100.0 * ((double) volume) / ((double) normal)); + if (muted) { markup = g_strdup_printf ("<b>%s: %s %u%%</b>\n<small>%s</small>", icon->priv->display_name, -- 2.37.1
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.
浙ICP备2022010568号-2