aboutsummaryrefslogtreecommitdiff
path: root/src/snap.cpp
diff options
context:
space:
mode:
authorCharles Kerr <charles.kerr@canonical.com>2014-07-07 20:35:17 -0500
committerCharles Kerr <charles.kerr@canonical.com>2014-07-07 20:35:17 -0500
commit3255261dd7ba9eda3e49ed9b84131c8d93653084 (patch)
tree2ae665f28c646a7048d08eec24adfd66a812e1fb /src/snap.cpp
parent47e3db9dc8d10d6518554a761418be976413f987 (diff)
downloadayatana-indicator-datetime-3255261dd7ba9eda3e49ed9b84131c8d93653084.tar.gz
ayatana-indicator-datetime-3255261dd7ba9eda3e49ed9b84131c8d93653084.tar.bz2
ayatana-indicator-datetime-3255261dd7ba9eda3e49ed9b84131c8d93653084.zip
use GStreamer's full volume range.
Diffstat (limited to 'src/snap.cpp')
-rw-r--r--src/snap.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/snap.cpp b/src/snap.cpp
index cea09d7..8a86521 100644
--- a/src/snap.cpp
+++ b/src/snap.cpp
@@ -131,10 +131,17 @@ private:
gst_element_set_state (m_play, GST_STATE_PLAYING);
}
+ // convert settings range [1..100] to gst playbin's range is [0...1.0]
gdouble get_volume() const
{
- // input int range is [1..100]; gst playbin's range is [0...1.0]
- return CLAMP(m_volume, 1, 100) / 100.0;
+ constexpr int in_range_lo = 1;
+ constexpr int in_range_hi = 100;
+ const double in = CLAMP(m_volume, in_range_lo, in_range_hi);
+ const double pct = (in - in_range_lo) / (in_range_hi - in_range_lo);
+
+ constexpr double out_range_lo = 0.0;
+ constexpr double out_range_hi = 1.0;
+ return out_range_lo + (pct * (out_range_hi - out_range_lo));
}
static gboolean bus_callback(GstBus*, GstMessage* msg, gpointer gself)