source: trunk/src/3rdparty/phonon/mmf/abstractaudioeffect.h

Last change on this file was 846, checked in by Dmitry A. Kuminov, 15 years ago

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

  • Property svn:eol-style set to native
File size: 4.7 KB
Line 
1/* This file is part of the KDE project.
2
3Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
4
5This library is free software: you can redistribute it and/or modify
6it under the terms of the GNU Lesser General Public License as published by
7the Free Software Foundation, either version 2.1 or 3 of the License.
8
9This library is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU Lesser General Public License for more details.
13
14You should have received a copy of the GNU Lesser General Public License
15along with this library. If not, see <http://www.gnu.org/licenses/>.
16
17*/
18
19#ifndef PHONON_MMF_ABSTRACTEFFECT_H
20#define PHONON_MMF_ABSTRACTEFFECT_H
21
22#include <QScopedPointer>
23
24#include <AudioEffectBase.h>
25
26#include <phonon/effectinterface.h>
27
28#include "audioplayer.h"
29#include "effectparameter.h"
30#include "mmf_medianode.h"
31
32class CMdaAudioOutputStream;
33
34QT_BEGIN_NAMESPACE
35
36namespace Phonon
37{
38namespace MMF
39{
40class AbstractPlayer;
41class AbstractMediaPlayer;
42
43/**
44 * @short Base class for all effects for MMF.
45 *
46 * Adhering to Phonon with MMF is cumbersome because of a number of reasons:
47 *
48 * - MMF has no concept of effect chaining. Simply, an effect is a applied
49 * to PlayerUtility, that's it. This means that the order of effects is
50 * undefined.
51 * - We apply an effect to a PlayerUtility, and MediaObject has that one.
52 * However, effects might be created before MediaObject, but nevertheless
53 * needs to work. We solve this by that we are aware of the whole connection
54 * chain, and whenever a connection happens, we walk the chain, find effects
55 * that aren't applied, and apply it if we have a media object.
56 * - There are plenty of corner cases which we don't handle and where behavior
57 * are undefined. For instance, graphs with more than one MediaObject.
58 */
59class AbstractAudioEffect : public MediaNode
60 , public EffectInterface
61{
62 Q_OBJECT
63 Q_INTERFACES(Phonon::EffectInterface)
64public:
65 AbstractAudioEffect(QObject *parent,
66 const QList<EffectParameter> &params);
67
68 // Phonon::EffectInterface
69 virtual QList<Phonon::EffectParameter> parameters() const;
70 virtual QVariant parameterValue(const Phonon::EffectParameter &param) const;
71 virtual void setParameterValue(const Phonon::EffectParameter &,
72 const QVariant &newValue);
73
74 // Parameters which are shared by all effects
75 enum CommonParameters
76 {
77 ParameterEnable = 0,
78 ParameterBase // must be last entry in enum
79 };
80
81public Q_SLOTS:
82 void abstractPlayerChanged(AbstractPlayer *player);
83 void stateChanged(Phonon::State newState,
84 Phonon::State oldState);
85
86protected:
87 // MediaNode
88 void connectMediaObject(MediaObject *mediaObject);
89 void disconnectMediaObject(MediaObject *mediaObject);
90
91 virtual void createEffect(AudioPlayer::NativePlayer *player) = 0;
92
93 // Effect-specific parameter changed
94 virtual int effectParameterChanged(const EffectParameter &param,
95 const QVariant &value);
96
97private:
98 void createEffect();
99 void setEnabled(bool enabled);
100 const EffectParameter& internalParameter(int id) const;
101 int parameterChanged(const EffectParameter &param,
102 const QVariant &value);
103
104protected:
105 QScopedPointer<CAudioEffect> m_effect;
106
107private:
108 const QList<EffectParameter> m_params;
109 AbstractMediaPlayer * m_player;
110 QHash<int, QVariant> m_values;
111};
112
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#ifdef Q_CC_NOKIAX86
122# pragma warn_illtokenpasting off
123#endif
124
125#define PHONON_MMF_DEFINE_EFFECT_FUNCTIONS(Effect) \
126 \
127void Effect##::createEffect(AudioPlayer::NativePlayer *player) \
128{ \
129 C##Effect *ptr = 0; \
130 QT_TRAP_THROWING(ptr = C##Effect::NewL(*player)); \
131 m_effect.reset(ptr); \
132} \
133 \
134C##Effect* Effect::concreteEffect() \
135{ \
136 return static_cast<C##Effect *>(m_effect.data()); \
137}
138
139QT_END_NAMESPACE
140
141#endif
142
Note: See TracBrowser for help on using the repository browser.