summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/phonon
diff options
context:
space:
mode:
authorGareth Stockwell <ext-gareth.stockwell@nokia.com>2010-01-11 16:05:17 (GMT)
committerGareth Stockwell <ext-gareth.stockwell@nokia.com>2010-01-11 16:30:44 (GMT)
commit99acb8f8e53767e59a5634609b0d3582ae5b0d7c (patch)
tree15c8149eac6f3389b7f3f0430e845f99cb037848 /src/3rdparty/phonon
parentaefcf35b4e4dd62771b9fe531c84d35e13f2c660 (diff)
downloadQt-99acb8f8e53767e59a5634609b0d3582ae5b0d7c.zip
Qt-99acb8f8e53767e59a5634609b0d3582ae5b0d7c.tar.gz
Qt-99acb8f8e53767e59a5634609b0d3582ae5b0d7c.tar.bz2
Refactored AbstractAudioEffect to reduce redundancy in derived classes
Task-number: QTBUG-4659 Reviewed-by: Espen Riskedal
Diffstat (limited to 'src/3rdparty/phonon')
-rw-r--r--src/3rdparty/phonon/mmf/abstractaudioeffect.cpp21
-rw-r--r--src/3rdparty/phonon/mmf/abstractaudioeffect.h6
-rw-r--r--src/3rdparty/phonon/mmf/audioequalizer.cpp35
-rw-r--r--src/3rdparty/phonon/mmf/audioequalizer.h5
-rw-r--r--src/3rdparty/phonon/mmf/bassboost.cpp7
-rw-r--r--src/3rdparty/phonon/mmf/bassboost.h4
6 files changed, 37 insertions, 41 deletions
diff --git a/src/3rdparty/phonon/mmf/abstractaudioeffect.cpp b/src/3rdparty/phonon/mmf/abstractaudioeffect.cpp
index cdddf02..3bce86b 100644
--- a/src/3rdparty/phonon/mmf/abstractaudioeffect.cpp
+++ b/src/3rdparty/phonon/mmf/abstractaudioeffect.cpp
@@ -70,7 +70,8 @@ void AbstractAudioEffect::setParameterValue(const Phonon::EffectParameter &param
m_values.insert(param.id(), newValue);
if (m_effect.data()) {
- parameterChanged(param.id(), newValue);
+ const EffectParameter& internalParam = internalParameter(param.id());
+ parameterChanged(internalParam, newValue);
// TODO: handle audio effect errors
TRAP_IGNORE(m_effect->ApplyL());
}
@@ -122,11 +123,27 @@ void AbstractAudioEffect::createEffect()
}
if (m_effect.data()) {
- applyParameters();
+ EffectParameter param;
+ foreach (param, m_params) {
+ const QVariant value = parameterValue(param);
+ parameterChanged(param, value);
+ }
+
// TODO: handle audio effect errors
TRAP_IGNORE(m_effect->EnableL());
}
}
+const MMF::EffectParameter& AbstractAudioEffect::internalParameter(int id) const
+{
+ const EffectParameter *result = 0;
+ for (int i=0; i<m_params.count() && !result; ++i) {
+ if (m_params[i].id() == id)
+ result = &m_params[i];
+ }
+ Q_ASSERT_X(result, Q_FUNC_INFO, "Parameter not found");
+ return *result;
+}
+
QT_END_NAMESPACE
diff --git a/src/3rdparty/phonon/mmf/abstractaudioeffect.h b/src/3rdparty/phonon/mmf/abstractaudioeffect.h
index b34ad0d..9b9c47d 100644
--- a/src/3rdparty/phonon/mmf/abstractaudioeffect.h
+++ b/src/3rdparty/phonon/mmf/abstractaudioeffect.h
@@ -83,19 +83,19 @@ protected:
void disconnectMediaObject(MediaObject *mediaObject);
virtual void createEffect(AudioPlayer::NativePlayer *player) = 0;
- virtual void applyParameters() = 0;
- virtual void parameterChanged(const int id,
+ virtual void parameterChanged(const EffectParameter &param,
const QVariant &value) = 0;
private:
void createEffect();
+ const EffectParameter& internalParameter(int id) const;
protected:
QScopedPointer<CAudioEffect> m_effect;
- const QList<EffectParameter> m_params;
private:
+ const QList<EffectParameter> m_params;
AbstractMediaPlayer * m_player;
QHash<int, QVariant> m_values;
};
diff --git a/src/3rdparty/phonon/mmf/audioequalizer.cpp b/src/3rdparty/phonon/mmf/audioequalizer.cpp
index e3b1ab3..1584cf7 100644
--- a/src/3rdparty/phonon/mmf/audioequalizer.cpp
+++ b/src/3rdparty/phonon/mmf/audioequalizer.cpp
@@ -37,35 +37,18 @@ AudioEqualizer::AudioEqualizer(QObject *parent, const QList<EffectParameter>& pa
}
-void AudioEqualizer::parameterChanged(const int pid,
+void AudioEqualizer::parameterChanged(const EffectParameter &param,
const QVariant &value)
{
- const int band = pid;
- const qreal level = value.toReal();
- setBandLevel(band, level);
-}
-
-void AudioEqualizer::applyParameters()
-{
- if (m_effect.data()) {
- Phonon::EffectParameter param;
- foreach (param, parameters()) {
- const int band = param.id();
- const qreal level = parameterValue(param).toReal();
- setBandLevel(band, level);
- }
- }
-}
-
-void AudioEqualizer::setBandLevel(int band, qreal externalLevel)
-{
- const EffectParameter &param = m_params[band-1]; // Band IDs are 1-based
+ const int band = param.id() + 1;
+ const qreal externalLevel = value.toReal();
const int internalLevel = param.toInternalValue(externalLevel);
// TODO: handle audio effect errors
TRAP_IGNORE(concreteEffect()->SetBandLevelL(band, internalLevel));
}
+
//-----------------------------------------------------------------------------
// Static functions
//-----------------------------------------------------------------------------
@@ -92,10 +75,12 @@ bool AudioEqualizer::getParameters(CMdaAudioOutputStream *stream,
const int bandCount = effect->NumberOfBands();
- // 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);
+ for (int i = 0; i < bandCount; ++i) {
+ // For some reason, band IDs are 1-based, as opposed to the
+ // 0-based indices used in just about other Symbian API...!
+ const int band = i + 1;
+
+ const qint32 hz = effect->CenterFrequency(band);
// We pass a floating-point parameter range of -1.0 to +1.0 for
// each band in order to work around a limitation in
diff --git a/src/3rdparty/phonon/mmf/audioequalizer.h b/src/3rdparty/phonon/mmf/audioequalizer.h
index 9eda994..3a9a5ca 100644
--- a/src/3rdparty/phonon/mmf/audioequalizer.h
+++ b/src/3rdparty/phonon/mmf/audioequalizer.h
@@ -51,11 +51,10 @@ public:
protected:
// AbstractAudioEffect
virtual void createEffect(AudioPlayer::NativePlayer *player);
- virtual void applyParameters();
- virtual void parameterChanged(const int id, const QVariant &value);
+ virtual void parameterChanged(const EffectParameter &param,
+ const QVariant &value);
private:
- void setBandLevel(int band, qreal externalLevel);
CAudioEqualizer *concreteEffect();
};
diff --git a/src/3rdparty/phonon/mmf/bassboost.cpp b/src/3rdparty/phonon/mmf/bassboost.cpp
index c8c4831..997bae4 100644
--- a/src/3rdparty/phonon/mmf/bassboost.cpp
+++ b/src/3rdparty/phonon/mmf/bassboost.cpp
@@ -37,17 +37,12 @@ BassBoost::BassBoost(QObject *parent, const QList<EffectParameter> &parameters)
}
-void BassBoost::parameterChanged(const int,
+void BassBoost::parameterChanged(const EffectParameter &,
const QVariant &)
{
Q_ASSERT_X(false, Q_FUNC_INFO, "BassBoost has no parameters");
}
-void BassBoost::applyParameters()
-{
- // No parameters to apply
-}
-
//-----------------------------------------------------------------------------
// Static functions
//-----------------------------------------------------------------------------
diff --git a/src/3rdparty/phonon/mmf/bassboost.h b/src/3rdparty/phonon/mmf/bassboost.h
index d3cda34..b2bc854 100644
--- a/src/3rdparty/phonon/mmf/bassboost.h
+++ b/src/3rdparty/phonon/mmf/bassboost.h
@@ -49,8 +49,8 @@ public:
protected:
// AbstractAudioEffect
virtual void createEffect(AudioPlayer::NativePlayer *player);
- virtual void applyParameters();
- virtual void parameterChanged(const int id, const QVariant &value);
+ virtual void parameterChanged(const EffectParameter &param,
+ const QVariant &value);
private:
CBassBoost *concreteEffect();