source: trunk/src/3rdparty/phonon/mmf/abstractaudioeffect.cpp@ 561

Last change on this file since 561 was 561, checked in by Dmitry A. Kuminov, 16 years ago

trunk: Merged in qt 4.6.1 sources.

  • Property svn:eol-style set to native
File size: 2.6 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#include "mediaobject.h"
20
21#include "abstractaudioeffect.h"
22#include "audioplayer.h"
23#include "mmf_videoplayer.h"
24
25QT_BEGIN_NAMESPACE
26
27using namespace Phonon;
28using namespace Phonon::MMF;
29
30/*! \class MMF::AbstractAudioEffect
31 \internal
32*/
33
34/*! \namespace Phonon::MMF
35 \internal
36*/
37
38AbstractAudioEffect::AbstractAudioEffect(QObject *parent,
39 const QList<EffectParameter> &params)
40 : MediaNode::MediaNode(parent)
41 , m_player(0)
42 , m_params(params)
43{
44}
45
46QList<EffectParameter> AbstractAudioEffect::parameters() const
47{
48 return m_params;
49}
50
51QVariant AbstractAudioEffect::parameterValue(const EffectParameter &queriedParam) const
52{
53 const QVariant &val = m_values.value(queriedParam.id());
54
55 if (val.isNull())
56 return queriedParam.defaultValue();
57 else
58 return val;
59}
60
61void AbstractAudioEffect::setParameterValue(const EffectParameter &param,
62 const QVariant &newValue)
63{
64 m_values.insert(param.id(), newValue);
65 parameterChanged(param.id(), newValue);
66 // TODO: handle audio effect errors
67 TRAP_IGNORE(m_effect->ApplyL());
68}
69
70void AbstractAudioEffect::connectMediaObject(MediaObject *mediaObject)
71{
72 Q_ASSERT_X(!m_player, Q_FUNC_INFO, "Player already connected");
73 Q_ASSERT_X(!m_effect.data(), Q_FUNC_INFO, "Effect already created");
74
75 AbstractMediaPlayer *const player =
76 qobject_cast<AbstractMediaPlayer *>(mediaObject->abstractPlayer());
77
78 if (player) {
79 m_player = player;
80
81 if (AudioPlayer *audioPlayer = qobject_cast<AudioPlayer *>(player)) {
82 connectAudioPlayer(audioPlayer->nativePlayer());
83 applyParameters();
84 // TODO: handle audio effect errors
85 TRAP_IGNORE(m_effect->EnableL());
86 }
87 }
88}
89
90void AbstractAudioEffect::disconnectMediaObject(MediaObject * /*mediaObject*/)
91{
92 m_player = 0;
93 m_effect.reset();
94}
95
96QT_END_NAMESPACE
97
Note: See TracBrowser for help on using the repository browser.