diff -r 41300fa6a67c -r 3b1da2848fc7 src/3rdparty/phonon/mmf/abstractaudioeffect.h --- a/src/3rdparty/phonon/mmf/abstractaudioeffect.h Tue Feb 02 00:43:10 2010 +0200 +++ b/src/3rdparty/phonon/mmf/abstractaudioeffect.h Fri Feb 19 23:40:16 2010 +0200 @@ -19,15 +19,18 @@ #ifndef PHONON_MMF_ABSTRACTEFFECT_H #define PHONON_MMF_ABSTRACTEFFECT_H -#include "mmf_medianode.h" - #include #include -#include -#include +#include + #include "audioplayer.h" +#include "effectparameter.h" +#include "mmf_medianode.h" +#include "mmf_videoplayer.h" + +class CMdaAudioOutputStream; QT_BEGIN_NAMESPACE @@ -35,6 +38,8 @@ { namespace MMF { +class AbstractPlayer; +class AbstractMediaPlayer; /** * @short Base class for all effects for MMF. @@ -61,44 +66,73 @@ AbstractAudioEffect(QObject *parent, const QList ¶ms); - virtual QList parameters() const; - virtual QVariant parameterValue(const EffectParameter ¶m) const; - virtual void setParameterValue(const EffectParameter &, + // Phonon::EffectInterface + virtual QList parameters() const; + virtual QVariant parameterValue(const Phonon::EffectParameter ¶m) const; + virtual void setParameterValue(const Phonon::EffectParameter &, const QVariant &newValue); - virtual bool disconnectMediaNode(MediaNode *target); - - enum Type + // Parameters which are shared by all effects + enum CommonParameters { - EffectAudioEqualizer = 1, - EffectBassBoost, - EffectDistanceAttenuation, - EffectEnvironmentalReverb, - EffectListenerOrientation, - EffectLoudness, - EffectSourceOrientation, - EffectStereoWidening + ParameterEnable = 0, + ParameterBase // must be last entry in enum }; +public Q_SLOTS: + void abstractPlayerChanged(AbstractPlayer *player); + void stateChanged(Phonon::State newState, + Phonon::State oldState); + protected: - virtual bool activateOn(CPlayerType *player) = 0; - virtual void parameterChanged(const int id, - const QVariant &value) = 0; + // MediaNode + void connectMediaObject(MediaObject *mediaObject); + void disconnectMediaObject(MediaObject *mediaObject); + + virtual void createEffect(AudioPlayer::NativePlayer *player) = 0; + + // Effect-specific parameter changed + virtual int effectParameterChanged(const EffectParameter ¶m, + const QVariant &value); - /** - * Part of the implementation of AbstractAudioEffect. Forwards the call to - * activateOn(), essentially. - */ - virtual bool activateOnMediaObject(MediaObject *mo); +private: + void createEffect(); + void setEnabled(bool enabled); + const EffectParameter& internalParameter(int id) const; + int parameterChanged(const EffectParameter ¶m, + const QVariant &value); +protected: QScopedPointer m_effect; + private: const QList m_params; + AbstractMediaPlayer * m_player; QHash m_values; }; + } } + +// 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(m_effect.data()); \ +} + QT_END_NAMESPACE #endif