summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGareth Stockwell <ext-gareth.stockwell@nokia.com>2010-01-11 18:08:00 (GMT)
committerGareth Stockwell <ext-gareth.stockwell@nokia.com>2010-01-11 18:08:00 (GMT)
commit24392fb62bb34a80eb7ce13662b0a8744c9ab415 (patch)
tree5cfef2c30f07356e361d8c69948130af364c5b93
parent5a8c0ded599263446010dfc1729dcab8b2f62f0d (diff)
downloadQt-24392fb62bb34a80eb7ce13662b0a8744c9ab415.zip
Qt-24392fb62bb34a80eb7ce13662b0a8744c9ab415.tar.gz
Qt-24392fb62bb34a80eb7ce13662b0a8744c9ab415.tar.bz2
Added enable/disable parameter to each effect in Phonon MMF backend
Task-number: QTBUG-4659 Reviewed-by: Espen Riskedal
-rw-r--r--src/3rdparty/phonon/mmf/abstractaudioeffect.cpp33
-rw-r--r--src/3rdparty/phonon/mmf/abstractaudioeffect.h17
-rw-r--r--src/3rdparty/phonon/mmf/audioequalizer.cpp7
-rw-r--r--src/3rdparty/phonon/mmf/audioequalizer.h4
-rw-r--r--src/3rdparty/phonon/mmf/bassboost.cpp25
-rw-r--r--src/3rdparty/phonon/mmf/bassboost.h2
-rw-r--r--src/3rdparty/phonon/mmf/effectfactory.cpp15
-rw-r--r--src/3rdparty/phonon/mmf/environmentalreverb.cpp4
-rw-r--r--src/3rdparty/phonon/mmf/environmentalreverb.h4
-rw-r--r--src/3rdparty/phonon/mmf/loudness.cpp25
-rw-r--r--src/3rdparty/phonon/mmf/loudness.h2
-rw-r--r--src/3rdparty/phonon/mmf/stereowidening.cpp4
12 files changed, 74 insertions, 68 deletions
diff --git a/src/3rdparty/phonon/mmf/abstractaudioeffect.cpp b/src/3rdparty/phonon/mmf/abstractaudioeffect.cpp
index e3672e6..132eb79 100644
--- a/src/3rdparty/phonon/mmf/abstractaudioeffect.cpp
+++ b/src/3rdparty/phonon/mmf/abstractaudioeffect.cpp
@@ -72,7 +72,6 @@ void AbstractAudioEffect::setParameterValue(const Phonon::EffectParameter &param
if (m_effect.data()) {
const EffectParameter& internalParam = internalParameter(param.id());
int err = parameterChanged(internalParam, newValue);
- TRAP(err, m_effect->ApplyL());
// TODO: handle audio effect errors
Q_UNUSED(err);
}
@@ -159,5 +158,37 @@ const MMF::EffectParameter& AbstractAudioEffect::internalParameter(int id) const
return *result;
}
+int AbstractAudioEffect::parameterChanged(const EffectParameter &param,
+ const QVariant &value)
+{
+ int err = 0;
+
+ switch (param.id()) {
+ case ParameterEnable:
+ setEnabled(value.toBool());
+ break;
+ default:
+ {
+ const EffectParameter& internalParam = internalParameter(param.id());
+ err = effectParameterChanged(internalParam, value);
+ }
+ break;
+ }
+
+ if (!err)
+ TRAP(err, m_effect->ApplyL());
+
+ return err;
+}
+
+int AbstractAudioEffect::effectParameterChanged(
+ const EffectParameter &param, const QVariant &value)
+{
+ // Default implementation
+ Q_ASSERT_X(false, Q_FUNC_INFO, "Effect has no parameters");
+ return 0;
+}
+
+
QT_END_NAMESPACE
diff --git a/src/3rdparty/phonon/mmf/abstractaudioeffect.h b/src/3rdparty/phonon/mmf/abstractaudioeffect.h
index a3b35c2..9878472 100644
--- a/src/3rdparty/phonon/mmf/abstractaudioeffect.h
+++ b/src/3rdparty/phonon/mmf/abstractaudioeffect.h
@@ -72,6 +72,13 @@ public:
virtual void setParameterValue(const Phonon::EffectParameter &,
const QVariant &newValue);
+ // Parameters which are shared by all effects
+ enum CommonParameters
+ {
+ ParameterEnable = 0,
+ ParameterBase // must be last entry in enum
+ };
+
public Q_SLOTS:
void abstractPlayerChanged(AbstractPlayer *player);
void stateChanged(Phonon::State newState,
@@ -82,16 +89,18 @@ protected:
void connectMediaObject(MediaObject *mediaObject);
void disconnectMediaObject(MediaObject *mediaObject);
- void setEnabled(bool enabled);
-
virtual void createEffect(AudioPlayer::NativePlayer *player) = 0;
- virtual int parameterChanged(const EffectParameter &param,
- const QVariant &value) = 0;
+ // Effect-specific parameter changed
+ virtual int effectParameterChanged(const EffectParameter &param,
+ const QVariant &value);
private:
void createEffect();
+ void setEnabled(bool enabled);
const EffectParameter& internalParameter(int id) const;
+ int parameterChanged(const EffectParameter &param,
+ const QVariant &value);
protected:
QScopedPointer<CAudioEffect> m_effect;
diff --git a/src/3rdparty/phonon/mmf/audioequalizer.cpp b/src/3rdparty/phonon/mmf/audioequalizer.cpp
index 201a5fc..1d2bbd4 100644
--- a/src/3rdparty/phonon/mmf/audioequalizer.cpp
+++ b/src/3rdparty/phonon/mmf/audioequalizer.cpp
@@ -37,10 +37,11 @@ AudioEqualizer::AudioEqualizer(QObject *parent, const QList<EffectParameter>& pa
}
-int AudioEqualizer::parameterChanged(const EffectParameter &param,
+int AudioEqualizer::effectParameterChanged(const EffectParameter &param,
const QVariant &value)
{
- const int band = param.id() + 1;
+ const int band = param.id() - ParameterBase + 1;
+
const qreal externalLevel = value.toReal();
const int internalLevel = param.toInternalValue(externalLevel);
@@ -87,7 +88,7 @@ bool AudioEqualizer::getParameters(CMdaAudioOutputStream *stream,
// Phonon::EffectWidget. See documentation of EffectParameter
// for more details.
EffectParameter param(
- /* parameterId */ i,
+ /* parameterId */ ParameterBase + i,
/* name */ tr("%1 Hz").arg(hz),
/* hints */ EffectParameter::LogarithmicHint,
/* defaultValue */ QVariant(qreal(0.0)),
diff --git a/src/3rdparty/phonon/mmf/audioequalizer.h b/src/3rdparty/phonon/mmf/audioequalizer.h
index acfe9b5..9c3770a 100644
--- a/src/3rdparty/phonon/mmf/audioequalizer.h
+++ b/src/3rdparty/phonon/mmf/audioequalizer.h
@@ -51,8 +51,8 @@ public:
protected:
// AbstractAudioEffect
virtual void createEffect(AudioPlayer::NativePlayer *player);
- virtual int parameterChanged(const EffectParameter &param,
- const QVariant &value);
+ virtual int effectParameterChanged(const EffectParameter &param,
+ const QVariant &value);
private:
CAudioEqualizer *concreteEffect();
diff --git a/src/3rdparty/phonon/mmf/bassboost.cpp b/src/3rdparty/phonon/mmf/bassboost.cpp
index 6996ba9..c7af939 100644
--- a/src/3rdparty/phonon/mmf/bassboost.cpp
+++ b/src/3rdparty/phonon/mmf/bassboost.cpp
@@ -37,14 +37,6 @@ BassBoost::BassBoost(QObject *parent, const QList<EffectParameter> &parameters)
}
-int BassBoost::parameterChanged(const EffectParameter &param,
- const QVariant &value)
-{
- Q_ASSERT_X(param.id() == 0, Q_FUNC_INFO, "Invalid parameter ID");
- setEnabled(value.toBool());
- return 0;
-}
-
//-----------------------------------------------------------------------------
// Static functions
//-----------------------------------------------------------------------------
@@ -57,24 +49,9 @@ const char* BassBoost::description()
bool BassBoost::getParameters(CMdaAudioOutputStream *stream,
QList<EffectParameter> &parameters)
{
- bool supported = false;
-
QScopedPointer<CBassBoost> effect;
TRAPD(err, effect.reset(CBassBoost::NewL(*stream)));
-
- if(KErrNone == err) {
- supported = true;
-
- EffectParameter param(
- /* parameterId */ 0,
- /* name */ tr("Enabled"),
- /* hints */ EffectParameter::ToggledHint,
- /* defaultValue */ QVariant(bool(true)));
-
- parameters.append(param);
- }
-
- return supported;
+ return (KErrNone == err);
}
QT_END_NAMESPACE
diff --git a/src/3rdparty/phonon/mmf/bassboost.h b/src/3rdparty/phonon/mmf/bassboost.h
index e8e8094..fc40e21 100644
--- a/src/3rdparty/phonon/mmf/bassboost.h
+++ b/src/3rdparty/phonon/mmf/bassboost.h
@@ -46,8 +46,6 @@ public:
protected:
// AbstractAudioEffect
virtual void createEffect(AudioPlayer::NativePlayer *player);
- virtual int parameterChanged(const EffectParameter &param,
- const QVariant &value);
private:
CBassBoost *concreteEffect();
diff --git a/src/3rdparty/phonon/mmf/effectfactory.cpp b/src/3rdparty/phonon/mmf/effectfactory.cpp
index 081f6a3..c5e33d5 100644
--- a/src/3rdparty/phonon/mmf/effectfactory.cpp
+++ b/src/3rdparty/phonon/mmf/effectfactory.cpp
@@ -176,6 +176,13 @@ EffectFactory::EffectData EffectFactory::getData()
OutputStreamFactory streamFactory;
QScopedPointer<CMdaAudioOutputStream> stream(streamFactory.create());
+ EffectParameter param(
+ /* parameterId */ AbstractAudioEffect::ParameterEnable,
+ /* name */ tr("Enabled"),
+ /* hints */ EffectParameter::ToggledHint,
+ /* defaultValue */ QVariant(bool(true)));
+ data.m_parameters.append(param);
+
if (data.m_supported = BackendNode::getParameters
(stream.data(), data.m_parameters)) {
const QString description = QCoreApplication::translate
@@ -185,6 +192,14 @@ EffectFactory::EffectData EffectFactory::getData()
data.m_descriptions.insert("available", true);
}
+ // Sanity check to ensure that all parameter IDs are unique
+ QSet<int> ids;
+ foreach (param, data.m_parameters) {
+ Q_ASSERT_X(ids.find(param.id()) == ids.end(), Q_FUNC_INFO,
+ "Parameter list contains duplicates");
+ ids.insert(param.id());
+ }
+
return data;
}
diff --git a/src/3rdparty/phonon/mmf/environmentalreverb.cpp b/src/3rdparty/phonon/mmf/environmentalreverb.cpp
index f362afd..89f8d60 100644
--- a/src/3rdparty/phonon/mmf/environmentalreverb.cpp
+++ b/src/3rdparty/phonon/mmf/environmentalreverb.cpp
@@ -33,7 +33,7 @@ PHONON_MMF_DEFINE_EFFECT_FUNCTIONS(EnvironmentalReverb)
enum Parameters
{
- DecayHFRatio,
+ DecayHFRatio = AbstractAudioEffect::ParameterBase,
DecayTime,
Density,
Diffusion,
@@ -51,7 +51,7 @@ EnvironmentalReverb::EnvironmentalReverb(QObject *parent, const QList<EffectPara
}
-int EnvironmentalReverb::parameterChanged(const EffectParameter &param,
+int EnvironmentalReverb::effectParameterChanged(const EffectParameter &param,
const QVariant &value)
{
const qreal externalLevel = value.toReal();
diff --git a/src/3rdparty/phonon/mmf/environmentalreverb.h b/src/3rdparty/phonon/mmf/environmentalreverb.h
index 8a91517..eab68c6 100644
--- a/src/3rdparty/phonon/mmf/environmentalreverb.h
+++ b/src/3rdparty/phonon/mmf/environmentalreverb.h
@@ -46,8 +46,8 @@ public:
protected:
// AbstractAudioEffect
virtual void createEffect(AudioPlayer::NativePlayer *player);
- virtual int parameterChanged(const EffectParameter &param,
- const QVariant &value);
+ virtual int effectParameterChanged(const EffectParameter &param,
+ const QVariant &value);
private:
CEnvironmentalReverb *concreteEffect();
diff --git a/src/3rdparty/phonon/mmf/loudness.cpp b/src/3rdparty/phonon/mmf/loudness.cpp
index 2239ac1..1079a35 100644
--- a/src/3rdparty/phonon/mmf/loudness.cpp
+++ b/src/3rdparty/phonon/mmf/loudness.cpp
@@ -37,14 +37,6 @@ Loudness::Loudness(QObject *parent, const QList<EffectParameter>& parameters)
}
-int Loudness::parameterChanged(const EffectParameter &param,
- const QVariant &value)
-{
- Q_ASSERT_X(param.id() == 0, Q_FUNC_INFO, "Invalid parameter ID");
- setEnabled(value.toBool());
- return 0;
-}
-
//-----------------------------------------------------------------------------
// Static functions
//-----------------------------------------------------------------------------
@@ -57,24 +49,9 @@ const char* Loudness::description()
bool Loudness::getParameters(CMdaAudioOutputStream *stream,
QList<EffectParameter> &parameters)
{
- bool supported = false;
-
QScopedPointer<CLoudness> effect;
TRAPD(err, effect.reset(CLoudness::NewL(*stream)));
-
- if(KErrNone == err) {
- supported = true;
-
- EffectParameter param(
- /* parameterId */ 0,
- /* name */ tr("Enabled"),
- /* hints */ EffectParameter::ToggledHint,
- /* defaultValue */ QVariant(bool(true)));
-
- parameters.append(param);
- }
-
- return supported;
+ return (KErrNone == err);
}
QT_END_NAMESPACE
diff --git a/src/3rdparty/phonon/mmf/loudness.h b/src/3rdparty/phonon/mmf/loudness.h
index bb3380e..a688a67 100644
--- a/src/3rdparty/phonon/mmf/loudness.h
+++ b/src/3rdparty/phonon/mmf/loudness.h
@@ -46,8 +46,6 @@ public:
protected:
// AbstractAudioEffect
virtual void createEffect(AudioPlayer::NativePlayer *player);
- virtual int parameterChanged(const EffectParameter &param,
- const QVariant &value);
private:
CLoudness *concreteEffect();
diff --git a/src/3rdparty/phonon/mmf/stereowidening.cpp b/src/3rdparty/phonon/mmf/stereowidening.cpp
index d14617d..f90651b 100644
--- a/src/3rdparty/phonon/mmf/stereowidening.cpp
+++ b/src/3rdparty/phonon/mmf/stereowidening.cpp
@@ -40,7 +40,7 @@ StereoWidening::StereoWidening(QObject *parent, const QList<EffectParameter>& pa
int StereoWidening::parameterChanged(const EffectParameter &param,
const QVariant &value)
{
- Q_ASSERT_X(param.id() == 0, Q_FUNC_INFO, "Invalid parameter ID");
+ Q_ASSERT_X(param.id() == ParameterBase, Q_FUNC_INFO, "Invalid parameter ID");
const qreal externalLevel = value.toReal();
const int internalLevel = param.toInternalValue(externalLevel);
@@ -75,7 +75,7 @@ bool StereoWidening::getParameters(CMdaAudioOutputStream *stream,
(effect->StereoWideningLevel(), 0, 100);
EffectParameter param(
- /* parameterId */ 0,
+ /* parameterId */ ParameterBase,
/* name */ tr("Level (%)"),
/* hints */ EffectParameter::IntegerHint,
/* defaultValue */ QVariant(defaultValue),