17 */ |
17 */ |
18 |
18 |
19 #ifndef PHONON_MMF_ABSTRACTEFFECT_H |
19 #ifndef PHONON_MMF_ABSTRACTEFFECT_H |
20 #define PHONON_MMF_ABSTRACTEFFECT_H |
20 #define PHONON_MMF_ABSTRACTEFFECT_H |
21 |
21 |
22 #include "mmf_medianode.h" |
|
23 |
|
24 #include <QScopedPointer> |
22 #include <QScopedPointer> |
25 |
23 |
26 #include <AudioEffectBase.h> |
24 #include <AudioEffectBase.h> |
27 |
25 |
28 #include <Phonon/EffectInterface> |
26 #include <phonon/effectinterface.h> |
29 #include <Phonon/EffectParameter> |
27 |
30 #include "audioplayer.h" |
28 #include "audioplayer.h" |
|
29 #include "effectparameter.h" |
|
30 #include "mmf_medianode.h" |
|
31 |
|
32 class CMdaAudioOutputStream; |
31 |
33 |
32 QT_BEGIN_NAMESPACE |
34 QT_BEGIN_NAMESPACE |
33 |
35 |
34 namespace Phonon |
36 namespace Phonon |
35 { |
37 { |
36 namespace MMF |
38 namespace MMF |
37 { |
39 { |
|
40 class AbstractPlayer; |
|
41 class AbstractMediaPlayer; |
38 |
42 |
39 /** |
43 /** |
40 * @short Base class for all effects for MMF. |
44 * @short Base class for all effects for MMF. |
41 * |
45 * |
42 * Adhering to Phonon with MMF is cumbersome because of a number of reasons: |
46 * Adhering to Phonon with MMF is cumbersome because of a number of reasons: |
59 Q_INTERFACES(Phonon::EffectInterface) |
63 Q_INTERFACES(Phonon::EffectInterface) |
60 public: |
64 public: |
61 AbstractAudioEffect(QObject *parent, |
65 AbstractAudioEffect(QObject *parent, |
62 const QList<EffectParameter> ¶ms); |
66 const QList<EffectParameter> ¶ms); |
63 |
67 |
64 virtual QList<EffectParameter> parameters() const; |
68 // Phonon::EffectInterface |
65 virtual QVariant parameterValue(const EffectParameter ¶m) const; |
69 virtual QList<Phonon::EffectParameter> parameters() const; |
66 virtual void setParameterValue(const EffectParameter &, |
70 virtual QVariant parameterValue(const Phonon::EffectParameter ¶m) const; |
|
71 virtual void setParameterValue(const Phonon::EffectParameter &, |
67 const QVariant &newValue); |
72 const QVariant &newValue); |
68 |
73 |
69 virtual bool disconnectMediaNode(MediaNode *target); |
74 // Parameters which are shared by all effects |
70 |
75 enum CommonParameters |
71 enum Type |
|
72 { |
76 { |
73 EffectAudioEqualizer = 1, |
77 ParameterEnable = 0, |
74 EffectBassBoost, |
78 ParameterBase // must be last entry in enum |
75 EffectDistanceAttenuation, |
|
76 EffectEnvironmentalReverb, |
|
77 EffectListenerOrientation, |
|
78 EffectLoudness, |
|
79 EffectSourceOrientation, |
|
80 EffectStereoWidening |
|
81 }; |
79 }; |
82 |
80 |
|
81 public Q_SLOTS: |
|
82 void abstractPlayerChanged(AbstractPlayer *player); |
|
83 void stateChanged(Phonon::State newState, |
|
84 Phonon::State oldState); |
|
85 |
83 protected: |
86 protected: |
84 virtual bool activateOn(CPlayerType *player) = 0; |
87 // MediaNode |
85 virtual void parameterChanged(const int id, |
88 void connectMediaObject(MediaObject *mediaObject); |
86 const QVariant &value) = 0; |
89 void disconnectMediaObject(MediaObject *mediaObject); |
87 |
90 |
88 /** |
91 virtual void createEffect(AudioPlayer::NativePlayer *player) = 0; |
89 * Part of the implementation of AbstractAudioEffect. Forwards the call to |
|
90 * activateOn(), essentially. |
|
91 */ |
|
92 virtual bool activateOnMediaObject(MediaObject *mo); |
|
93 |
92 |
|
93 // Effect-specific parameter changed |
|
94 virtual int effectParameterChanged(const EffectParameter ¶m, |
|
95 const QVariant &value); |
|
96 |
|
97 private: |
|
98 void createEffect(); |
|
99 void setEnabled(bool enabled); |
|
100 const EffectParameter& internalParameter(int id) const; |
|
101 int parameterChanged(const EffectParameter ¶m, |
|
102 const QVariant &value); |
|
103 |
|
104 protected: |
94 QScopedPointer<CAudioEffect> m_effect; |
105 QScopedPointer<CAudioEffect> m_effect; |
|
106 |
95 private: |
107 private: |
96 const QList<EffectParameter> m_params; |
108 const QList<EffectParameter> m_params; |
|
109 AbstractMediaPlayer * m_player; |
97 QHash<int, QVariant> m_values; |
110 QHash<int, QVariant> m_values; |
98 }; |
111 }; |
|
112 |
99 } |
113 } |
|
114 } |
|
115 |
|
116 |
|
117 // Macro for defining functions which depend on the native class name |
|
118 // for each of the effects. Using this reduces repetition of boilerplate |
|
119 // in the implementations of the backend effect nodes. |
|
120 |
|
121 #define PHONON_MMF_DEFINE_EFFECT_FUNCTIONS(Effect) \ |
|
122 \ |
|
123 void Effect##::createEffect(AudioPlayer::NativePlayer *player) \ |
|
124 { \ |
|
125 C##Effect *ptr = 0; \ |
|
126 QT_TRAP_THROWING(ptr = C##Effect::NewL(*player)); \ |
|
127 m_effect.reset(ptr); \ |
|
128 } \ |
|
129 \ |
|
130 C##Effect* Effect::concreteEffect() \ |
|
131 { \ |
|
132 return static_cast<C##Effect *>(m_effect.data()); \ |
100 } |
133 } |
101 |
134 |
102 QT_END_NAMESPACE |
135 QT_END_NAMESPACE |
103 |
136 |
104 #endif |
137 #endif |