summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/phonon/mmf/audioequalizer.cpp
diff options
context:
space:
mode:
authorGareth Stockwell <ext-gareth.stockwell@nokia.com>2010-01-08 18:09:27 (GMT)
committerGareth Stockwell <ext-gareth.stockwell@nokia.com>2010-01-08 18:09:27 (GMT)
commit4c95ec342c62183ecc3dffe50497b4858bc27c8d (patch)
tree3888d6454c4e7d346ddcf9ff5d3b63b6b15ecd20 /src/3rdparty/phonon/mmf/audioequalizer.cpp
parentd44c661d75ff6edcabf70b188b18bc991611628b (diff)
downloadQt-4c95ec342c62183ecc3dffe50497b4858bc27c8d.zip
Qt-4c95ec342c62183ecc3dffe50497b4858bc27c8d.tar.gz
Qt-4c95ec342c62183ecc3dffe50497b4858bc27c8d.tar.bz2
Implemented audio effects capability querying in Phonon MMF backend
This patch addresses the following deficiencies in the existing implementation of audio effects: 1. Native effect objects (e.g. CAudioEqualizer, CBassBoost etc) were created frequently, just in order to check whether a given effect is supported, or retrieve the list of parameters which it requires. Although this is in part due to a deficiency in the S60 audio effects API (it doesn't have a 'capability query' concept), it can be improved by using caching. This patch introduces a singleton EffectFactory object, which lazily initializes a data structure containing information about support and parameters. 2. In order to either query effect support, the native effect object ultimately needs to access a DevSound instance. Previously, the effect object was provided with a CMdaAudioPlayerUtility object. If this player utility has not loaded an MMF controller plugin *before* the effects object makes any calls to the player utility, incorrect results will be returned. This was observed in the previous code. For querying, we don't actually need to load an MMF controller; instead, we would like to directly provide a CMMFDevSound instance to the effect object. Unfortunately, this API is not available in public S60 SDKs, so we must use the next lowest interface available, namely CMdaAudioOutputStream. By making this change, this patch ensures that support and parameter queries made via the EffectFactory will return the correct result. At this point, however, effect settings made via the Phonon API are not actually applied to the audio output. Fixing this will require notifying the audio effects backend nodes of state changes in the MediaObject. Task-number: QTBUG-4659 Reviewed-by: Espen Riskedal
Diffstat (limited to 'src/3rdparty/phonon/mmf/audioequalizer.cpp')
-rw-r--r--src/3rdparty/phonon/mmf/audioequalizer.cpp40
1 files changed, 21 insertions, 19 deletions
diff --git a/src/3rdparty/phonon/mmf/audioequalizer.cpp b/src/3rdparty/phonon/mmf/audioequalizer.cpp
index c2936c5..5aa659a 100644
--- a/src/3rdparty/phonon/mmf/audioequalizer.cpp
+++ b/src/3rdparty/phonon/mmf/audioequalizer.cpp
@@ -28,8 +28,10 @@ using namespace Phonon::MMF;
\internal
*/
-AudioEqualizer::AudioEqualizer(QObject *parent) : AbstractAudioEffect::AbstractAudioEffect(parent, createParams())
+AudioEqualizer::AudioEqualizer(QObject *parent, const QList<EffectParameter> &parameters)
+ : AbstractAudioEffect::AbstractAudioEffect(parent, parameters)
{
+
}
void AudioEqualizer::parameterChanged(const int pid,
@@ -68,30 +70,32 @@ void AudioEqualizer::setBandLevel(int band, int level)
TRAP_IGNORE(effect->SetBandLevelL(band, level));
}
-QList<EffectParameter> AudioEqualizer::createParams()
-{
- QList<EffectParameter> retval;
-
- // We temporarily create an AudioPlayer, and run the effect on it, so
- // we can extract the readonly data we need.
- AudioPlayer dummyPlayer;
+//-----------------------------------------------------------------------------
+// Static functions
+//-----------------------------------------------------------------------------
- CAudioEqualizer *eqPtr = 0;
- QT_TRAP_THROWING(eqPtr = CAudioEqualizer::NewL(*dummyPlayer.nativePlayer()));
- QScopedPointer<CAudioEqualizer> e(eqPtr);
+const char* AudioEqualizer::description()
+{
+ return "Audio equalizer";
+}
+void AudioEqualizer::getParameters(NativeEffect *effect,
+ QList<EffectParameter> &parameters)
+{
TInt32 dbMin;
TInt32 dbMax;
- e->DbLevelLimits(dbMin, dbMax);
+ effect->DbLevelLimits(dbMin, dbMax);
- const int bandCount = e->NumberOfBands();
+ const int bandCount = effect->NumberOfBands();
- for (int i = 0; i < bandCount; ++i) {
- const qint32 hz = e->CenterFrequency(i);
+ // For some reason, band IDs are 1-based, as opposed to the
+ // 0-based indices used in just about other Symbian API...!
+ for (int i = 1; i <= bandCount; ++i) {
+ const qint32 hz = effect->CenterFrequency(i);
- const qint32 defVol = e->BandLevel(i);
+ const qint32 defVol = effect->BandLevel(i);
- retval.append(EffectParameter(i,
+ parameters.append(EffectParameter(i,
tr("Frequency band, %1 Hz").arg(hz),
EffectParameter::LogarithmicHint,
QVariant(qint32(defVol)),
@@ -100,8 +104,6 @@ QList<EffectParameter> AudioEqualizer::createParams()
QVariantList(),
QString()));
}
-
- return retval;
}
QT_END_NAMESPACE