OpenSL: Fix volume scale

The old code was assuming that the interface was expecting power
values, while it actually uses amplitude values. In addition the
difference between the min/max values where used, resulting in
quite high gain values.

Task-number: QTBUG-34777

Change-Id: Ibd3f7774b67c44e37dfd79cbe6e2c35746f00a0a
Reviewed-by: Yoann Lopes <yoann.lopes@digia.com>
This commit is contained in:
Christian Strømme
2013-11-12 04:01:28 +01:00
committed by The Qt Project
parent dd11f6d052
commit 14f31c29cf

View File

@@ -52,6 +52,8 @@
#define BUFFER_COUNT 2
#define DEFAULT_PERIOD_TIME_MS 50
#define MINIMUM_PERIOD_TIME_MS 5
#define EBASE 2.302585093
#define LOG10(x) qLn(x)/qreal(EBASE)
QT_BEGIN_NAMESPACE
@@ -622,7 +624,7 @@ inline SLmillibel QOpenSLESAudioOutput::adjustVolume(qreal vol)
if (qFuzzyCompare(vol, qreal(1.0)))
return 0;
return SL_MILLIBEL_MIN + ((1 - (qLn(10 - (vol * 10)) / qLn(10))) * SL_MILLIBEL_MAX);
return 20 * LOG10(vol) * 100; // I.e., 20 * LOG10(SL_MILLIBEL_MAX * vol / SL_MILLIBEL_MAX)
}
QT_END_NAMESPACE