summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGareth Stockwell <ext-gareth.stockwell@nokia.com>2010-01-11 15:50:19 (GMT)
committerGareth Stockwell <ext-gareth.stockwell@nokia.com>2010-01-11 15:50:19 (GMT)
commit1a7234e3a27b592565241e9044919f7842fc5f08 (patch)
treef1827dc67e43e1a6565709db100aaca37cd82150 /src
parent894bb6e1742b75312feb7a18d043a67a3dba4cb9 (diff)
downloadQt-1a7234e3a27b592565241e9044919f7842fc5f08.zip
Qt-1a7234e3a27b592565241e9044919f7842fc5f08.tar.gz
Qt-1a7234e3a27b592565241e9044919f7842fc5f08.tar.bz2
Added a macro to reduce boilerplate code in Phonon MMF backend
Task-number: QTBUG-4659 Reviewed-by: Espen Riskedal
Diffstat (limited to 'src')
-rw-r--r--src/3rdparty/phonon/mmf/abstractaudioeffect.h19
-rw-r--r--src/3rdparty/phonon/mmf/audioequalizer.cpp15
-rw-r--r--src/3rdparty/phonon/mmf/audioequalizer.h3
-rw-r--r--src/3rdparty/phonon/mmf/bassboost.cpp10
-rw-r--r--src/3rdparty/phonon/mmf/bassboost.h5
5 files changed, 35 insertions, 17 deletions
diff --git a/src/3rdparty/phonon/mmf/abstractaudioeffect.h b/src/3rdparty/phonon/mmf/abstractaudioeffect.h
index 9e5a6eb..b34ad0d 100644
--- a/src/3rdparty/phonon/mmf/abstractaudioeffect.h
+++ b/src/3rdparty/phonon/mmf/abstractaudioeffect.h
@@ -103,6 +103,25 @@ private:
}
}
+
+// Macro for defining functions which depend on the native class name
+// for each of the effects. Using this reduces repetition of boilerplate
+// in the implementations of the backend effect nodes.
+
+#define PHONON_MMF_DEFINE_EFFECT_FUNCTIONS(Effect) \
+ \
+void Effect##::createEffect(AudioPlayer::NativePlayer *player) \
+{ \
+ C##Effect *ptr = 0; \
+ QT_TRAP_THROWING(ptr = C##Effect::NewL(*player)); \
+ m_effect.reset(ptr); \
+} \
+ \
+C##Effect* Effect::concreteEffect() \
+{ \
+ return static_cast<C##Effect *>(m_effect.data()); \
+}
+
QT_END_NAMESPACE
#endif
diff --git a/src/3rdparty/phonon/mmf/audioequalizer.cpp b/src/3rdparty/phonon/mmf/audioequalizer.cpp
index a4127c4..ab95f30 100644
--- a/src/3rdparty/phonon/mmf/audioequalizer.cpp
+++ b/src/3rdparty/phonon/mmf/audioequalizer.cpp
@@ -28,7 +28,10 @@ using namespace Phonon::MMF;
\internal
*/
-AudioEqualizer::AudioEqualizer(QObject *parent, const QList<EffectParameter> &parameters)
+// Define functions which depend on concrete native effect class name
+PHONON_MMF_DEFINE_EFFECT_FUNCTIONS(AudioEqualizer)
+
+AudioEqualizer::AudioEqualizer(QObject *parent, const QList<EffectParameter>& parameters)
: AbstractAudioEffect::AbstractAudioEffect(parent, parameters)
{
@@ -44,13 +47,6 @@ void AudioEqualizer::parameterChanged(const int pid,
}
}
-void AudioEqualizer::createEffect(AudioPlayer::NativePlayer *player)
-{
- CAudioEqualizer *ptr = 0;
- QT_TRAP_THROWING(ptr = CAudioEqualizer::NewL(*player));
- m_effect.reset(ptr);
-}
-
void AudioEqualizer::applyParameters()
{
if (m_effect.data()) {
@@ -68,9 +64,8 @@ void AudioEqualizer::setBandLevel(int band, qreal externalLevel)
const EffectParameter &param = m_params[band-1]; // Band IDs are 1-based
const int internalLevel = param.toInternalValue(externalLevel);
- CAudioEqualizer *const effect = static_cast<CAudioEqualizer *>(m_effect.data());
// TODO: handle audio effect errors
- TRAP_IGNORE(effect->SetBandLevelL(band, internalLevel));
+ TRAP_IGNORE(concreteEffect()->SetBandLevelL(band, internalLevel));
}
//-----------------------------------------------------------------------------
diff --git a/src/3rdparty/phonon/mmf/audioequalizer.h b/src/3rdparty/phonon/mmf/audioequalizer.h
index 35592f4..9eda994 100644
--- a/src/3rdparty/phonon/mmf/audioequalizer.h
+++ b/src/3rdparty/phonon/mmf/audioequalizer.h
@@ -21,6 +21,8 @@ along with this library. If not, see <http://www.gnu.org/licenses/>.
#include "abstractaudioeffect.h"
+class CAudioEqualizer;
+
QT_BEGIN_NAMESPACE
namespace Phonon
@@ -54,6 +56,7 @@ protected:
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 642d782..c8c4831 100644
--- a/src/3rdparty/phonon/mmf/bassboost.cpp
+++ b/src/3rdparty/phonon/mmf/bassboost.cpp
@@ -24,6 +24,9 @@ QT_BEGIN_NAMESPACE
using namespace Phonon;
using namespace Phonon::MMF;
+// Define functions which depend on concrete native effect class name
+PHONON_MMF_DEFINE_EFFECT_FUNCTIONS(BassBoost)
+
/*! \class MMF::BassBoost
\internal
*/
@@ -40,13 +43,6 @@ void BassBoost::parameterChanged(const int,
Q_ASSERT_X(false, Q_FUNC_INFO, "BassBoost has no parameters");
}
-void BassBoost::createEffect(AudioPlayer::NativePlayer *player)
-{
- CBassBoost *ptr = 0;
- QT_TRAP_THROWING(ptr = CBassBoost::NewL(*player));
- m_effect.reset(ptr);
-}
-
void BassBoost::applyParameters()
{
// No parameters to apply
diff --git a/src/3rdparty/phonon/mmf/bassboost.h b/src/3rdparty/phonon/mmf/bassboost.h
index 241cda9..d3cda34 100644
--- a/src/3rdparty/phonon/mmf/bassboost.h
+++ b/src/3rdparty/phonon/mmf/bassboost.h
@@ -21,6 +21,8 @@ along with this library. If not, see <http://www.gnu.org/licenses/>.
#include "abstractaudioeffect.h"
+class CBassBoost;
+
QT_BEGIN_NAMESPACE
namespace Phonon
@@ -50,6 +52,9 @@ protected:
virtual void applyParameters();
virtual void parameterChanged(const int id, const QVariant &value);
+private:
+ CBassBoost *concreteEffect();
+
};
}
}