From 41f2710dea63d0c0fad50d03660c7f6caa636ae2 Mon Sep 17 00:00:00 2001 From: Jonas Kvinge Date: Sun, 8 Jan 2023 15:25:24 +0100 Subject: [PATCH] GstEnginePipeline: Use linear volume --- src/engine/gstenginepipeline.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/engine/gstenginepipeline.cpp b/src/engine/gstenginepipeline.cpp index 59933400..a3b094ae 100644 --- a/src/engine/gstenginepipeline.cpp +++ b/src/engine/gstenginepipeline.cpp @@ -876,7 +876,7 @@ void GstEnginePipeline::NotifyVolumeCallback(GstElement *element, GParamSpec *pa g_object_get(G_OBJECT(instance->volume_), "volume", &instance->volume_internal_, nullptr); - const uint volume_percent = static_cast(qBound(0L, lround(qBound(0.0, gst_stream_volume_convert_volume(GST_STREAM_VOLUME_FORMAT_LINEAR, GST_STREAM_VOLUME_FORMAT_CUBIC, instance->volume_internal_), 1.0) / 0.01), 100L)); + const uint volume_percent = static_cast(qBound(0L, lround(instance->volume_internal_ / 0.01), 100L)); if (volume_percent != instance->volume_percent_) { instance->volume_percent_ = volume_percent; emit instance->VolumeChanged(volume_percent); @@ -1515,8 +1515,8 @@ bool GstEnginePipeline::Seek(const qint64 nanosec) { void GstEnginePipeline::SetVolume(const uint volume_percent) { - if (volume_) { - const double volume_internal = lround(static_cast(gst_stream_volume_convert_volume(GST_STREAM_VOLUME_FORMAT_CUBIC, GST_STREAM_VOLUME_FORMAT_LINEAR, static_cast(volume_percent) * 0.01) * 100.0)) / 100.0; + if (volume_ && volume_percent_ != volume_percent) { + const double volume_internal = static_cast(volume_percent) * 0.01; if (volume_internal != volume_internal_) { volume_internal_ = volume_internal; g_object_set(G_OBJECT(volume_), "volume", volume_internal, nullptr);