From 7d3cdcb63c4030926ef5224d7e986de6d67da31b Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Tue, 8 Dec 2009 14:44:31 +0000 Subject: Fixed typo in Phonon::EffectWidget implementation Task-number: QTBUG-4659 Reviewed-by: trustme --- src/3rdparty/phonon/phonon/effectwidget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/3rdparty/phonon/phonon/effectwidget.cpp b/src/3rdparty/phonon/phonon/effectwidget.cpp index 2334d7f..b39299a 100644 --- a/src/3rdparty/phonon/phonon/effectwidget.cpp +++ b/src/3rdparty/phonon/phonon/effectwidget.cpp @@ -151,7 +151,7 @@ void EffectWidgetPrivate::autogenerateUi() bool minValueOk = false; bool maxValueOk = false; const int minValue = para.minimumValue().toInt(&minValueOk); - const int maxValue = para.minimumValue().toInt(&maxValueOk); + const int maxValue = para.maximumValue().toInt(&maxValueOk); sb->setRange(minValueOk ? minValue : DEFAULT_MIN_INT, maxValueOk ? maxValue : DEFAULT_MAX_INT); sb->setValue(value.toInt()); -- cgit v0.12 From d44c661d75ff6edcabf70b188b18bc991611628b Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Tue, 8 Dec 2009 17:18:17 +0000 Subject: Corrected parameter name ordering in internal Phonon MMF function signatures Some instances of the changeState signal declaration had the newState and oldState parameters in the wrong order. While this has no effect on the behaviour of the code, it can be confusing to developers reading it. Reviewed-by: trustme --- src/3rdparty/phonon/mmf/abstractplayer.h | 4 ++-- src/3rdparty/phonon/mmf/mediaobject.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/3rdparty/phonon/mmf/abstractplayer.h b/src/3rdparty/phonon/mmf/abstractplayer.h index 40ad7f8..dbcbe63 100644 --- a/src/3rdparty/phonon/mmf/abstractplayer.h +++ b/src/3rdparty/phonon/mmf/abstractplayer.h @@ -106,8 +106,8 @@ Q_SIGNALS: void finished(); void tick(qint64 time); void bufferStatus(int percentFilled); - void stateChanged(Phonon::State oldState, - Phonon::State newState); + void stateChanged(Phonon::State newState, + Phonon::State oldState); void metaDataChanged(const QMultiMap& metaData); void aboutToFinish(); void prefinishMarkReached(qint32 remaining); diff --git a/src/3rdparty/phonon/mmf/mediaobject.h b/src/3rdparty/phonon/mmf/mediaobject.h index 668b953..7d330e7 100644 --- a/src/3rdparty/phonon/mmf/mediaobject.h +++ b/src/3rdparty/phonon/mmf/mediaobject.h @@ -101,8 +101,8 @@ Q_SIGNALS: // TODO: emit metaDataChanged from MediaObject void metaDataChanged(const QMultiMap& metaData); void currentSourceChanged(const MediaSource& source); - void stateChanged(Phonon::State oldState, - Phonon::State newState); + void stateChanged(Phonon::State newState, + Phonon::State oldState); void finished(); void tick(qint64 time); -- cgit v0.12 From 4c95ec342c62183ecc3dffe50497b4858bc27c8d Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Fri, 8 Jan 2010 18:09:27 +0000 Subject: Implemented audio effects capability querying in Phonon MMF backend This patch addresses the following deficiencies in the existing implementation of audio effects: 1. Native effect objects (e.g. CAudioEqualizer, CBassBoost etc) were created frequently, just in order to check whether a given effect is supported, or retrieve the list of parameters which it requires. Although this is in part due to a deficiency in the S60 audio effects API (it doesn't have a 'capability query' concept), it can be improved by using caching. This patch introduces a singleton EffectFactory object, which lazily initializes a data structure containing information about support and parameters. 2. In order to either query effect support, the native effect object ultimately needs to access a DevSound instance. Previously, the effect object was provided with a CMdaAudioPlayerUtility object. If this player utility has not loaded an MMF controller plugin *before* the effects object makes any calls to the player utility, incorrect results will be returned. This was observed in the previous code. For querying, we don't actually need to load an MMF controller; instead, we would like to directly provide a CMMFDevSound instance to the effect object. Unfortunately, this API is not available in public S60 SDKs, so we must use the next lowest interface available, namely CMdaAudioOutputStream. By making this change, this patch ensures that support and parameter queries made via the EffectFactory will return the correct result. At this point, however, effect settings made via the Phonon API are not actually applied to the audio output. Fixing this will require notifying the audio effects backend nodes of state changes in the MediaObject. Task-number: QTBUG-4659 Reviewed-by: Espen Riskedal --- src/3rdparty/phonon/mmf/abstractaudioeffect.cpp | 9 +- src/3rdparty/phonon/mmf/abstractaudioeffect.h | 12 -- src/3rdparty/phonon/mmf/audioequalizer.cpp | 40 ++--- src/3rdparty/phonon/mmf/audioequalizer.h | 13 +- src/3rdparty/phonon/mmf/backend.cpp | 11 +- src/3rdparty/phonon/mmf/backend.h | 2 + src/3rdparty/phonon/mmf/bassboost.cpp | 21 ++- src/3rdparty/phonon/mmf/bassboost.h | 10 +- src/3rdparty/phonon/mmf/effectfactory.cpp | 189 +++++++++++++++--------- src/3rdparty/phonon/mmf/effectfactory.h | 50 +++++-- src/plugins/phonon/mmf/mmf.pro | 1 + 11 files changed, 226 insertions(+), 132 deletions(-) diff --git a/src/3rdparty/phonon/mmf/abstractaudioeffect.cpp b/src/3rdparty/phonon/mmf/abstractaudioeffect.cpp index e7ef9b2..c75c08e 100644 --- a/src/3rdparty/phonon/mmf/abstractaudioeffect.cpp +++ b/src/3rdparty/phonon/mmf/abstractaudioeffect.cpp @@ -37,10 +37,11 @@ using namespace Phonon::MMF; AbstractAudioEffect::AbstractAudioEffect(QObject *parent, const QList ¶ms) - : MediaNode::MediaNode(parent) + : MediaNode(parent) , m_player(0) , m_params(params) { + } QList AbstractAudioEffect::parameters() const @@ -63,8 +64,10 @@ void AbstractAudioEffect::setParameterValue(const EffectParameter ¶m, { m_values.insert(param.id(), newValue); parameterChanged(param.id(), newValue); - // TODO: handle audio effect errors - TRAP_IGNORE(m_effect->ApplyL()); + + if (m_effect.data()) + // TODO: handle audio effect errors + TRAP_IGNORE(m_effect->ApplyL()); } void AbstractAudioEffect::connectMediaObject(MediaObject *mediaObject) diff --git a/src/3rdparty/phonon/mmf/abstractaudioeffect.h b/src/3rdparty/phonon/mmf/abstractaudioeffect.h index 6f74a73..df1d08a 100644 --- a/src/3rdparty/phonon/mmf/abstractaudioeffect.h +++ b/src/3rdparty/phonon/mmf/abstractaudioeffect.h @@ -68,18 +68,6 @@ public: virtual void setParameterValue(const EffectParameter &, const QVariant &newValue); - enum Type - { - EffectAudioEqualizer = 1, - EffectBassBoost, - EffectDistanceAttenuation, - EffectEnvironmentalReverb, - EffectListenerOrientation, - EffectLoudness, - EffectSourceOrientation, - EffectStereoWidening - }; - protected: // MediaNode void connectMediaObject(MediaObject *mediaObject); diff --git a/src/3rdparty/phonon/mmf/audioequalizer.cpp b/src/3rdparty/phonon/mmf/audioequalizer.cpp index c2936c5..5aa659a 100644 --- a/src/3rdparty/phonon/mmf/audioequalizer.cpp +++ b/src/3rdparty/phonon/mmf/audioequalizer.cpp @@ -28,8 +28,10 @@ using namespace Phonon::MMF; \internal */ -AudioEqualizer::AudioEqualizer(QObject *parent) : AbstractAudioEffect::AbstractAudioEffect(parent, createParams()) +AudioEqualizer::AudioEqualizer(QObject *parent, const QList ¶meters) + : AbstractAudioEffect::AbstractAudioEffect(parent, parameters) { + } void AudioEqualizer::parameterChanged(const int pid, @@ -68,30 +70,32 @@ void AudioEqualizer::setBandLevel(int band, int level) TRAP_IGNORE(effect->SetBandLevelL(band, level)); } -QList AudioEqualizer::createParams() -{ - QList retval; - - // We temporarily create an AudioPlayer, and run the effect on it, so - // we can extract the readonly data we need. - AudioPlayer dummyPlayer; +//----------------------------------------------------------------------------- +// Static functions +//----------------------------------------------------------------------------- - CAudioEqualizer *eqPtr = 0; - QT_TRAP_THROWING(eqPtr = CAudioEqualizer::NewL(*dummyPlayer.nativePlayer())); - QScopedPointer e(eqPtr); +const char* AudioEqualizer::description() +{ + return "Audio equalizer"; +} +void AudioEqualizer::getParameters(NativeEffect *effect, + QList ¶meters) +{ TInt32 dbMin; TInt32 dbMax; - e->DbLevelLimits(dbMin, dbMax); + effect->DbLevelLimits(dbMin, dbMax); - const int bandCount = e->NumberOfBands(); + const int bandCount = effect->NumberOfBands(); - for (int i = 0; i < bandCount; ++i) { - const qint32 hz = e->CenterFrequency(i); + // For some reason, band IDs are 1-based, as opposed to the + // 0-based indices used in just about other Symbian API...! + for (int i = 1; i <= bandCount; ++i) { + const qint32 hz = effect->CenterFrequency(i); - const qint32 defVol = e->BandLevel(i); + const qint32 defVol = effect->BandLevel(i); - retval.append(EffectParameter(i, + parameters.append(EffectParameter(i, tr("Frequency band, %1 Hz").arg(hz), EffectParameter::LogarithmicHint, QVariant(qint32(defVol)), @@ -100,8 +104,6 @@ QList AudioEqualizer::createParams() QVariantList(), QString())); } - - return retval; } QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/audioequalizer.h b/src/3rdparty/phonon/mmf/audioequalizer.h index 10fe9ad..ee3d297 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 . #include "abstractaudioeffect.h" +class CAudioEqualizer; + QT_BEGIN_NAMESPACE namespace Phonon @@ -39,7 +41,13 @@ class AudioEqualizer : public AbstractAudioEffect { Q_OBJECT public: - AudioEqualizer(QObject *parent); + AudioEqualizer(QObject *parent, const QList ¶meters); + + // Static interface required by EffectFactory + static const char* description(); + typedef CAudioEqualizer NativeEffect; + static void getParameters(NativeEffect *effect, + QList ¶meters); protected: // AbstractAudioEffect @@ -50,9 +58,6 @@ protected: private: void setBandLevel(int band, int level); -private: - static QList createParams(); - }; } } diff --git a/src/3rdparty/phonon/mmf/backend.cpp b/src/3rdparty/phonon/mmf/backend.cpp index 0c07f66..3568a49 100644 --- a/src/3rdparty/phonon/mmf/backend.cpp +++ b/src/3rdparty/phonon/mmf/backend.cpp @@ -45,6 +45,7 @@ using namespace Phonon::MMF; Backend::Backend(QObject *parent) : QObject(parent) , m_ancestorMoveMonitor(new AncestorMoveMonitor(this)) + , m_effectFactory(new EffectFactory(this)) { TRACE_CONTEXT(Backend::Backend, EBackend); TRACE_ENTRY_0(); @@ -81,9 +82,9 @@ QObject *Backend::createObject(BackendInterface::Class c, QObject *parent, const { Q_ASSERT(args.count() == 1); Q_ASSERT(args.first().type() == QVariant::Int); - const AbstractAudioEffect::Type effect = AbstractAudioEffect::Type(args.first().toInt()); - - return EffectFactory::createAudioEffect(effect, parent); + const EffectFactory::Type type = + static_cast(args.first().toInt()); + return m_effectFactory->createAudioEffect(type, parent); } case VideoWidgetClass: result = new VideoWidget(m_ancestorMoveMonitor.data(), qobject_cast(parent)); @@ -105,7 +106,7 @@ QList Backend::objectDescriptionIndexes(ObjectDescriptionType type) const switch(type) { case EffectType: - retval.append(EffectFactory::effectIndexes()); + retval.append(m_effectFactory->effectIndexes()); break; case AudioOutputDeviceType: // We only have one possible output device, but we need at least @@ -126,7 +127,7 @@ QHash Backend::objectDescriptionProperties(ObjectDescripti switch (type) { case EffectType: - return EffectFactory::audioEffectDescriptions(AbstractAudioEffect::Type(index)); + return m_effectFactory->audioEffectDescriptions(EffectFactory::Type(index)); case AudioOutputDeviceType: return AudioOutput::audioOutputDescription(index); default: diff --git a/src/3rdparty/phonon/mmf/backend.h b/src/3rdparty/phonon/mmf/backend.h index 9e3d3b3..6b85625 100644 --- a/src/3rdparty/phonon/mmf/backend.h +++ b/src/3rdparty/phonon/mmf/backend.h @@ -20,6 +20,7 @@ along with this library. If not, see . #define PHONON_MMF_BACKEND_H #include "ancestormovemonitor.h" +#include "effectfactory.h" #include #include @@ -53,6 +54,7 @@ Q_SIGNALS: private: QScopedPointer m_ancestorMoveMonitor; + QScopedPointer m_effectFactory; }; } diff --git a/src/3rdparty/phonon/mmf/bassboost.cpp b/src/3rdparty/phonon/mmf/bassboost.cpp index ae96b45..4edd102 100644 --- a/src/3rdparty/phonon/mmf/bassboost.cpp +++ b/src/3rdparty/phonon/mmf/bassboost.cpp @@ -28,15 +28,16 @@ using namespace Phonon::MMF; \internal */ -BassBoost::BassBoost(QObject *parent) : AbstractAudioEffect::AbstractAudioEffect(parent, - QList()) +BassBoost::BassBoost(QObject *parent, const QList ¶meters) + : AbstractAudioEffect::AbstractAudioEffect(parent, parameters) { + } void BassBoost::parameterChanged(const int, const QVariant &) { - Q_ASSERT_X(false, Q_FUNC_INFO, "BassBoost has not parameters"); + Q_ASSERT_X(false, Q_FUNC_INFO, "BassBoost has no parameters"); } void BassBoost::connectAudioPlayer(AudioPlayer::NativePlayer *player) @@ -51,5 +52,19 @@ void BassBoost::applyParameters() // No parameters to apply } +//----------------------------------------------------------------------------- +// Static functions +//----------------------------------------------------------------------------- + +const char* BassBoost::description() +{ + return "Bass boost"; +} + +void BassBoost::getParameters(NativeEffect*, QList&) +{ + +} + QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/bassboost.h b/src/3rdparty/phonon/mmf/bassboost.h index 4ad0a6c..c3c48d0 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 . #include "abstractaudioeffect.h" +class CBassBoost; + QT_BEGIN_NAMESPACE namespace Phonon @@ -37,7 +39,13 @@ class BassBoost : public AbstractAudioEffect { Q_OBJECT public: - BassBoost(QObject *parent); + BassBoost(QObject *parent, const QList ¶meters); + + // Static interface required by EffectFactory + static const char* description(); + typedef CBassBoost NativeEffect; + static void getParameters(NativeEffect *effect, + QList ¶meters); protected: // AbstractAudioEffect diff --git a/src/3rdparty/phonon/mmf/effectfactory.cpp b/src/3rdparty/phonon/mmf/effectfactory.cpp index cc94367..a8cbf24 100644 --- a/src/3rdparty/phonon/mmf/effectfactory.cpp +++ b/src/3rdparty/phonon/mmf/effectfactory.cpp @@ -30,6 +30,8 @@ along with this library. If not, see . #include #include +#include + #include "audioequalizer.h" #include "bassboost.h" @@ -44,111 +46,154 @@ using namespace Phonon::MMF; \internal */ -QHash EffectFactory::constructEffectDescription(const QString &name, - const QString &description) +EffectFactory::EffectFactory(QObject *parent) + : QObject(parent) + , m_initialized(false) { - QHash retval; - - retval.insert("name", name); - retval.insert("description", description); - retval.insert("available", true); - return retval; } - -QHash EffectFactory::audioEffectDescriptions(AbstractAudioEffect::Type type) +EffectFactory::~EffectFactory() { - switch (type) - { - case AbstractAudioEffect::EffectAudioEqualizer: - return constructEffectDescription(QCoreApplication::translate("Phonon::MMF::EffectFactory", "Audio Equalizer"), "Audio equalizer."); - case AbstractAudioEffect::EffectBassBoost: - return constructEffectDescription(QCoreApplication::translate("Phonon::MMF::EffectFactory", "Bass Boost"), "Bass boost."); - case AbstractAudioEffect::EffectDistanceAttenuation: - return constructEffectDescription(QCoreApplication::translate("Phonon::MMF::EffectFactory", "Distance Attenuation"), "Distance Attenuation."); - case AbstractAudioEffect::EffectEnvironmentalReverb: - return constructEffectDescription(QCoreApplication::translate("Phonon::MMF::EffectFactory", "Environmental Reverb"), "Environmental Reverb."); - case AbstractAudioEffect::EffectListenerOrientation: - return constructEffectDescription(QCoreApplication::translate("Phonon::MMF::EffectFactory", "Environmental Reverb"), "Environmental Reverb."); - case AbstractAudioEffect::EffectLoudness: - return constructEffectDescription(QCoreApplication::translate("Phonon::MMF::EffectFactory", "Loudness"), "Loudness."); - case AbstractAudioEffect::EffectSourceOrientation: - return constructEffectDescription(QCoreApplication::translate("Phonon::MMF::EffectFactory", "Source Orientation"), "Source Orientation."); - case AbstractAudioEffect::EffectStereoWidening: - return constructEffectDescription(QCoreApplication::translate("Phonon::MMF::EffectFactory", "Stereo Widening"), "Stereo Widening."); - } - Q_ASSERT_X(false, Q_FUNC_INFO, "Unknown effect type."); - return QHash(); } -AbstractAudioEffect *EffectFactory::createAudioEffect(AbstractAudioEffect::Type type, +//----------------------------------------------------------------------------- +// Public functions +//----------------------------------------------------------------------------- + +AbstractAudioEffect *EffectFactory::createAudioEffect(Type type, QObject *parent) { + // Lazily initialize + if (!m_initialized) + initialize(); + Q_ASSERT(parent); + const QList& parameters = data(type).m_parameters; + + AbstractAudioEffect *effect = 0; + switch (type) { - case AbstractAudioEffect::EffectBassBoost: - return new BassBoost(parent); - case AbstractAudioEffect::EffectAudioEqualizer: - return new AudioEqualizer(parent); - case AbstractAudioEffect::EffectDistanceAttenuation: - case AbstractAudioEffect::EffectEnvironmentalReverb: - case AbstractAudioEffect::EffectListenerOrientation: - case AbstractAudioEffect::EffectLoudness: - case AbstractAudioEffect::EffectSourceOrientation: - case AbstractAudioEffect::EffectStereoWidening: - ; + case TypeBassBoost: + effect = new BassBoost(parent, parameters); + case TypeAudioEqualizer: + effect = new AudioEqualizer(parent, parameters); + case TypeDistanceAttenuation: + case TypeEnvironmentalReverb: + case TypeListenerOrientation: + case TypeLoudness: + case TypeSourceOrientation: + case TypeStereoWidening: + break; + default: + Q_ASSERT_X(false, Q_FUNC_INFO, "Unknown effect"); } - Q_ASSERT_X(false, Q_FUNC_INFO, "Unknown effect."); - return 0; + return effect; } -template -bool isEffectSupported() +QHash EffectFactory::audioEffectDescriptions(Type type) { - AudioPlayer audioPlayer; - - QScopedPointer eff; - TRAPD(errorCode, eff.reset(TEffect::NewL(*audioPlayer.nativePlayer()))); + // Lazily initialize + if (!m_initialized) + initialize(); - return errorCode != KErrNone; + return data(type).m_descriptions; } QList EffectFactory::effectIndexes() { - QList retval; + // Lazily initialize + if (!m_initialized) + initialize(); + + QList result; - if (isEffectSupported()) - retval.append(AbstractAudioEffect::EffectAudioEqualizer); + QHash::const_iterator i = m_effectData.begin(); + for ( ; i != m_effectData.end(); ++i) + if (i.value().m_supported) + result.append(i.key()); - if (isEffectSupported()) - retval.append(AbstractAudioEffect::EffectBassBoost); + return result; +} + +//----------------------------------------------------------------------------- +// Private functions +//----------------------------------------------------------------------------- - /* We haven't implemented these yet. - if (isEffectSupported()) - retval.append(AbstractAudioEffect::EffectDistanceAttenuation); +#define INITIALIZE_EFFECT(Effect) \ + { \ + EffectData data = getData(); \ + m_effectData.insert(Type##Effect, data); \ + } - if (isEffectSupported()) - retval.append(AbstractAudioEffect::EffectEnvironmentalReverb); +void EffectFactory::initialize() +{ + Q_ASSERT_X(!m_initialized, Q_FUNC_INFO, "Already initialized"); - if (isEffectSupported()) - retval.append(AbstractAudioEffect::EffectLoudness); + INITIALIZE_EFFECT(AudioEqualizer) + //INITIALIZE_EFFECT(BassBoost) - if (isEffectSupported()) - retval.append(AbstractAudioEffect::EffectListenerOrientation); + m_initialized = true; +} - if (isEffectSupported()) - retval.append(AbstractAudioEffect::EffectSourceOrientation); +// This class is just a wrapper which allows us to instantiate a +// CMdaAudioOutputStream object. This is done in order to allow the +// effects API to query the DevSound implementation, to discover +// which effects are supported and what parameters they take. +// Ideally, we would use CMMFDevSound directly, but this class is not +// available in the public S60 SDK. +class OutputStreamFactory : public MMdaAudioOutputStreamCallback +{ +public: + CMdaAudioOutputStream* create() + { + CMdaAudioOutputStream* stream = 0; + QT_TRAP_THROWING(stream = CMdaAudioOutputStream::NewL(*this)); + return stream; + } +private: + void MaoscOpenComplete(TInt /*aError*/) { } + void MaoscBufferCopied(TInt /*aError*/, const TDesC8& /*aBuffer*/) { } + void MaoscPlayComplete(TInt /*aError*/) { } +}; + +template +EffectFactory::EffectData EffectFactory::getData() +{ + EffectData data; + + // Create a temporary CMdaAudioOutputStream object, so that the effects + // API can query DevSound to discover which effects are supported. + OutputStreamFactory streamFactory; + QScopedPointer stream(streamFactory.create()); + + typedef typename BackendNode::NativeEffect NativeEffect; + QScopedPointer effect; + TRAPD(err, effect.reset(NativeEffect::NewL(*stream))); + data.m_supported = (KErrNone == err); + + if (KErrNone == err) { + const QString description = QCoreApplication::translate + ("Phonon::MMF::EffectFactory", BackendNode::description()); + data.m_descriptions.insert("name", description); + data.m_descriptions.insert("description", description); + data.m_descriptions.insert("available", true); + + BackendNode::getParameters(effect.data(), data.m_parameters); + } - if (isEffectSupported()) - retval.append(AbstractAudioEffect::EffectStereoWidening); - */ + return data; +} - return retval; +const EffectFactory::EffectData& EffectFactory::data(Type type) const +{ + QHash::const_iterator i = m_effectData.find(type); + Q_ASSERT_X(i != m_effectData.end(), Q_FUNC_INFO, "Effect data not found"); + return i.value(); } QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/effectfactory.h b/src/3rdparty/phonon/mmf/effectfactory.h index e83ad15..45bd0f0 100644 --- a/src/3rdparty/phonon/mmf/effectfactory.h +++ b/src/3rdparty/phonon/mmf/effectfactory.h @@ -31,14 +31,30 @@ namespace MMF /** * @short Contains utility functions related to effects. */ -class EffectFactory +class EffectFactory : public QObject { + Q_OBJECT + public: + EffectFactory(QObject *parent); + ~EffectFactory(); + + enum Type + { + TypeAudioEqualizer = 0 + , TypeBassBoost + , TypeDistanceAttenuation + , TypeEnvironmentalReverb + , TypeListenerOrientation + , TypeLoudness + , TypeSourceOrientation + , TypeStereoWidening + }; + /** * @short Creates an audio effect of type @p type. */ - static AbstractAudioEffect *createAudioEffect(AbstractAudioEffect::Type type, - QObject *parent); + AbstractAudioEffect *createAudioEffect(Type type, QObject *parent); /** * @short Return the properties for effect @p type. @@ -46,7 +62,7 @@ public: * This handles the effects for * BackendInterface::objectDescriptionProperties(). */ - static QHash audioEffectDescriptions(AbstractAudioEffect::Type type); + QHash audioEffectDescriptions(Type type); /** * @short Returns the indexes for the supported effects. @@ -54,19 +70,27 @@ public: * This handles the effects for * BackendInterface::objectDescriptionIndexes(). */ - static QList effectIndexes(); + QList effectIndexes(); private: - static inline QHash constructEffectDescription(const QString &name, - const QString &description); + void initialize(); + + struct EffectData + { + bool m_supported; + QHash m_descriptions; + QList m_parameters; + }; + + template EffectData getData(); + const EffectData& data(Type type) const; + +private: + bool m_initialized; + QHash m_effectData; - /** - * This class is not supposed to be instantiated, so disable - * the default constructor. - */ - inline EffectFactory(); - Q_DISABLE_COPY(EffectFactory) }; + } } diff --git a/src/plugins/phonon/mmf/mmf.pro b/src/plugins/phonon/mmf/mmf.pro index 854f893..65a7a29 100644 --- a/src/plugins/phonon/mmf/mmf.pro +++ b/src/plugins/phonon/mmf/mmf.pro @@ -81,6 +81,7 @@ LIBS += -lws32 # For RWindow LIBS += -lefsrv # For file server LIBS += -lapgrfx -lapmime # For recognizer LIBS += -lmmfcontrollerframework # For CMMFMetaDataEntry +LIBS += -lmediaclientaudiostream # For CMdaAudioOutputStream # These are for effects. LIBS += -lAudioEqualizerEffect -lBassBoostEffect -lDistanceAttenuationEffect -lDopplerBase -lEffectBase -lEnvironmentalReverbEffect -lListenerDopplerEffect -lListenerLocationEffect -lListenerOrientationEffect -lLocationBase -lLoudnessEffect -lOrientationBase -lSourceDopplerEffect -lSourceLocationEffect -lSourceOrientationEffect -lStereoWideningEffect -- cgit v0.12 From af7a0cbe4d6dcbae5d16e91d488df5a5dc8919c2 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Tue, 8 Dec 2009 14:39:51 +0000 Subject: Shortened description of audio equalizer bands This improves the small-screen layout of the equalizer configuration dialog. Task-number: QTBUG-4659 Reviewed-by: trustme --- src/3rdparty/phonon/mmf/audioequalizer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/3rdparty/phonon/mmf/audioequalizer.cpp b/src/3rdparty/phonon/mmf/audioequalizer.cpp index 5aa659a..37ba328 100644 --- a/src/3rdparty/phonon/mmf/audioequalizer.cpp +++ b/src/3rdparty/phonon/mmf/audioequalizer.cpp @@ -96,7 +96,7 @@ void AudioEqualizer::getParameters(NativeEffect *effect, const qint32 defVol = effect->BandLevel(i); parameters.append(EffectParameter(i, - tr("Frequency band, %1 Hz").arg(hz), + tr("%1 Hz").arg(hz), EffectParameter::LogarithmicHint, QVariant(qint32(defVol)), QVariant(qint32(dbMin)), -- cgit v0.12 From e4f2a7f7aae733df87a60f0e9b32dd4d4f6ddcd0 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Tue, 8 Dec 2009 14:41:31 +0000 Subject: Added comments to clarify usage of Phonon::EffectParameter API Task-number: QTBUG-4659 Reviewed-by: trustme --- src/3rdparty/phonon/mmf/audioequalizer.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/3rdparty/phonon/mmf/audioequalizer.cpp b/src/3rdparty/phonon/mmf/audioequalizer.cpp index 37ba328..5a1ce19 100644 --- a/src/3rdparty/phonon/mmf/audioequalizer.cpp +++ b/src/3rdparty/phonon/mmf/audioequalizer.cpp @@ -95,14 +95,15 @@ void AudioEqualizer::getParameters(NativeEffect *effect, const qint32 defVol = effect->BandLevel(i); - parameters.append(EffectParameter(i, - tr("%1 Hz").arg(hz), - EffectParameter::LogarithmicHint, - QVariant(qint32(defVol)), - QVariant(qint32(dbMin)), - QVariant(qint32(dbMax)), - QVariantList(), - QString())); + parameters.append(EffectParameter( + /* parameterId */ i, + /* name */ tr("%1 Hz").arg(hz), + /* hints */ EffectParameter::LogarithmicHint, + /* defaultValue */ QVariant(qint32(defVol)), + /* minimumValue */ QVariant(qint32(dbMin)), + /* maximumValue */ QVariant(qint32(dbMax)), + /* values */ QVariantList(), + /* description */ QString())); } } -- cgit v0.12 From 483893142dcec15c646ef997309dcede76466766 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Mon, 11 Jan 2010 15:03:29 +0000 Subject: Modified effect parameter handling to improve user experience This change is to work around a limitation in the Phonon::EffectWidget class. This widget only displays sliders for parameters with numeric values if the variant type of the parameter is QReal and the range is exactly -1.0 to +1.0; otherwise, a spinbox is displayed. This is rather inconvenient for many effects, such as the audio equalizer, for which a slider is a much more natural UI control. The MMF backend therefore reports the type of numeric parameters to be QReal, and the range to be -1.0 to +1.0. Internally, the integer range for the parameter is stored. Changes to the parameter value are converted from the client-side, floating point representation to the internal, integer representation. Task-number: QTBUG-4659 Reviewed-by: Espen Riskedal --- src/3rdparty/phonon/mmf/abstractaudioeffect.cpp | 15 ++++-- src/3rdparty/phonon/mmf/abstractaudioeffect.h | 11 ++-- src/3rdparty/phonon/mmf/audioequalizer.cpp | 30 +++++++---- src/3rdparty/phonon/mmf/audioequalizer.h | 2 +- src/3rdparty/phonon/mmf/effectfactory.h | 1 + src/3rdparty/phonon/mmf/effectparameter.cpp | 63 ++++++++++++++++++++++ src/3rdparty/phonon/mmf/effectparameter.h | 72 +++++++++++++++++++++++++ src/3rdparty/phonon/phonon/effectwidget.cpp | 2 +- src/plugins/phonon/mmf/mmf.pro | 2 + 9 files changed, 175 insertions(+), 23 deletions(-) create mode 100644 src/3rdparty/phonon/mmf/effectparameter.cpp create mode 100644 src/3rdparty/phonon/mmf/effectparameter.h diff --git a/src/3rdparty/phonon/mmf/abstractaudioeffect.cpp b/src/3rdparty/phonon/mmf/abstractaudioeffect.cpp index c75c08e..1939e04 100644 --- a/src/3rdparty/phonon/mmf/abstractaudioeffect.cpp +++ b/src/3rdparty/phonon/mmf/abstractaudioeffect.cpp @@ -38,18 +38,23 @@ using namespace Phonon::MMF; AbstractAudioEffect::AbstractAudioEffect(QObject *parent, const QList ¶ms) : MediaNode(parent) - , m_player(0) , m_params(params) + , m_player(0) { } -QList AbstractAudioEffect::parameters() const +QList AbstractAudioEffect::parameters() const { - return m_params; + // Convert from QList to QList + QList result; + EffectParameter param; + foreach (param, m_params) + result += param; + return result; } -QVariant AbstractAudioEffect::parameterValue(const EffectParameter &queriedParam) const +QVariant AbstractAudioEffect::parameterValue(const Phonon::EffectParameter &queriedParam) const { const QVariant &val = m_values.value(queriedParam.id()); @@ -59,7 +64,7 @@ QVariant AbstractAudioEffect::parameterValue(const EffectParameter &queriedParam return val; } -void AbstractAudioEffect::setParameterValue(const EffectParameter ¶m, +void AbstractAudioEffect::setParameterValue(const Phonon::EffectParameter ¶m, const QVariant &newValue) { m_values.insert(param.id(), newValue); diff --git a/src/3rdparty/phonon/mmf/abstractaudioeffect.h b/src/3rdparty/phonon/mmf/abstractaudioeffect.h index df1d08a..4772eb8 100644 --- a/src/3rdparty/phonon/mmf/abstractaudioeffect.h +++ b/src/3rdparty/phonon/mmf/abstractaudioeffect.h @@ -24,9 +24,9 @@ along with this library. If not, see . #include #include -#include #include "audioplayer.h" +#include "effectparameter.h" #include "mmf_medianode.h" #include "mmf_videoplayer.h" @@ -63,9 +63,10 @@ public: 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); protected: @@ -81,10 +82,10 @@ protected: protected: QScopedPointer m_effect; + const QList m_params; private: AbstractMediaPlayer * m_player; - const QList m_params; QHash m_values; }; diff --git a/src/3rdparty/phonon/mmf/audioequalizer.cpp b/src/3rdparty/phonon/mmf/audioequalizer.cpp index 5a1ce19..adbe6c8 100644 --- a/src/3rdparty/phonon/mmf/audioequalizer.cpp +++ b/src/3rdparty/phonon/mmf/audioequalizer.cpp @@ -39,7 +39,7 @@ void AudioEqualizer::parameterChanged(const int pid, { if (m_effect.data()) { const int band = pid; - const int level = value.toInt(); + const qreal level = value.toReal(); setBandLevel(band, level); } } @@ -54,7 +54,7 @@ void AudioEqualizer::connectAudioPlayer(AudioPlayer::NativePlayer *player) void AudioEqualizer::applyParameters() { if (m_effect.data()) { - EffectParameter param; + Phonon::EffectParameter param; foreach (param, parameters()) { const int band = param.id(); const int level = parameterValue(param).toInt(); @@ -63,11 +63,14 @@ void AudioEqualizer::applyParameters() } } -void AudioEqualizer::setBandLevel(int band, int level) +void AudioEqualizer::setBandLevel(int band, qreal externalLevel) { + const EffectParameter ¶m = m_params[band]; + const int internalLevel = param.toInternalValue(externalLevel); + CAudioEqualizer *const effect = static_cast(m_effect.data()); // TODO: handle audio effect errors - TRAP_IGNORE(effect->SetBandLevelL(band, level)); + TRAP_IGNORE(effect->SetBandLevelL(band, internalLevel)); } //----------------------------------------------------------------------------- @@ -93,17 +96,22 @@ void AudioEqualizer::getParameters(NativeEffect *effect, for (int i = 1; i <= bandCount; ++i) { const qint32 hz = effect->CenterFrequency(i); - const qint32 defVol = effect->BandLevel(i); - - parameters.append(EffectParameter( + // We pass a floating-point parameter range of -1.0 to +1.0 for + // each band in order to work around a limitation in + // Phonon::EffectWidget. See documentation of EffectParameter + // for more details. + EffectParameter param( /* parameterId */ i, /* name */ tr("%1 Hz").arg(hz), /* hints */ EffectParameter::LogarithmicHint, - /* defaultValue */ QVariant(qint32(defVol)), - /* minimumValue */ QVariant(qint32(dbMin)), - /* maximumValue */ QVariant(qint32(dbMax)), + /* defaultValue */ QVariant(qreal(0.0)), + /* minimumValue */ QVariant(qreal(-1.0)), + /* maximumValue */ QVariant(qreal(+1.0)), /* values */ QVariantList(), - /* description */ QString())); + /* description */ QString()); + + param.setInternalRange(dbMin, dbMax); + parameters.append(param); } } diff --git a/src/3rdparty/phonon/mmf/audioequalizer.h b/src/3rdparty/phonon/mmf/audioequalizer.h index ee3d297..d10cbf3 100644 --- a/src/3rdparty/phonon/mmf/audioequalizer.h +++ b/src/3rdparty/phonon/mmf/audioequalizer.h @@ -56,7 +56,7 @@ protected: virtual void parameterChanged(const int id, const QVariant &value); private: - void setBandLevel(int band, int level); + void setBandLevel(int band, qreal externalLevel); }; } diff --git a/src/3rdparty/phonon/mmf/effectfactory.h b/src/3rdparty/phonon/mmf/effectfactory.h index 45bd0f0..dd4b58d 100644 --- a/src/3rdparty/phonon/mmf/effectfactory.h +++ b/src/3rdparty/phonon/mmf/effectfactory.h @@ -20,6 +20,7 @@ along with this library. If not, see . #define PHONON_MMF_EFFECTFACTORY_H #include "abstractaudioeffect.h" +#include "effectparameter.h" QT_BEGIN_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/effectparameter.cpp b/src/3rdparty/phonon/mmf/effectparameter.cpp new file mode 100644 index 0000000..f4287b8 --- /dev/null +++ b/src/3rdparty/phonon/mmf/effectparameter.cpp @@ -0,0 +1,63 @@ +/* This file is part of the KDE project. + +Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + +This library is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 or 3 of the License. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library. If not, see . + +*/ + +#include "effectparameter.h" + +QT_BEGIN_NAMESPACE + +using namespace Phonon; +using namespace Phonon::MMF; + +/*! \class MMF::EffectParameter + \internal +*/ + +MMF::EffectParameter::EffectParameter() + : m_hasInternalRange(false) +{ + +} + +MMF::EffectParameter::EffectParameter( + int parameterId, const QString &name, Hints hints, + const QVariant &defaultValue, const QVariant &min, + const QVariant &max, const QVariantList &values, + const QString &description) + : Phonon::EffectParameter(parameterId, name, hints, defaultValue, + min, max, values, description) + , m_hasInternalRange(false) +{ + +} + +void MMF::EffectParameter::setInternalRange(qint32 min, qint32 max) +{ + Q_ASSERT_X(max >= min, Q_FUNC_INFO, "Invalid range"); + m_internalRange = QPair(min, max); + m_hasInternalRange = true; +} + +qint32 MMF::EffectParameter::toInternalValue(qreal external) const +{ + Q_ASSERT_X(m_hasInternalRange, Q_FUNC_INFO, "Does not have internal range"); + const qint32 range = m_internalRange.second - m_internalRange.first; + return m_internalRange.first + ((1.0 + external) / 2) * range; +} + +QT_END_NAMESPACE + diff --git a/src/3rdparty/phonon/mmf/effectparameter.h b/src/3rdparty/phonon/mmf/effectparameter.h new file mode 100644 index 0000000..3008159 --- /dev/null +++ b/src/3rdparty/phonon/mmf/effectparameter.h @@ -0,0 +1,72 @@ +/* This file is part of the KDE project. + +Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + +This library is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 or 3 of the License. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library. If not, see . + +*/ + +#ifndef PHONON_MMF_EFFECTPARAMETER_H +#define PHONON_MMF_EFFECTPARAMETER_H + +#include + +QT_BEGIN_NAMESPACE + +namespace Phonon +{ +namespace MMF +{ + +/** + * @short Parameter value for an audio effect + * + * The base class is extended in order to work around a shortcoming + * in Phonon::EffectWidget. This widget only displays sliders for + * parameters with numeric values if the variant type of the parameter + * is QReal and the range is exactly -1.0 to +1.0; otherwise, a + * spinbox is used to set numeric parameters. This is rather + * inconvenient for many effects, such as the audio equalizer, for + * which a slider is a much more natural UI control. + * + * For many such parameters, we therefore report the type to be QReal + * and the range to be -1.0 to +1.0. This class stores the actual + * integer range for the parameter, and provides the toInternalValue + * function for converting between the client-side floating point + * value and the internal integer value. + */ +class EffectParameter : public Phonon::EffectParameter +{ +public: + EffectParameter(); + EffectParameter(int parameterId, const QString &name, Hints hints, + const QVariant &defaultValue, const QVariant &min = QVariant(), + const QVariant &max = QVariant(), const QVariantList &values = QVariantList(), + const QString &description = QString()); + + void setInternalRange(qint32 min, qint32 max); + qint32 toInternalValue(qreal external) const; + +private: + bool m_hasInternalRange; + QPair m_internalRange; + +}; + +} +} + +QT_END_NAMESPACE + +#endif + diff --git a/src/3rdparty/phonon/phonon/effectwidget.cpp b/src/3rdparty/phonon/phonon/effectwidget.cpp index b39299a..a2fe50f 100644 --- a/src/3rdparty/phonon/phonon/effectwidget.cpp +++ b/src/3rdparty/phonon/phonon/effectwidget.cpp @@ -15,7 +15,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU Lesser General Public + You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . */ diff --git a/src/plugins/phonon/mmf/mmf.pro b/src/plugins/phonon/mmf/mmf.pro index 65a7a29..f72a657 100644 --- a/src/plugins/phonon/mmf/mmf.pro +++ b/src/plugins/phonon/mmf/mmf.pro @@ -35,6 +35,7 @@ HEADERS += \ $$PHONON_MMF_DIR/defs.h \ $$PHONON_MMF_DIR/dummyplayer.h \ $$PHONON_MMF_DIR/effectfactory.h \ + $$PHONON_MMF_DIR/effectparameter.h \ $$PHONON_MMF_DIR/mediaobject.h \ $$PHONON_MMF_DIR/mmf_medianode.h \ $$PHONON_MMF_DIR/mmf_videoplayer.h \ @@ -57,6 +58,7 @@ SOURCES += \ $$PHONON_MMF_DIR/bassboost.cpp \ $$PHONON_MMF_DIR/dummyplayer.cpp \ $$PHONON_MMF_DIR/effectfactory.cpp \ + $$PHONON_MMF_DIR/effectparameter.cpp \ $$PHONON_MMF_DIR/mediaobject.cpp \ $$PHONON_MMF_DIR/mmf_medianode.cpp \ $$PHONON_MMF_DIR/mmf_videoplayer.cpp \ -- cgit v0.12 From e53306725e52407146304df9d8d3a65920fc3e8d Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Mon, 11 Jan 2010 15:30:15 +0000 Subject: Delayed creation of audio effect object until audio is initialized When applying effects to an audio stream, we must ensure that the MMF utility API (CMdaAudioPlayerUtility or CVideoPlayerUtility) instance has loaded a controller before calling attempting to create a CAudioEffect- derived object. If the controller has not been loaded, construction of the effect object will fail. Even if we mitigate against this, calling CAudioEffect::ApplyL() will only have an effect if there is a controller object - or more precisely, a DevSound instance - on which to apply the effect. This patch delays construction of the effect object until the MediaObject has transitioned out of the LoadingState, indicating that an underlying DevSound instance will have been created. Task-number: QTBUG-4659 Reviewed-by: Espen Riskedal --- src/3rdparty/phonon/mmf/abstractaudioeffect.cpp | 59 ++++++++++++++++++------- src/3rdparty/phonon/mmf/abstractaudioeffect.h | 11 ++++- src/3rdparty/phonon/mmf/audioequalizer.cpp | 6 +-- src/3rdparty/phonon/mmf/audioequalizer.h | 2 +- src/3rdparty/phonon/mmf/bassboost.cpp | 2 +- src/3rdparty/phonon/mmf/bassboost.h | 2 +- src/3rdparty/phonon/mmf/mediaobject.cpp | 3 ++ src/3rdparty/phonon/mmf/mediaobject.h | 1 + 8 files changed, 63 insertions(+), 23 deletions(-) diff --git a/src/3rdparty/phonon/mmf/abstractaudioeffect.cpp b/src/3rdparty/phonon/mmf/abstractaudioeffect.cpp index 1939e04..cdddf02 100644 --- a/src/3rdparty/phonon/mmf/abstractaudioeffect.cpp +++ b/src/3rdparty/phonon/mmf/abstractaudioeffect.cpp @@ -68,11 +68,26 @@ void AbstractAudioEffect::setParameterValue(const Phonon::EffectParameter ¶m const QVariant &newValue) { m_values.insert(param.id(), newValue); - parameterChanged(param.id(), newValue); - if (m_effect.data()) + if (m_effect.data()) { + parameterChanged(param.id(), newValue); // TODO: handle audio effect errors TRAP_IGNORE(m_effect->ApplyL()); + } +} + +void AbstractAudioEffect::abstractPlayerChanged(AbstractPlayer *player) +{ + m_player = qobject_cast(player); + m_effect.reset(); +} + +void AbstractAudioEffect::stateChanged(Phonon::State newState, + Phonon::State oldState) +{ + if (Phonon::LoadingState == oldState + && Phonon::LoadingState != newState) + createEffect(); } void AbstractAudioEffect::connectMediaObject(MediaObject *mediaObject) @@ -80,25 +95,37 @@ void AbstractAudioEffect::connectMediaObject(MediaObject *mediaObject) Q_ASSERT_X(!m_player, Q_FUNC_INFO, "Player already connected"); Q_ASSERT_X(!m_effect.data(), Q_FUNC_INFO, "Effect already created"); - AbstractMediaPlayer *const player = - qobject_cast(mediaObject->abstractPlayer()); + abstractPlayerChanged(mediaObject->abstractPlayer()); - if (player) { - m_player = player; + connect(mediaObject, SIGNAL(stateChanged(Phonon::State, Phonon::State)), + SLOT(stateChanged(Phonon::State, Phonon::State))); - if (AudioPlayer *audioPlayer = qobject_cast(player)) { - connectAudioPlayer(audioPlayer->nativePlayer()); - applyParameters(); - // TODO: handle audio effect errors - TRAP_IGNORE(m_effect->EnableL()); - } - } + connect(mediaObject, SIGNAL(abstractPlayerChanged(AbstractPlayer *)), + SLOT(abstractPlayerChanged(AbstractPlayer *))); + + if (mediaObject->state() != Phonon::LoadingState) + createEffect(); } -void AbstractAudioEffect::disconnectMediaObject(MediaObject * /*mediaObject*/) +void AbstractAudioEffect::disconnectMediaObject(MediaObject *mediaObject) { - m_player = 0; - m_effect.reset(); + mediaObject->disconnect(this); + abstractPlayerChanged(0); +} + +void AbstractAudioEffect::createEffect() +{ + Q_ASSERT_X(m_player, Q_FUNC_INFO, "Invalid media player pointer"); + + if (AudioPlayer *audioPlayer = qobject_cast(m_player)) { + createEffect(audioPlayer->nativePlayer()); + } + + if (m_effect.data()) { + applyParameters(); + // TODO: handle audio effect errors + TRAP_IGNORE(m_effect->EnableL()); + } } QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/abstractaudioeffect.h b/src/3rdparty/phonon/mmf/abstractaudioeffect.h index 4772eb8..7d44bf0 100644 --- a/src/3rdparty/phonon/mmf/abstractaudioeffect.h +++ b/src/3rdparty/phonon/mmf/abstractaudioeffect.h @@ -36,6 +36,7 @@ namespace Phonon { namespace MMF { +class AbstractPlayer; class AbstractMediaPlayer; /** @@ -69,17 +70,25 @@ public: virtual void setParameterValue(const Phonon::EffectParameter &, const QVariant &newValue); +public Q_SLOTS: + void abstractPlayerChanged(AbstractPlayer *player); + void stateChanged(Phonon::State newState, + Phonon::State oldState); + protected: // MediaNode void connectMediaObject(MediaObject *mediaObject); void disconnectMediaObject(MediaObject *mediaObject); - virtual void connectAudioPlayer(AudioPlayer::NativePlayer *player) = 0; + virtual void createEffect(AudioPlayer::NativePlayer *player) = 0; virtual void applyParameters() = 0; virtual void parameterChanged(const int id, const QVariant &value) = 0; +private: + void createEffect(); + protected: QScopedPointer m_effect; const QList m_params; diff --git a/src/3rdparty/phonon/mmf/audioequalizer.cpp b/src/3rdparty/phonon/mmf/audioequalizer.cpp index adbe6c8..b41eda4 100644 --- a/src/3rdparty/phonon/mmf/audioequalizer.cpp +++ b/src/3rdparty/phonon/mmf/audioequalizer.cpp @@ -44,7 +44,7 @@ void AudioEqualizer::parameterChanged(const int pid, } } -void AudioEqualizer::connectAudioPlayer(AudioPlayer::NativePlayer *player) +void AudioEqualizer::createEffect(AudioPlayer::NativePlayer *player) { CAudioEqualizer *ptr = 0; QT_TRAP_THROWING(ptr = CAudioEqualizer::NewL(*player)); @@ -57,7 +57,7 @@ void AudioEqualizer::applyParameters() Phonon::EffectParameter param; foreach (param, parameters()) { const int band = param.id(); - const int level = parameterValue(param).toInt(); + const qreal level = parameterValue(param).toReal(); setBandLevel(band, level); } } @@ -65,7 +65,7 @@ void AudioEqualizer::applyParameters() void AudioEqualizer::setBandLevel(int band, qreal externalLevel) { - const EffectParameter ¶m = m_params[band]; + const EffectParameter ¶m = m_params[band-1]; // Band IDs are 1-based const int internalLevel = param.toInternalValue(externalLevel); CAudioEqualizer *const effect = static_cast(m_effect.data()); diff --git a/src/3rdparty/phonon/mmf/audioequalizer.h b/src/3rdparty/phonon/mmf/audioequalizer.h index d10cbf3..22fa1e8 100644 --- a/src/3rdparty/phonon/mmf/audioequalizer.h +++ b/src/3rdparty/phonon/mmf/audioequalizer.h @@ -51,7 +51,7 @@ public: protected: // AbstractAudioEffect - virtual void connectAudioPlayer(AudioPlayer::NativePlayer *player); + virtual void createEffect(AudioPlayer::NativePlayer *player); virtual void applyParameters(); virtual void parameterChanged(const int id, const QVariant &value); diff --git a/src/3rdparty/phonon/mmf/bassboost.cpp b/src/3rdparty/phonon/mmf/bassboost.cpp index 4edd102..9f62ecc 100644 --- a/src/3rdparty/phonon/mmf/bassboost.cpp +++ b/src/3rdparty/phonon/mmf/bassboost.cpp @@ -40,7 +40,7 @@ void BassBoost::parameterChanged(const int, Q_ASSERT_X(false, Q_FUNC_INFO, "BassBoost has no parameters"); } -void BassBoost::connectAudioPlayer(AudioPlayer::NativePlayer *player) +void BassBoost::createEffect(AudioPlayer::NativePlayer *player) { CBassBoost *ptr = 0; QT_TRAP_THROWING(ptr = CBassBoost::NewL(*player)); diff --git a/src/3rdparty/phonon/mmf/bassboost.h b/src/3rdparty/phonon/mmf/bassboost.h index c3c48d0..9f3d764 100644 --- a/src/3rdparty/phonon/mmf/bassboost.h +++ b/src/3rdparty/phonon/mmf/bassboost.h @@ -49,7 +49,7 @@ public: protected: // AbstractAudioEffect - virtual void connectAudioPlayer(AudioPlayer::NativePlayer *player); + virtual void createEffect(AudioPlayer::NativePlayer *player); virtual void applyParameters(); virtual void parameterChanged(const int id, const QVariant &value); diff --git a/src/3rdparty/phonon/mmf/mediaobject.cpp b/src/3rdparty/phonon/mmf/mediaobject.cpp index 4653fee..9744774 100644 --- a/src/3rdparty/phonon/mmf/mediaobject.cpp +++ b/src/3rdparty/phonon/mmf/mediaobject.cpp @@ -297,7 +297,10 @@ void MMF::MediaObject::createPlayer(const MediaSource &source) break; } + if (oldPlayer) + emit abstractPlayerChanged(0); m_player.reset(newPlayer); + emit abstractPlayerChanged(newPlayer); if (oldPlayerHasVideo != hasVideo()) { emit hasVideoChanged(hasVideo()); diff --git a/src/3rdparty/phonon/mmf/mediaobject.h b/src/3rdparty/phonon/mmf/mediaobject.h index 7d330e7..c87d755 100644 --- a/src/3rdparty/phonon/mmf/mediaobject.h +++ b/src/3rdparty/phonon/mmf/mediaobject.h @@ -92,6 +92,7 @@ public Q_SLOTS: void switchToNextSource(); Q_SIGNALS: + void abstractPlayerChanged(AbstractPlayer *player); void totalTimeChanged(qint64 length); void hasVideoChanged(bool hasVideo); void seekableChanged(bool seekable); -- cgit v0.12 From 894bb6e1742b75312feb7a18d043a67a3dba4cb9 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Mon, 11 Jan 2010 15:38:07 +0000 Subject: Removed dependency of EffectFactory on native effect headers By refactoring the static capabilities / parameters interface exposed by AbstractAudioEffect-derived classes to the EffectFactory, the latter's implementation no longer needs access to the headers for native effect classes. Previously, during the initialization phase, the EffectFactory tried to create an instance of each native effect class, in order to determine whether that effect is supported. This is now done inside the backend class for each effect, thereby improving encapsulation. Task-number: QTBUG-4659 Reviewed-by: Espen Riskedal --- src/3rdparty/phonon/mmf/abstractaudioeffect.h | 2 + src/3rdparty/phonon/mmf/audioequalizer.cpp | 67 +++++++++++++++------------ src/3rdparty/phonon/mmf/audioequalizer.h | 7 +-- src/3rdparty/phonon/mmf/bassboost.cpp | 4 +- src/3rdparty/phonon/mmf/bassboost.h | 7 +-- src/3rdparty/phonon/mmf/effectfactory.cpp | 21 +-------- 6 files changed, 48 insertions(+), 60 deletions(-) diff --git a/src/3rdparty/phonon/mmf/abstractaudioeffect.h b/src/3rdparty/phonon/mmf/abstractaudioeffect.h index 7d44bf0..9e5a6eb 100644 --- a/src/3rdparty/phonon/mmf/abstractaudioeffect.h +++ b/src/3rdparty/phonon/mmf/abstractaudioeffect.h @@ -30,6 +30,8 @@ along with this library. If not, see . #include "mmf_medianode.h" #include "mmf_videoplayer.h" +class CMdaAudioOutputStream; + QT_BEGIN_NAMESPACE namespace Phonon diff --git a/src/3rdparty/phonon/mmf/audioequalizer.cpp b/src/3rdparty/phonon/mmf/audioequalizer.cpp index b41eda4..a4127c4 100644 --- a/src/3rdparty/phonon/mmf/audioequalizer.cpp +++ b/src/3rdparty/phonon/mmf/audioequalizer.cpp @@ -82,37 +82,46 @@ const char* AudioEqualizer::description() return "Audio equalizer"; } -void AudioEqualizer::getParameters(NativeEffect *effect, - QList ¶meters) +bool AudioEqualizer::getParameters(CMdaAudioOutputStream *stream, + QList& parameters) { - TInt32 dbMin; - TInt32 dbMax; - effect->DbLevelLimits(dbMin, dbMax); - - const int bandCount = effect->NumberOfBands(); - - // For some reason, band IDs are 1-based, as opposed to the - // 0-based indices used in just about other Symbian API...! - for (int i = 1; i <= bandCount; ++i) { - const qint32 hz = effect->CenterFrequency(i); - - // We pass a floating-point parameter range of -1.0 to +1.0 for - // each band in order to work around a limitation in - // Phonon::EffectWidget. See documentation of EffectParameter - // for more details. - EffectParameter param( - /* parameterId */ i, - /* name */ tr("%1 Hz").arg(hz), - /* hints */ EffectParameter::LogarithmicHint, - /* defaultValue */ QVariant(qreal(0.0)), - /* minimumValue */ QVariant(qreal(-1.0)), - /* maximumValue */ QVariant(qreal(+1.0)), - /* values */ QVariantList(), - /* description */ QString()); - - param.setInternalRange(dbMin, dbMax); - parameters.append(param); + bool supported = false; + + QScopedPointer effect; + TRAPD(err, effect.reset(CAudioEqualizer::NewL(*stream))); + + if (KErrNone == err) { + supported = true; + + TInt32 dbMin; + TInt32 dbMax; + effect->DbLevelLimits(dbMin, dbMax); + + const int bandCount = effect->NumberOfBands(); + + // For some reason, band IDs are 1-based, as opposed to the + // 0-based indices used in just about other Symbian API...! + for (int i = 1; i <= bandCount; ++i) { + const qint32 hz = effect->CenterFrequency(i); + + // We pass a floating-point parameter range of -1.0 to +1.0 for + // each band in order to work around a limitation in + // Phonon::EffectWidget. See documentation of EffectParameter + // for more details. + EffectParameter param( + /* parameterId */ i, + /* name */ tr("%1 Hz").arg(hz), + /* hints */ EffectParameter::LogarithmicHint, + /* defaultValue */ QVariant(qreal(0.0)), + /* minimumValue */ QVariant(qreal(-1.0)), + /* maximumValue */ QVariant(qreal(+1.0))); + + param.setInternalRange(dbMin, dbMax); + parameters.append(param); + } } + + return supported; } QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/audioequalizer.h b/src/3rdparty/phonon/mmf/audioequalizer.h index 22fa1e8..35592f4 100644 --- a/src/3rdparty/phonon/mmf/audioequalizer.h +++ b/src/3rdparty/phonon/mmf/audioequalizer.h @@ -21,8 +21,6 @@ along with this library. If not, see . #include "abstractaudioeffect.h" -class CAudioEqualizer; - QT_BEGIN_NAMESPACE namespace Phonon @@ -45,9 +43,8 @@ public: // Static interface required by EffectFactory static const char* description(); - typedef CAudioEqualizer NativeEffect; - static void getParameters(NativeEffect *effect, - QList ¶meters); + static bool getParameters(CMdaAudioOutputStream *stream, + QList& parameters); protected: // AbstractAudioEffect diff --git a/src/3rdparty/phonon/mmf/bassboost.cpp b/src/3rdparty/phonon/mmf/bassboost.cpp index 9f62ecc..642d782 100644 --- a/src/3rdparty/phonon/mmf/bassboost.cpp +++ b/src/3rdparty/phonon/mmf/bassboost.cpp @@ -61,9 +61,9 @@ const char* BassBoost::description() return "Bass boost"; } -void BassBoost::getParameters(NativeEffect*, QList&) +bool BassBoost::getParameters(CMdaAudioOutputStream *, QList&) { - + return true; } QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/bassboost.h b/src/3rdparty/phonon/mmf/bassboost.h index 9f3d764..241cda9 100644 --- a/src/3rdparty/phonon/mmf/bassboost.h +++ b/src/3rdparty/phonon/mmf/bassboost.h @@ -21,8 +21,6 @@ along with this library. If not, see . #include "abstractaudioeffect.h" -class CBassBoost; - QT_BEGIN_NAMESPACE namespace Phonon @@ -43,9 +41,8 @@ public: // Static interface required by EffectFactory static const char* description(); - typedef CBassBoost NativeEffect; - static void getParameters(NativeEffect *effect, - QList ¶meters); + static bool getParameters(CMdaAudioOutputStream *stream, + QList& parameters); protected: // AbstractAudioEffect diff --git a/src/3rdparty/phonon/mmf/effectfactory.cpp b/src/3rdparty/phonon/mmf/effectfactory.cpp index a8cbf24..19c6d90 100644 --- a/src/3rdparty/phonon/mmf/effectfactory.cpp +++ b/src/3rdparty/phonon/mmf/effectfactory.cpp @@ -19,17 +19,6 @@ along with this library. If not, see . #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - #include #include "audioequalizer.h" @@ -171,19 +160,13 @@ EffectFactory::EffectData EffectFactory::getData() OutputStreamFactory streamFactory; QScopedPointer stream(streamFactory.create()); - typedef typename BackendNode::NativeEffect NativeEffect; - QScopedPointer effect; - TRAPD(err, effect.reset(NativeEffect::NewL(*stream))); - data.m_supported = (KErrNone == err); - - if (KErrNone == err) { + if (data.m_supported = BackendNode::getParameters + (stream.data(), data.m_parameters)) { const QString description = QCoreApplication::translate ("Phonon::MMF::EffectFactory", BackendNode::description()); data.m_descriptions.insert("name", description); data.m_descriptions.insert("description", description); data.m_descriptions.insert("available", true); - - BackendNode::getParameters(effect.data(), data.m_parameters); } return data; -- cgit v0.12 From 1a7234e3a27b592565241e9044919f7842fc5f08 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Mon, 11 Jan 2010 15:50:19 +0000 Subject: Added a macro to reduce boilerplate code in Phonon MMF backend Task-number: QTBUG-4659 Reviewed-by: Espen Riskedal --- src/3rdparty/phonon/mmf/abstractaudioeffect.h | 19 +++++++++++++++++++ src/3rdparty/phonon/mmf/audioequalizer.cpp | 15 +++++---------- src/3rdparty/phonon/mmf/audioequalizer.h | 3 +++ src/3rdparty/phonon/mmf/bassboost.cpp | 10 +++------- src/3rdparty/phonon/mmf/bassboost.h | 5 +++++ 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(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 ¶meters) +// Define functions which depend on concrete native effect class name +PHONON_MMF_DEFINE_EFFECT_FUNCTIONS(AudioEqualizer) + +AudioEqualizer::AudioEqualizer(QObject *parent, const QList& 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 ¶m = m_params[band-1]; // Band IDs are 1-based const int internalLevel = param.toInternalValue(externalLevel); - CAudioEqualizer *const effect = static_cast(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 . #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 . #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(); + }; } } -- cgit v0.12 From aefcf35b4e4dd62771b9fe531c84d35e13f2c660 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Tue, 8 Dec 2009 18:26:17 +0000 Subject: Removed unnecessary check in Phonon MMF backend This pointer is guaranteed not to be null by the check in AbstractAudioEffect::setParameterValue. Task-number: QTBUG-4659 Reviewed-by: trustme --- src/3rdparty/phonon/mmf/audioequalizer.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/3rdparty/phonon/mmf/audioequalizer.cpp b/src/3rdparty/phonon/mmf/audioequalizer.cpp index ab95f30..e3b1ab3 100644 --- a/src/3rdparty/phonon/mmf/audioequalizer.cpp +++ b/src/3rdparty/phonon/mmf/audioequalizer.cpp @@ -40,11 +40,9 @@ AudioEqualizer::AudioEqualizer(QObject *parent, const QList& pa void AudioEqualizer::parameterChanged(const int pid, const QVariant &value) { - if (m_effect.data()) { - const int band = pid; - const qreal level = value.toReal(); - setBandLevel(band, level); - } + const int band = pid; + const qreal level = value.toReal(); + setBandLevel(band, level); } void AudioEqualizer::applyParameters() -- cgit v0.12 From 99acb8f8e53767e59a5634609b0d3582ae5b0d7c Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Mon, 11 Jan 2010 16:05:17 +0000 Subject: Refactored AbstractAudioEffect to reduce redundancy in derived classes Task-number: QTBUG-4659 Reviewed-by: Espen Riskedal --- src/3rdparty/phonon/mmf/abstractaudioeffect.cpp | 21 +++++++++++++-- src/3rdparty/phonon/mmf/abstractaudioeffect.h | 6 ++--- src/3rdparty/phonon/mmf/audioequalizer.cpp | 35 +++++++------------------ src/3rdparty/phonon/mmf/audioequalizer.h | 5 ++-- src/3rdparty/phonon/mmf/bassboost.cpp | 7 +---- src/3rdparty/phonon/mmf/bassboost.h | 4 +-- 6 files changed, 37 insertions(+), 41 deletions(-) diff --git a/src/3rdparty/phonon/mmf/abstractaudioeffect.cpp b/src/3rdparty/phonon/mmf/abstractaudioeffect.cpp index cdddf02..3bce86b 100644 --- a/src/3rdparty/phonon/mmf/abstractaudioeffect.cpp +++ b/src/3rdparty/phonon/mmf/abstractaudioeffect.cpp @@ -70,7 +70,8 @@ void AbstractAudioEffect::setParameterValue(const Phonon::EffectParameter ¶m m_values.insert(param.id(), newValue); if (m_effect.data()) { - parameterChanged(param.id(), newValue); + const EffectParameter& internalParam = internalParameter(param.id()); + parameterChanged(internalParam, newValue); // TODO: handle audio effect errors TRAP_IGNORE(m_effect->ApplyL()); } @@ -122,11 +123,27 @@ void AbstractAudioEffect::createEffect() } if (m_effect.data()) { - applyParameters(); + EffectParameter param; + foreach (param, m_params) { + const QVariant value = parameterValue(param); + parameterChanged(param, value); + } + // TODO: handle audio effect errors TRAP_IGNORE(m_effect->EnableL()); } } +const MMF::EffectParameter& AbstractAudioEffect::internalParameter(int id) const +{ + const EffectParameter *result = 0; + for (int i=0; i m_effect; - const QList m_params; private: + const QList m_params; AbstractMediaPlayer * m_player; QHash m_values; }; diff --git a/src/3rdparty/phonon/mmf/audioequalizer.cpp b/src/3rdparty/phonon/mmf/audioequalizer.cpp index e3b1ab3..1584cf7 100644 --- a/src/3rdparty/phonon/mmf/audioequalizer.cpp +++ b/src/3rdparty/phonon/mmf/audioequalizer.cpp @@ -37,35 +37,18 @@ AudioEqualizer::AudioEqualizer(QObject *parent, const QList& pa } -void AudioEqualizer::parameterChanged(const int pid, +void AudioEqualizer::parameterChanged(const EffectParameter ¶m, const QVariant &value) { - const int band = pid; - const qreal level = value.toReal(); - setBandLevel(band, level); -} - -void AudioEqualizer::applyParameters() -{ - if (m_effect.data()) { - Phonon::EffectParameter param; - foreach (param, parameters()) { - const int band = param.id(); - const qreal level = parameterValue(param).toReal(); - setBandLevel(band, level); - } - } -} - -void AudioEqualizer::setBandLevel(int band, qreal externalLevel) -{ - const EffectParameter ¶m = m_params[band-1]; // Band IDs are 1-based + const int band = param.id() + 1; + const qreal externalLevel = value.toReal(); const int internalLevel = param.toInternalValue(externalLevel); // TODO: handle audio effect errors TRAP_IGNORE(concreteEffect()->SetBandLevelL(band, internalLevel)); } + //----------------------------------------------------------------------------- // Static functions //----------------------------------------------------------------------------- @@ -92,10 +75,12 @@ bool AudioEqualizer::getParameters(CMdaAudioOutputStream *stream, const int bandCount = effect->NumberOfBands(); - // For some reason, band IDs are 1-based, as opposed to the - // 0-based indices used in just about other Symbian API...! - for (int i = 1; i <= bandCount; ++i) { - const qint32 hz = effect->CenterFrequency(i); + for (int i = 0; i < bandCount; ++i) { + // For some reason, band IDs are 1-based, as opposed to the + // 0-based indices used in just about other Symbian API...! + const int band = i + 1; + + const qint32 hz = effect->CenterFrequency(band); // We pass a floating-point parameter range of -1.0 to +1.0 for // each band in order to work around a limitation in diff --git a/src/3rdparty/phonon/mmf/audioequalizer.h b/src/3rdparty/phonon/mmf/audioequalizer.h index 9eda994..3a9a5ca 100644 --- a/src/3rdparty/phonon/mmf/audioequalizer.h +++ b/src/3rdparty/phonon/mmf/audioequalizer.h @@ -51,11 +51,10 @@ public: protected: // AbstractAudioEffect virtual void createEffect(AudioPlayer::NativePlayer *player); - virtual void applyParameters(); - virtual void parameterChanged(const int id, const QVariant &value); + virtual void parameterChanged(const EffectParameter ¶m, + const QVariant &value); 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 c8c4831..997bae4 100644 --- a/src/3rdparty/phonon/mmf/bassboost.cpp +++ b/src/3rdparty/phonon/mmf/bassboost.cpp @@ -37,17 +37,12 @@ BassBoost::BassBoost(QObject *parent, const QList ¶meters) } -void BassBoost::parameterChanged(const int, +void BassBoost::parameterChanged(const EffectParameter &, const QVariant &) { Q_ASSERT_X(false, Q_FUNC_INFO, "BassBoost has no parameters"); } -void BassBoost::applyParameters() -{ - // No parameters to apply -} - //----------------------------------------------------------------------------- // Static functions //----------------------------------------------------------------------------- diff --git a/src/3rdparty/phonon/mmf/bassboost.h b/src/3rdparty/phonon/mmf/bassboost.h index d3cda34..b2bc854 100644 --- a/src/3rdparty/phonon/mmf/bassboost.h +++ b/src/3rdparty/phonon/mmf/bassboost.h @@ -49,8 +49,8 @@ public: protected: // AbstractAudioEffect virtual void createEffect(AudioPlayer::NativePlayer *player); - virtual void applyParameters(); - virtual void parameterChanged(const int id, const QVariant &value); + virtual void parameterChanged(const EffectParameter ¶m, + const QVariant &value); private: CBassBoost *concreteEffect(); -- cgit v0.12 From edbbbe81675e1b9792f43232963c399ff2fffbd6 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Mon, 11 Jan 2010 16:13:10 +0000 Subject: Implemented bass boost in Phonon MMF backend Task-number: QTBUG-4659 Reviewed-by: Espen Riskedal --- src/3rdparty/phonon/mmf/abstractaudioeffect.cpp | 12 ++++++++++ src/3rdparty/phonon/mmf/abstractaudioeffect.h | 2 ++ src/3rdparty/phonon/mmf/bassboost.cpp | 29 ++++++++++++++++++++----- src/3rdparty/phonon/mmf/bassboost.h | 5 +---- src/3rdparty/phonon/mmf/effectfactory.cpp | 5 +++-- 5 files changed, 42 insertions(+), 11 deletions(-) diff --git a/src/3rdparty/phonon/mmf/abstractaudioeffect.cpp b/src/3rdparty/phonon/mmf/abstractaudioeffect.cpp index 3bce86b..593e00f 100644 --- a/src/3rdparty/phonon/mmf/abstractaudioeffect.cpp +++ b/src/3rdparty/phonon/mmf/abstractaudioeffect.cpp @@ -114,6 +114,16 @@ void AbstractAudioEffect::disconnectMediaObject(MediaObject *mediaObject) abstractPlayerChanged(0); } +void AbstractAudioEffect::setEnabled(bool enabled) +{ + if (enabled) + // TODO: handle audio effect errors + TRAP_IGNORE(m_effect->EnableL()) + else + // TODO: handle audio effect errors + TRAP_IGNORE(m_effect->DisableL()) +} + void AbstractAudioEffect::createEffect() { Q_ASSERT_X(m_player, Q_FUNC_INFO, "Invalid media player pointer"); @@ -131,6 +141,8 @@ void AbstractAudioEffect::createEffect() // TODO: handle audio effect errors TRAP_IGNORE(m_effect->EnableL()); + + setEnabled(true); } } diff --git a/src/3rdparty/phonon/mmf/abstractaudioeffect.h b/src/3rdparty/phonon/mmf/abstractaudioeffect.h index 9b9c47d..57427e7 100644 --- a/src/3rdparty/phonon/mmf/abstractaudioeffect.h +++ b/src/3rdparty/phonon/mmf/abstractaudioeffect.h @@ -82,6 +82,8 @@ protected: void connectMediaObject(MediaObject *mediaObject); void disconnectMediaObject(MediaObject *mediaObject); + void setEnabled(bool enabled); + virtual void createEffect(AudioPlayer::NativePlayer *player) = 0; virtual void parameterChanged(const EffectParameter ¶m, diff --git a/src/3rdparty/phonon/mmf/bassboost.cpp b/src/3rdparty/phonon/mmf/bassboost.cpp index 997bae4..a8631e0 100644 --- a/src/3rdparty/phonon/mmf/bassboost.cpp +++ b/src/3rdparty/phonon/mmf/bassboost.cpp @@ -37,10 +37,11 @@ BassBoost::BassBoost(QObject *parent, const QList ¶meters) } -void BassBoost::parameterChanged(const EffectParameter &, - const QVariant &) +void BassBoost::parameterChanged(const EffectParameter ¶m, + const QVariant &value) { - Q_ASSERT_X(false, Q_FUNC_INFO, "BassBoost has no parameters"); + Q_ASSERT_X(param.id() == 0, Q_FUNC_INFO, "Invalid parameter ID"); + setEnabled(value.toBool()); } //----------------------------------------------------------------------------- @@ -52,9 +53,27 @@ const char* BassBoost::description() return "Bass boost"; } -bool BassBoost::getParameters(CMdaAudioOutputStream *, QList&) +bool BassBoost::getParameters(CMdaAudioOutputStream *stream, + QList ¶meters) { - return true; + bool supported = false; + + QScopedPointer effect; + TRAPD(err, effect.reset(CBassBoost::NewL(*stream))); + + if(KErrNone == err) { + supported = true; + + EffectParameter param( + /* parameterId */ 0, + /* name */ tr("Enabled"), + /* hints */ EffectParameter::ToggledHint, + /* defaultValue */ QVariant(bool(true))); + + parameters.append(param); + } + + return supported; } QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/bassboost.h b/src/3rdparty/phonon/mmf/bassboost.h index b2bc854..82a3bab 100644 --- a/src/3rdparty/phonon/mmf/bassboost.h +++ b/src/3rdparty/phonon/mmf/bassboost.h @@ -30,10 +30,7 @@ namespace Phonon namespace MMF { /** - * @short An "bass boost" effect. - * - * The documentation does not say what "bass boost" is, neither has it anykind - * of setting. It's an on or off thing. + * @short A "bass boost" effect. */ class BassBoost : public AbstractAudioEffect { diff --git a/src/3rdparty/phonon/mmf/effectfactory.cpp b/src/3rdparty/phonon/mmf/effectfactory.cpp index 19c6d90..c6593bb 100644 --- a/src/3rdparty/phonon/mmf/effectfactory.cpp +++ b/src/3rdparty/phonon/mmf/effectfactory.cpp @@ -68,15 +68,16 @@ AbstractAudioEffect *EffectFactory::createAudioEffect(Type type, { case TypeBassBoost: effect = new BassBoost(parent, parameters); + break; case TypeAudioEqualizer: effect = new AudioEqualizer(parent, parameters); + break; case TypeDistanceAttenuation: case TypeEnvironmentalReverb: case TypeListenerOrientation: case TypeLoudness: case TypeSourceOrientation: case TypeStereoWidening: - break; default: Q_ASSERT_X(false, Q_FUNC_INFO, "Unknown effect"); } @@ -124,7 +125,7 @@ void EffectFactory::initialize() Q_ASSERT_X(!m_initialized, Q_FUNC_INFO, "Already initialized"); INITIALIZE_EFFECT(AudioEqualizer) - //INITIALIZE_EFFECT(BassBoost) + INITIALIZE_EFFECT(BassBoost) m_initialized = true; } -- cgit v0.12 From d993351832c34f51056af06eb83d18f71fa9fd9d Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Thu, 10 Dec 2009 15:43:37 +0000 Subject: Implemented loudness effect in Phonon MMF backend Task-number: QTBUG-4659 Reviewed-by: Espen Riskedal --- src/3rdparty/phonon/mmf/effectfactory.cpp | 4 ++ src/3rdparty/phonon/mmf/loudness.cpp | 80 +++++++++++++++++++++++++++++++ src/3rdparty/phonon/mmf/loudness.h | 62 ++++++++++++++++++++++++ src/plugins/phonon/mmf/mmf.pro | 2 + 4 files changed, 148 insertions(+) create mode 100644 src/3rdparty/phonon/mmf/loudness.cpp create mode 100644 src/3rdparty/phonon/mmf/loudness.h diff --git a/src/3rdparty/phonon/mmf/effectfactory.cpp b/src/3rdparty/phonon/mmf/effectfactory.cpp index c6593bb..50d08e7 100644 --- a/src/3rdparty/phonon/mmf/effectfactory.cpp +++ b/src/3rdparty/phonon/mmf/effectfactory.cpp @@ -23,6 +23,7 @@ along with this library. If not, see . #include "audioequalizer.h" #include "bassboost.h" +#include "loudness.h" #include "effectfactory.h" @@ -76,6 +77,8 @@ AbstractAudioEffect *EffectFactory::createAudioEffect(Type type, case TypeEnvironmentalReverb: case TypeListenerOrientation: case TypeLoudness: + effect = new Loudness(parent, parameters); + break; case TypeSourceOrientation: case TypeStereoWidening: default: @@ -126,6 +129,7 @@ void EffectFactory::initialize() INITIALIZE_EFFECT(AudioEqualizer) INITIALIZE_EFFECT(BassBoost) + INITIALIZE_EFFECT(Loudness) m_initialized = true; } diff --git a/src/3rdparty/phonon/mmf/loudness.cpp b/src/3rdparty/phonon/mmf/loudness.cpp new file mode 100644 index 0000000..7a033fa --- /dev/null +++ b/src/3rdparty/phonon/mmf/loudness.cpp @@ -0,0 +1,80 @@ +/* This file is part of the KDE project. + +Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + +This library is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 or 3 of the License. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library. If not, see . + +*/ + +#include +#include "loudness.h" + +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(Loudness) + +/*! \class MMF::Loudness + \internal +*/ + +Loudness::Loudness(QObject *parent, const QList& parameters) + : AbstractAudioEffect::AbstractAudioEffect(parent, parameters) +{ + +} + +void Loudness::parameterChanged(const EffectParameter ¶m, + const QVariant &value) +{ + Q_ASSERT_X(param.id() == 0, Q_FUNC_INFO, "Invalid parameter ID"); + setEnabled(value.toBool()); +} + +//----------------------------------------------------------------------------- +// Static functions +//----------------------------------------------------------------------------- + +const char* Loudness::description() +{ + return "Loudness"; +} + +bool Loudness::getParameters(CMdaAudioOutputStream *stream, + QList ¶meters) +{ + bool supported = false; + + QScopedPointer effect; + TRAPD(err, effect.reset(CLoudness::NewL(*stream))); + + if(KErrNone == err) { + supported = true; + + EffectParameter param( + /* parameterId */ 0, + /* name */ tr("Enabled"), + /* hints */ EffectParameter::ToggledHint, + /* defaultValue */ QVariant(bool(true))); + + parameters.append(param); + } + + return supported; +} + +QT_END_NAMESPACE + diff --git a/src/3rdparty/phonon/mmf/loudness.h b/src/3rdparty/phonon/mmf/loudness.h new file mode 100644 index 0000000..f772d7f --- /dev/null +++ b/src/3rdparty/phonon/mmf/loudness.h @@ -0,0 +1,62 @@ +/* This file is part of the KDE project. + +Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + +This library is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 or 3 of the License. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library. If not, see . + +*/ + +#ifndef PHONON_MMF_LOUDNESS_H +#define PHONON_MMF_LOUDNESS_H + +#include "abstractaudioeffect.h" + +class CLoudness; + +QT_BEGIN_NAMESPACE + +namespace Phonon +{ +namespace MMF +{ +/** + * @short A "loudness" effect. + */ +class Loudness : public AbstractAudioEffect +{ + Q_OBJECT +public: + Loudness(QObject *parent, const QList& parameters); + + // Static interface required by EffectFactory + static const char* description(); + static bool getParameters(CMdaAudioOutputStream *stream, + QList& parameters); + +protected: + // AbstractAudioEffect + virtual void createEffect(AudioPlayer::NativePlayer *player); + virtual void parameterChanged(const EffectParameter ¶m, + const QVariant &value); + +private: + CLoudness *concreteEffect(); + +}; +} +} + +QT_END_NAMESPACE + +#endif + diff --git a/src/plugins/phonon/mmf/mmf.pro b/src/plugins/phonon/mmf/mmf.pro index f72a657..37c613c 100644 --- a/src/plugins/phonon/mmf/mmf.pro +++ b/src/plugins/phonon/mmf/mmf.pro @@ -36,6 +36,7 @@ HEADERS += \ $$PHONON_MMF_DIR/dummyplayer.h \ $$PHONON_MMF_DIR/effectfactory.h \ $$PHONON_MMF_DIR/effectparameter.h \ + $$PHONON_MMF_DIR/loudness.h \ $$PHONON_MMF_DIR/mediaobject.h \ $$PHONON_MMF_DIR/mmf_medianode.h \ $$PHONON_MMF_DIR/mmf_videoplayer.h \ @@ -59,6 +60,7 @@ SOURCES += \ $$PHONON_MMF_DIR/dummyplayer.cpp \ $$PHONON_MMF_DIR/effectfactory.cpp \ $$PHONON_MMF_DIR/effectparameter.cpp \ + $$PHONON_MMF_DIR/loudness.cpp \ $$PHONON_MMF_DIR/mediaobject.cpp \ $$PHONON_MMF_DIR/mmf_medianode.cpp \ $$PHONON_MMF_DIR/mmf_videoplayer.cpp \ -- cgit v0.12 From bc0e4aa8aec231b43a6033f3f4f12037b02ee64e Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Thu, 10 Dec 2009 17:24:03 +0000 Subject: Implemented reverb effect in Phonon MMF backend Task-number: QTBUG-4659 Reviewed-by: Espen Riskedal --- src/3rdparty/phonon/mmf/effectfactory.cpp | 11 +- src/3rdparty/phonon/mmf/effectparameter.cpp | 8 + src/3rdparty/phonon/mmf/effectparameter.h | 2 + src/3rdparty/phonon/mmf/environmentalreverb.cpp | 202 ++++++++++++++++++++++++ src/3rdparty/phonon/mmf/environmentalreverb.h | 62 ++++++++ src/plugins/phonon/mmf/mmf.pro | 2 + 6 files changed, 285 insertions(+), 2 deletions(-) create mode 100644 src/3rdparty/phonon/mmf/environmentalreverb.cpp create mode 100644 src/3rdparty/phonon/mmf/environmentalreverb.h diff --git a/src/3rdparty/phonon/mmf/effectfactory.cpp b/src/3rdparty/phonon/mmf/effectfactory.cpp index 50d08e7..ef2ddf7 100644 --- a/src/3rdparty/phonon/mmf/effectfactory.cpp +++ b/src/3rdparty/phonon/mmf/effectfactory.cpp @@ -23,6 +23,7 @@ along with this library. If not, see . #include "audioequalizer.h" #include "bassboost.h" +#include "environmentalreverb.h" #include "loudness.h" #include "effectfactory.h" @@ -73,14 +74,19 @@ AbstractAudioEffect *EffectFactory::createAudioEffect(Type type, case TypeAudioEqualizer: effect = new AudioEqualizer(parent, parameters); break; - case TypeDistanceAttenuation: case TypeEnvironmentalReverb: - case TypeListenerOrientation: + effect = new EnvironmentalReverb(parent, parameters); + break; case TypeLoudness: effect = new Loudness(parent, parameters); break; + + // Not implemented + case TypeDistanceAttenuation: + case TypeListenerOrientation: case TypeSourceOrientation: case TypeStereoWidening: + // Fall through default: Q_ASSERT_X(false, Q_FUNC_INFO, "Unknown effect"); } @@ -129,6 +135,7 @@ void EffectFactory::initialize() INITIALIZE_EFFECT(AudioEqualizer) INITIALIZE_EFFECT(BassBoost) + INITIALIZE_EFFECT(EnvironmentalReverb) INITIALIZE_EFFECT(Loudness) m_initialized = true; diff --git a/src/3rdparty/phonon/mmf/effectparameter.cpp b/src/3rdparty/phonon/mmf/effectparameter.cpp index f4287b8..17c1315 100644 --- a/src/3rdparty/phonon/mmf/effectparameter.cpp +++ b/src/3rdparty/phonon/mmf/effectparameter.cpp @@ -59,5 +59,13 @@ qint32 MMF::EffectParameter::toInternalValue(qreal external) const return m_internalRange.first + ((1.0 + external) / 2) * range; } +qreal MMF::EffectParameter::toExternalValue + (qint32 value, qint32 min, qint32 max) +{ + Q_ASSERT_X(max >= min, Q_FUNC_INFO, "Invalid range"); + const qint32 range = max - min; + return range == 0 ? 0.0 : ((2.0 * value - min) / range) - 1.0; +} + QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/effectparameter.h b/src/3rdparty/phonon/mmf/effectparameter.h index 3008159..27cc018 100644 --- a/src/3rdparty/phonon/mmf/effectparameter.h +++ b/src/3rdparty/phonon/mmf/effectparameter.h @@ -57,6 +57,8 @@ public: void setInternalRange(qint32 min, qint32 max); qint32 toInternalValue(qreal external) const; + static qreal toExternalValue(qint32 value, qint32 min, qint32 max); + private: bool m_hasInternalRange; QPair m_internalRange; diff --git a/src/3rdparty/phonon/mmf/environmentalreverb.cpp b/src/3rdparty/phonon/mmf/environmentalreverb.cpp new file mode 100644 index 0000000..2e30ca1 --- /dev/null +++ b/src/3rdparty/phonon/mmf/environmentalreverb.cpp @@ -0,0 +1,202 @@ +/* This file is part of the KDE project. + +Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + +This library is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 or 3 of the License. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library. If not, see . + +*/ + +#include +#include "environmentalreverb.h" + +QT_BEGIN_NAMESPACE + +using namespace Phonon; +using namespace Phonon::MMF; + +/*! \class MMF::EnvironmentalReverb + \internal +*/ + +// Define functions which depend on concrete native effect class name +PHONON_MMF_DEFINE_EFFECT_FUNCTIONS(EnvironmentalReverb) + +enum Parameters +{ + DecayHFRatio, + DecayTime, + Density, + Diffusion, + ReflectionsDelay, + ReflectionsLevel, + ReverbDelay, + ReverbLevel, + RoomHFLevel, + RoomLevel +}; + +EnvironmentalReverb::EnvironmentalReverb(QObject *parent, const QList& parameters) + : AbstractAudioEffect::AbstractAudioEffect(parent, parameters) +{ + +} + +void EnvironmentalReverb::parameterChanged(const EffectParameter ¶m, + const QVariant &value) +{ + const qreal externalLevel = value.toReal(); + const int internalLevel = param.toInternalValue(externalLevel); + + TInt err = 0; + + switch(param.id()) { + case DecayHFRatio: + TRAP(err, concreteEffect()->SetDecayHFRatioL(internalLevel)); + break; + case DecayTime: + TRAP(err, concreteEffect()->SetDecayTimeL(internalLevel)); + break; + case Density: + TRAP(err, concreteEffect()->SetDensityL(internalLevel)); + break; + case Diffusion: + TRAP(err, concreteEffect()->SetDiffusionL(internalLevel)); + break; + case ReflectionsDelay: + TRAP(err, concreteEffect()->SetReflectionsDelayL(internalLevel)); + break; + case ReflectionsLevel: + TRAP(err, concreteEffect()->SetReflectionsLevelL(internalLevel)); + break; + case ReverbDelay: + TRAP(err, concreteEffect()->SetReverbDelayL(internalLevel)); + break; + case ReverbLevel: + TRAP(err, concreteEffect()->SetReverbLevelL(internalLevel)); + break; + case RoomHFLevel: + TRAP(err, concreteEffect()->SetRoomHFLevelL(internalLevel)); + break; + case RoomLevel: + TRAP(err, concreteEffect()->SetRoomLevelL(internalLevel)); + break; + default: + Q_ASSERT_X(false, Q_FUNC_INFO, "Unknown parameter"); + } + + // TODO: handle audio effect errors + Q_UNUSED(err); +} + + +//----------------------------------------------------------------------------- +// Static functions +//----------------------------------------------------------------------------- + +const char* EnvironmentalReverb::description() +{ + return "Reverb"; +} + +// Internal helper function +Phonon::MMF::EffectParameter createParameter(int id, const QString &name, + int defaultValue, int minValue, int maxValue, + Phonon::EffectParameter::Hint hint = Phonon::EffectParameter::IntegerHint) +{ + const qreal externalDefaultValue = + Phonon::MMF::EffectParameter::toExternalValue + (defaultValue, minValue, maxValue); + + Phonon::MMF::EffectParameter param(id, name, hint, + /* defaultValue */ QVariant(externalDefaultValue), + /* minimumValue */ QVariant(qreal(-1.0)), + /* maximumValue */ QVariant(qreal(+1.0))); + + param.setInternalRange(minValue, maxValue); + return param; +} + +bool EnvironmentalReverb::getParameters(CMdaAudioOutputStream *stream, + QList& parameters) +{ + bool supported = false; + + QScopedPointer effect; + TRAPD(err, effect.reset(CEnvironmentalReverb::NewL(*stream))); + + if (KErrNone == err) { + supported = true; + + TInt32 min, max; + TUint32 umin, umax; + + // DecayHFRatio + effect->DecayHFRatioRange(umin, umax); + parameters.append(createParameter( + DecayHFRatio, tr("Decay HF ratio (%)"), effect->DecayHFRatio(), + umin, umax)); + + // DecayTime + effect->DecayTimeRange(umin, umax); + parameters.append(createParameter( + DecayTime, tr("Decay time (ms)"), effect->DecayTime(), + umin, umax)); + + // Density + parameters.append(createParameter( + Density, tr("Density (%)"), effect->Density(), 0, 100)); + + // Diffusion + parameters.append(createParameter( + Diffusion, tr("Diffusion (%)"), effect->Diffusion(), 0, 100)); + + // ReflectionsDelay + parameters.append(createParameter( + ReflectionsDelay, tr("Reflections delay (ms)"), + effect->ReflectionsDelay(), 0, effect->ReflectionsDelayMax())); + + // ReflectionsLevel + effect->ReflectionLevelRange(min, max); + parameters.append(createParameter( + ReflectionsLevel, tr("Reflections level (mB)"), + effect->ReflectionsLevel(), + min, max, EffectParameter::LogarithmicHint)); + + // ReverbDelay + parameters.append(createParameter( + ReverbDelay, tr("Reverb delay (ms)"), effect->ReverbDelay(), + 0, effect->ReverbDelayMax())); + + // ReverbLevel + effect->ReverbLevelRange(min, max); + parameters.append(createParameter( + ReverbLevel, tr("Reverb level (mB)"), effect->ReverbLevel(), + min, max, EffectParameter::LogarithmicHint)); + + // RoomHFLevel + effect->RoomHFLevelRange(min, max); + parameters.append(createParameter( + RoomHFLevel, tr("Room HF level"), effect->RoomHFLevel(), + min, max)); + + // RoomLevel + effect->RoomLevelRange(min, max); + parameters.append(createParameter( + RoomLevel, tr("Room level (mB)"), effect->RoomLevel(), + min, max, EffectParameter::LogarithmicHint)); + } + + return supported; +} + +QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/environmentalreverb.h b/src/3rdparty/phonon/mmf/environmentalreverb.h new file mode 100644 index 0000000..5760c0a --- /dev/null +++ b/src/3rdparty/phonon/mmf/environmentalreverb.h @@ -0,0 +1,62 @@ +/* This file is part of the KDE project. + +Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + +This library is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 or 3 of the License. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library. If not, see . + +*/ + +#ifndef PHONON_MMF_ENVIRONMENTALREVERB_H +#define PHONON_MMF_ENVIRONMENTALREVERB_H + +#include "abstractaudioeffect.h" + +class CEnvironmentalReverb; + +QT_BEGIN_NAMESPACE + +namespace Phonon +{ +namespace MMF +{ +/** + * @short A reverb effect. + */ +class EnvironmentalReverb : public AbstractAudioEffect +{ + Q_OBJECT +public: + EnvironmentalReverb(QObject *parent, const QList& parameters); + + // Static interface required by EffectFactory + static const char* description(); + static bool getParameters(CMdaAudioOutputStream *stream, + QList& parameters); + +protected: + // AbstractAudioEffect + virtual void createEffect(AudioPlayer::NativePlayer *player); + virtual void parameterChanged(const EffectParameter ¶m, + const QVariant &value); + +private: + CEnvironmentalReverb *concreteEffect(); + +}; +} +} + +QT_END_NAMESPACE + +#endif + diff --git a/src/plugins/phonon/mmf/mmf.pro b/src/plugins/phonon/mmf/mmf.pro index 37c613c..78e23d9 100644 --- a/src/plugins/phonon/mmf/mmf.pro +++ b/src/plugins/phonon/mmf/mmf.pro @@ -36,6 +36,7 @@ HEADERS += \ $$PHONON_MMF_DIR/dummyplayer.h \ $$PHONON_MMF_DIR/effectfactory.h \ $$PHONON_MMF_DIR/effectparameter.h \ + $$PHONON_MMF_DIR/environmentalreverb.h \ $$PHONON_MMF_DIR/loudness.h \ $$PHONON_MMF_DIR/mediaobject.h \ $$PHONON_MMF_DIR/mmf_medianode.h \ @@ -60,6 +61,7 @@ SOURCES += \ $$PHONON_MMF_DIR/dummyplayer.cpp \ $$PHONON_MMF_DIR/effectfactory.cpp \ $$PHONON_MMF_DIR/effectparameter.cpp \ + $$PHONON_MMF_DIR/environmentalreverb.cpp \ $$PHONON_MMF_DIR/loudness.cpp \ $$PHONON_MMF_DIR/mediaobject.cpp \ $$PHONON_MMF_DIR/mmf_medianode.cpp \ -- cgit v0.12 From f42624c9f88cbbb71d6857566e00348b119d486c Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Thu, 10 Dec 2009 17:44:39 +0000 Subject: Implemented stereo widening effect in Phonon MMF backend Task-number: QTBUG-4659 Reviewed-by: Espen Riskedal --- src/3rdparty/phonon/mmf/effectfactory.cpp | 6 +- src/3rdparty/phonon/mmf/stereowidening.cpp | 94 ++++++++++++++++++++++++++++++ src/3rdparty/phonon/mmf/stereowidening.h | 62 ++++++++++++++++++++ src/plugins/phonon/mmf/mmf.pro | 2 + 4 files changed, 163 insertions(+), 1 deletion(-) create mode 100644 src/3rdparty/phonon/mmf/stereowidening.cpp create mode 100644 src/3rdparty/phonon/mmf/stereowidening.h diff --git a/src/3rdparty/phonon/mmf/effectfactory.cpp b/src/3rdparty/phonon/mmf/effectfactory.cpp index ef2ddf7..081f6a3 100644 --- a/src/3rdparty/phonon/mmf/effectfactory.cpp +++ b/src/3rdparty/phonon/mmf/effectfactory.cpp @@ -25,6 +25,7 @@ along with this library. If not, see . #include "bassboost.h" #include "environmentalreverb.h" #include "loudness.h" +#include "stereowidening.h" #include "effectfactory.h" @@ -80,12 +81,14 @@ AbstractAudioEffect *EffectFactory::createAudioEffect(Type type, case TypeLoudness: effect = new Loudness(parent, parameters); break; + case TypeStereoWidening: + effect = new StereoWidening(parent, parameters); + break; // Not implemented case TypeDistanceAttenuation: case TypeListenerOrientation: case TypeSourceOrientation: - case TypeStereoWidening: // Fall through default: Q_ASSERT_X(false, Q_FUNC_INFO, "Unknown effect"); @@ -137,6 +140,7 @@ void EffectFactory::initialize() INITIALIZE_EFFECT(BassBoost) INITIALIZE_EFFECT(EnvironmentalReverb) INITIALIZE_EFFECT(Loudness) + INITIALIZE_EFFECT(StereoWidening) m_initialized = true; } diff --git a/src/3rdparty/phonon/mmf/stereowidening.cpp b/src/3rdparty/phonon/mmf/stereowidening.cpp new file mode 100644 index 0000000..4fee1aa --- /dev/null +++ b/src/3rdparty/phonon/mmf/stereowidening.cpp @@ -0,0 +1,94 @@ +/* This file is part of the KDE project. + +Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + +This library is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 or 3 of the License. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library. If not, see . + +*/ + +#include +#include "stereowidening.h" + +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(StereoWidening) + +/*! \class MMF::StereoWidening + \internal +*/ + +StereoWidening::StereoWidening(QObject *parent, const QList& parameters) + : AbstractAudioEffect::AbstractAudioEffect(parent, parameters) +{ + +} + +void StereoWidening::parameterChanged(const EffectParameter ¶m, + const QVariant &value) +{ + Q_ASSERT_X(param.id() == 0, Q_FUNC_INFO, "Invalid parameter ID"); + + const qreal externalLevel = value.toReal(); + const int internalLevel = param.toInternalValue(externalLevel); + + TRAPD(err, concreteEffect()->SetStereoWideningLevelL(internalLevel)); + + // TODO: handle audio effect errors + Q_UNUSED(err); +} + +//----------------------------------------------------------------------------- +// Static functions +//----------------------------------------------------------------------------- + +const char* StereoWidening::description() +{ + return "Stereo widening"; +} + +bool StereoWidening::getParameters(CMdaAudioOutputStream *stream, + QList ¶meters) +{ + bool supported = false; + + QScopedPointer effect; + TRAPD(err, effect.reset(CStereoWidening::NewL(*stream))); + + if (KErrNone == err) { + supported = true; + + const qreal defaultValue = + Phonon::MMF::EffectParameter::toExternalValue + (effect->StereoWideningLevel(), 0, 100); + + EffectParameter param( + /* parameterId */ 0, + /* name */ tr("Level (%)"), + /* hints */ EffectParameter::IntegerHint, + /* defaultValue */ QVariant(defaultValue), + /* minimumValue */ QVariant(qreal(-1.0)), + /* maximumValue */ QVariant(qreal(+1.0))); + + param.setInternalRange(0, 100); + parameters.append(param); + } + + return supported; +} + +QT_END_NAMESPACE + diff --git a/src/3rdparty/phonon/mmf/stereowidening.h b/src/3rdparty/phonon/mmf/stereowidening.h new file mode 100644 index 0000000..249c279 --- /dev/null +++ b/src/3rdparty/phonon/mmf/stereowidening.h @@ -0,0 +1,62 @@ +/* This file is part of the KDE project. + +Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + +This library is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 or 3 of the License. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library. If not, see . + +*/ + +#ifndef PHONON_MMF_STEREOWIDENING_H +#define PHONON_MMF_STEREOWIDENING_H + +#include "abstractaudioeffect.h" + +class CStereoWidening; + +QT_BEGIN_NAMESPACE + +namespace Phonon +{ +namespace MMF +{ +/** + * @short A "bass boost" effect. + */ +class StereoWidening : public AbstractAudioEffect +{ + Q_OBJECT +public: + StereoWidening(QObject *parent, const QList& parameters); + + // Static interface required by EffectFactory + static const char* description(); + static bool getParameters(CMdaAudioOutputStream *stream, + QList& parameters); + +protected: + // AbstractAudioEffect + virtual void createEffect(AudioPlayer::NativePlayer *player); + virtual void parameterChanged(const EffectParameter ¶m, + const QVariant &value); + +private: + CStereoWidening *concreteEffect(); + +}; +} +} + +QT_END_NAMESPACE + +#endif + diff --git a/src/plugins/phonon/mmf/mmf.pro b/src/plugins/phonon/mmf/mmf.pro index 78e23d9..cfaca9d 100644 --- a/src/plugins/phonon/mmf/mmf.pro +++ b/src/plugins/phonon/mmf/mmf.pro @@ -41,6 +41,7 @@ HEADERS += \ $$PHONON_MMF_DIR/mediaobject.h \ $$PHONON_MMF_DIR/mmf_medianode.h \ $$PHONON_MMF_DIR/mmf_videoplayer.h \ + $$PHONON_MMF_DIR/stereowidening.h \ $$PHONON_MMF_DIR/objectdump.h \ $$PHONON_MMF_DIR/objectdump_symbian.h \ $$PHONON_MMF_DIR/objecttree.h \ @@ -66,6 +67,7 @@ SOURCES += \ $$PHONON_MMF_DIR/mediaobject.cpp \ $$PHONON_MMF_DIR/mmf_medianode.cpp \ $$PHONON_MMF_DIR/mmf_videoplayer.cpp \ + $$PHONON_MMF_DIR/stereowidening.cpp \ $$PHONON_MMF_DIR/objectdump.cpp \ $$PHONON_MMF_DIR/objectdump_symbian.cpp \ $$PHONON_MMF_DIR/objecttree.cpp \ -- cgit v0.12 From 5a8c0ded599263446010dfc1729dcab8b2f62f0d Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Mon, 11 Jan 2010 17:41:23 +0000 Subject: Simplified error handling for audio effects Task-number: QTBUG-4659 Reviewed-by: Espen Riskedal --- src/3rdparty/phonon/mmf/abstractaudioeffect.cpp | 22 ++++++++++++---------- src/3rdparty/phonon/mmf/abstractaudioeffect.h | 2 +- src/3rdparty/phonon/mmf/audioequalizer.cpp | 6 +++--- src/3rdparty/phonon/mmf/audioequalizer.h | 2 +- src/3rdparty/phonon/mmf/bassboost.cpp | 3 ++- src/3rdparty/phonon/mmf/bassboost.h | 4 ++-- src/3rdparty/phonon/mmf/environmentalreverb.cpp | 5 ++--- src/3rdparty/phonon/mmf/environmentalreverb.h | 4 ++-- src/3rdparty/phonon/mmf/loudness.cpp | 3 ++- src/3rdparty/phonon/mmf/loudness.h | 4 ++-- src/3rdparty/phonon/mmf/stereowidening.cpp | 5 ++--- src/3rdparty/phonon/mmf/stereowidening.h | 4 ++-- 12 files changed, 33 insertions(+), 31 deletions(-) diff --git a/src/3rdparty/phonon/mmf/abstractaudioeffect.cpp b/src/3rdparty/phonon/mmf/abstractaudioeffect.cpp index 593e00f..e3672e6 100644 --- a/src/3rdparty/phonon/mmf/abstractaudioeffect.cpp +++ b/src/3rdparty/phonon/mmf/abstractaudioeffect.cpp @@ -71,9 +71,10 @@ void AbstractAudioEffect::setParameterValue(const Phonon::EffectParameter ¶m if (m_effect.data()) { const EffectParameter& internalParam = internalParameter(param.id()); - parameterChanged(internalParam, newValue); + int err = parameterChanged(internalParam, newValue); + TRAP(err, m_effect->ApplyL()); // TODO: handle audio effect errors - TRAP_IGNORE(m_effect->ApplyL()); + Q_UNUSED(err); } } @@ -116,12 +117,16 @@ void AbstractAudioEffect::disconnectMediaObject(MediaObject *mediaObject) void AbstractAudioEffect::setEnabled(bool enabled) { + TInt err = KErrNone; + if (enabled) // TODO: handle audio effect errors - TRAP_IGNORE(m_effect->EnableL()) + TRAP(err, m_effect->EnableL()) else // TODO: handle audio effect errors - TRAP_IGNORE(m_effect->DisableL()) + TRAP(err, m_effect->DisableL()) + + Q_UNUSED(err); } void AbstractAudioEffect::createEffect() @@ -134,15 +139,12 @@ void AbstractAudioEffect::createEffect() if (m_effect.data()) { EffectParameter param; + int err = 0; foreach (param, m_params) { const QVariant value = parameterValue(param); - parameterChanged(param, value); + err = parameterChanged(param, value); } - - // TODO: handle audio effect errors - TRAP_IGNORE(m_effect->EnableL()); - - setEnabled(true); + Q_UNUSED(err) } } diff --git a/src/3rdparty/phonon/mmf/abstractaudioeffect.h b/src/3rdparty/phonon/mmf/abstractaudioeffect.h index 57427e7..a3b35c2 100644 --- a/src/3rdparty/phonon/mmf/abstractaudioeffect.h +++ b/src/3rdparty/phonon/mmf/abstractaudioeffect.h @@ -86,7 +86,7 @@ protected: virtual void createEffect(AudioPlayer::NativePlayer *player) = 0; - virtual void parameterChanged(const EffectParameter ¶m, + virtual int parameterChanged(const EffectParameter ¶m, const QVariant &value) = 0; private: diff --git a/src/3rdparty/phonon/mmf/audioequalizer.cpp b/src/3rdparty/phonon/mmf/audioequalizer.cpp index 1584cf7..201a5fc 100644 --- a/src/3rdparty/phonon/mmf/audioequalizer.cpp +++ b/src/3rdparty/phonon/mmf/audioequalizer.cpp @@ -37,15 +37,15 @@ AudioEqualizer::AudioEqualizer(QObject *parent, const QList& pa } -void AudioEqualizer::parameterChanged(const EffectParameter ¶m, +int AudioEqualizer::parameterChanged(const EffectParameter ¶m, const QVariant &value) { const int band = param.id() + 1; const qreal externalLevel = value.toReal(); const int internalLevel = param.toInternalValue(externalLevel); - // TODO: handle audio effect errors - TRAP_IGNORE(concreteEffect()->SetBandLevelL(band, internalLevel)); + TRAPD(err, concreteEffect()->SetBandLevelL(band, internalLevel)); + return err; } diff --git a/src/3rdparty/phonon/mmf/audioequalizer.h b/src/3rdparty/phonon/mmf/audioequalizer.h index 3a9a5ca..acfe9b5 100644 --- a/src/3rdparty/phonon/mmf/audioequalizer.h +++ b/src/3rdparty/phonon/mmf/audioequalizer.h @@ -51,7 +51,7 @@ public: protected: // AbstractAudioEffect virtual void createEffect(AudioPlayer::NativePlayer *player); - virtual void parameterChanged(const EffectParameter ¶m, + virtual int parameterChanged(const EffectParameter ¶m, const QVariant &value); private: diff --git a/src/3rdparty/phonon/mmf/bassboost.cpp b/src/3rdparty/phonon/mmf/bassboost.cpp index a8631e0..6996ba9 100644 --- a/src/3rdparty/phonon/mmf/bassboost.cpp +++ b/src/3rdparty/phonon/mmf/bassboost.cpp @@ -37,11 +37,12 @@ BassBoost::BassBoost(QObject *parent, const QList ¶meters) } -void BassBoost::parameterChanged(const EffectParameter ¶m, +int BassBoost::parameterChanged(const EffectParameter ¶m, const QVariant &value) { Q_ASSERT_X(param.id() == 0, Q_FUNC_INFO, "Invalid parameter ID"); setEnabled(value.toBool()); + return 0; } //----------------------------------------------------------------------------- diff --git a/src/3rdparty/phonon/mmf/bassboost.h b/src/3rdparty/phonon/mmf/bassboost.h index 82a3bab..e8e8094 100644 --- a/src/3rdparty/phonon/mmf/bassboost.h +++ b/src/3rdparty/phonon/mmf/bassboost.h @@ -46,8 +46,8 @@ public: protected: // AbstractAudioEffect virtual void createEffect(AudioPlayer::NativePlayer *player); - virtual void parameterChanged(const EffectParameter ¶m, - const QVariant &value); + virtual int parameterChanged(const EffectParameter ¶m, + const QVariant &value); private: CBassBoost *concreteEffect(); diff --git a/src/3rdparty/phonon/mmf/environmentalreverb.cpp b/src/3rdparty/phonon/mmf/environmentalreverb.cpp index 2e30ca1..f362afd 100644 --- a/src/3rdparty/phonon/mmf/environmentalreverb.cpp +++ b/src/3rdparty/phonon/mmf/environmentalreverb.cpp @@ -51,7 +51,7 @@ EnvironmentalReverb::EnvironmentalReverb(QObject *parent, const QList& parameters) } -void Loudness::parameterChanged(const EffectParameter ¶m, +int Loudness::parameterChanged(const EffectParameter ¶m, const QVariant &value) { Q_ASSERT_X(param.id() == 0, Q_FUNC_INFO, "Invalid parameter ID"); setEnabled(value.toBool()); + return 0; } //----------------------------------------------------------------------------- diff --git a/src/3rdparty/phonon/mmf/loudness.h b/src/3rdparty/phonon/mmf/loudness.h index f772d7f..bb3380e 100644 --- a/src/3rdparty/phonon/mmf/loudness.h +++ b/src/3rdparty/phonon/mmf/loudness.h @@ -46,8 +46,8 @@ public: protected: // AbstractAudioEffect virtual void createEffect(AudioPlayer::NativePlayer *player); - virtual void parameterChanged(const EffectParameter ¶m, - const QVariant &value); + virtual int parameterChanged(const EffectParameter ¶m, + const QVariant &value); private: CLoudness *concreteEffect(); diff --git a/src/3rdparty/phonon/mmf/stereowidening.cpp b/src/3rdparty/phonon/mmf/stereowidening.cpp index 4fee1aa..d14617d 100644 --- a/src/3rdparty/phonon/mmf/stereowidening.cpp +++ b/src/3rdparty/phonon/mmf/stereowidening.cpp @@ -37,7 +37,7 @@ StereoWidening::StereoWidening(QObject *parent, const QList& pa } -void StereoWidening::parameterChanged(const EffectParameter ¶m, +int StereoWidening::parameterChanged(const EffectParameter ¶m, const QVariant &value) { Q_ASSERT_X(param.id() == 0, Q_FUNC_INFO, "Invalid parameter ID"); @@ -47,8 +47,7 @@ void StereoWidening::parameterChanged(const EffectParameter ¶m, TRAPD(err, concreteEffect()->SetStereoWideningLevelL(internalLevel)); - // TODO: handle audio effect errors - Q_UNUSED(err); + return err; } //----------------------------------------------------------------------------- diff --git a/src/3rdparty/phonon/mmf/stereowidening.h b/src/3rdparty/phonon/mmf/stereowidening.h index 249c279..c967e37 100644 --- a/src/3rdparty/phonon/mmf/stereowidening.h +++ b/src/3rdparty/phonon/mmf/stereowidening.h @@ -46,8 +46,8 @@ public: protected: // AbstractAudioEffect virtual void createEffect(AudioPlayer::NativePlayer *player); - virtual void parameterChanged(const EffectParameter ¶m, - const QVariant &value); + virtual int parameterChanged(const EffectParameter ¶m, + const QVariant &value); private: CStereoWidening *concreteEffect(); -- cgit v0.12 From 24392fb62bb34a80eb7ce13662b0a8744c9ab415 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Mon, 11 Jan 2010 18:08:00 +0000 Subject: Added enable/disable parameter to each effect in Phonon MMF backend Task-number: QTBUG-4659 Reviewed-by: Espen Riskedal --- src/3rdparty/phonon/mmf/abstractaudioeffect.cpp | 33 ++++++++++++++++++++++++- src/3rdparty/phonon/mmf/abstractaudioeffect.h | 17 ++++++++++--- src/3rdparty/phonon/mmf/audioequalizer.cpp | 7 +++--- src/3rdparty/phonon/mmf/audioequalizer.h | 4 +-- src/3rdparty/phonon/mmf/bassboost.cpp | 25 +------------------ src/3rdparty/phonon/mmf/bassboost.h | 2 -- src/3rdparty/phonon/mmf/effectfactory.cpp | 15 +++++++++++ src/3rdparty/phonon/mmf/environmentalreverb.cpp | 4 +-- src/3rdparty/phonon/mmf/environmentalreverb.h | 4 +-- src/3rdparty/phonon/mmf/loudness.cpp | 25 +------------------ src/3rdparty/phonon/mmf/loudness.h | 2 -- src/3rdparty/phonon/mmf/stereowidening.cpp | 4 +-- 12 files changed, 74 insertions(+), 68 deletions(-) diff --git a/src/3rdparty/phonon/mmf/abstractaudioeffect.cpp b/src/3rdparty/phonon/mmf/abstractaudioeffect.cpp index e3672e6..132eb79 100644 --- a/src/3rdparty/phonon/mmf/abstractaudioeffect.cpp +++ b/src/3rdparty/phonon/mmf/abstractaudioeffect.cpp @@ -72,7 +72,6 @@ void AbstractAudioEffect::setParameterValue(const Phonon::EffectParameter ¶m if (m_effect.data()) { const EffectParameter& internalParam = internalParameter(param.id()); int err = parameterChanged(internalParam, newValue); - TRAP(err, m_effect->ApplyL()); // TODO: handle audio effect errors Q_UNUSED(err); } @@ -159,5 +158,37 @@ const MMF::EffectParameter& AbstractAudioEffect::internalParameter(int id) const return *result; } +int AbstractAudioEffect::parameterChanged(const EffectParameter ¶m, + const QVariant &value) +{ + int err = 0; + + switch (param.id()) { + case ParameterEnable: + setEnabled(value.toBool()); + break; + default: + { + const EffectParameter& internalParam = internalParameter(param.id()); + err = effectParameterChanged(internalParam, value); + } + break; + } + + if (!err) + TRAP(err, m_effect->ApplyL()); + + return err; +} + +int AbstractAudioEffect::effectParameterChanged( + const EffectParameter ¶m, const QVariant &value) +{ + // Default implementation + Q_ASSERT_X(false, Q_FUNC_INFO, "Effect has no parameters"); + return 0; +} + + QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/abstractaudioeffect.h b/src/3rdparty/phonon/mmf/abstractaudioeffect.h index a3b35c2..9878472 100644 --- a/src/3rdparty/phonon/mmf/abstractaudioeffect.h +++ b/src/3rdparty/phonon/mmf/abstractaudioeffect.h @@ -72,6 +72,13 @@ public: virtual void setParameterValue(const Phonon::EffectParameter &, const QVariant &newValue); + // Parameters which are shared by all effects + enum CommonParameters + { + ParameterEnable = 0, + ParameterBase // must be last entry in enum + }; + public Q_SLOTS: void abstractPlayerChanged(AbstractPlayer *player); void stateChanged(Phonon::State newState, @@ -82,16 +89,18 @@ protected: void connectMediaObject(MediaObject *mediaObject); void disconnectMediaObject(MediaObject *mediaObject); - void setEnabled(bool enabled); - virtual void createEffect(AudioPlayer::NativePlayer *player) = 0; - virtual int parameterChanged(const EffectParameter ¶m, - const QVariant &value) = 0; + // Effect-specific parameter changed + virtual int effectParameterChanged(const EffectParameter ¶m, + const QVariant &value); 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; diff --git a/src/3rdparty/phonon/mmf/audioequalizer.cpp b/src/3rdparty/phonon/mmf/audioequalizer.cpp index 201a5fc..1d2bbd4 100644 --- a/src/3rdparty/phonon/mmf/audioequalizer.cpp +++ b/src/3rdparty/phonon/mmf/audioequalizer.cpp @@ -37,10 +37,11 @@ AudioEqualizer::AudioEqualizer(QObject *parent, const QList& pa } -int AudioEqualizer::parameterChanged(const EffectParameter ¶m, +int AudioEqualizer::effectParameterChanged(const EffectParameter ¶m, const QVariant &value) { - const int band = param.id() + 1; + const int band = param.id() - ParameterBase + 1; + const qreal externalLevel = value.toReal(); const int internalLevel = param.toInternalValue(externalLevel); @@ -87,7 +88,7 @@ bool AudioEqualizer::getParameters(CMdaAudioOutputStream *stream, // Phonon::EffectWidget. See documentation of EffectParameter // for more details. EffectParameter param( - /* parameterId */ i, + /* parameterId */ ParameterBase + i, /* name */ tr("%1 Hz").arg(hz), /* hints */ EffectParameter::LogarithmicHint, /* defaultValue */ QVariant(qreal(0.0)), diff --git a/src/3rdparty/phonon/mmf/audioequalizer.h b/src/3rdparty/phonon/mmf/audioequalizer.h index acfe9b5..9c3770a 100644 --- a/src/3rdparty/phonon/mmf/audioequalizer.h +++ b/src/3rdparty/phonon/mmf/audioequalizer.h @@ -51,8 +51,8 @@ public: protected: // AbstractAudioEffect virtual void createEffect(AudioPlayer::NativePlayer *player); - virtual int parameterChanged(const EffectParameter ¶m, - const QVariant &value); + virtual int effectParameterChanged(const EffectParameter ¶m, + const QVariant &value); private: CAudioEqualizer *concreteEffect(); diff --git a/src/3rdparty/phonon/mmf/bassboost.cpp b/src/3rdparty/phonon/mmf/bassboost.cpp index 6996ba9..c7af939 100644 --- a/src/3rdparty/phonon/mmf/bassboost.cpp +++ b/src/3rdparty/phonon/mmf/bassboost.cpp @@ -37,14 +37,6 @@ BassBoost::BassBoost(QObject *parent, const QList ¶meters) } -int BassBoost::parameterChanged(const EffectParameter ¶m, - const QVariant &value) -{ - Q_ASSERT_X(param.id() == 0, Q_FUNC_INFO, "Invalid parameter ID"); - setEnabled(value.toBool()); - return 0; -} - //----------------------------------------------------------------------------- // Static functions //----------------------------------------------------------------------------- @@ -57,24 +49,9 @@ const char* BassBoost::description() bool BassBoost::getParameters(CMdaAudioOutputStream *stream, QList ¶meters) { - bool supported = false; - QScopedPointer effect; TRAPD(err, effect.reset(CBassBoost::NewL(*stream))); - - if(KErrNone == err) { - supported = true; - - EffectParameter param( - /* parameterId */ 0, - /* name */ tr("Enabled"), - /* hints */ EffectParameter::ToggledHint, - /* defaultValue */ QVariant(bool(true))); - - parameters.append(param); - } - - return supported; + return (KErrNone == err); } QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/bassboost.h b/src/3rdparty/phonon/mmf/bassboost.h index e8e8094..fc40e21 100644 --- a/src/3rdparty/phonon/mmf/bassboost.h +++ b/src/3rdparty/phonon/mmf/bassboost.h @@ -46,8 +46,6 @@ public: protected: // AbstractAudioEffect virtual void createEffect(AudioPlayer::NativePlayer *player); - virtual int parameterChanged(const EffectParameter ¶m, - const QVariant &value); private: CBassBoost *concreteEffect(); diff --git a/src/3rdparty/phonon/mmf/effectfactory.cpp b/src/3rdparty/phonon/mmf/effectfactory.cpp index 081f6a3..c5e33d5 100644 --- a/src/3rdparty/phonon/mmf/effectfactory.cpp +++ b/src/3rdparty/phonon/mmf/effectfactory.cpp @@ -176,6 +176,13 @@ EffectFactory::EffectData EffectFactory::getData() OutputStreamFactory streamFactory; QScopedPointer stream(streamFactory.create()); + EffectParameter param( + /* parameterId */ AbstractAudioEffect::ParameterEnable, + /* name */ tr("Enabled"), + /* hints */ EffectParameter::ToggledHint, + /* defaultValue */ QVariant(bool(true))); + data.m_parameters.append(param); + if (data.m_supported = BackendNode::getParameters (stream.data(), data.m_parameters)) { const QString description = QCoreApplication::translate @@ -185,6 +192,14 @@ EffectFactory::EffectData EffectFactory::getData() data.m_descriptions.insert("available", true); } + // Sanity check to ensure that all parameter IDs are unique + QSet ids; + foreach (param, data.m_parameters) { + Q_ASSERT_X(ids.find(param.id()) == ids.end(), Q_FUNC_INFO, + "Parameter list contains duplicates"); + ids.insert(param.id()); + } + return data; } diff --git a/src/3rdparty/phonon/mmf/environmentalreverb.cpp b/src/3rdparty/phonon/mmf/environmentalreverb.cpp index f362afd..89f8d60 100644 --- a/src/3rdparty/phonon/mmf/environmentalreverb.cpp +++ b/src/3rdparty/phonon/mmf/environmentalreverb.cpp @@ -33,7 +33,7 @@ PHONON_MMF_DEFINE_EFFECT_FUNCTIONS(EnvironmentalReverb) enum Parameters { - DecayHFRatio, + DecayHFRatio = AbstractAudioEffect::ParameterBase, DecayTime, Density, Diffusion, @@ -51,7 +51,7 @@ EnvironmentalReverb::EnvironmentalReverb(QObject *parent, const QList& parameters) } -int Loudness::parameterChanged(const EffectParameter ¶m, - const QVariant &value) -{ - Q_ASSERT_X(param.id() == 0, Q_FUNC_INFO, "Invalid parameter ID"); - setEnabled(value.toBool()); - return 0; -} - //----------------------------------------------------------------------------- // Static functions //----------------------------------------------------------------------------- @@ -57,24 +49,9 @@ const char* Loudness::description() bool Loudness::getParameters(CMdaAudioOutputStream *stream, QList ¶meters) { - bool supported = false; - QScopedPointer effect; TRAPD(err, effect.reset(CLoudness::NewL(*stream))); - - if(KErrNone == err) { - supported = true; - - EffectParameter param( - /* parameterId */ 0, - /* name */ tr("Enabled"), - /* hints */ EffectParameter::ToggledHint, - /* defaultValue */ QVariant(bool(true))); - - parameters.append(param); - } - - return supported; + return (KErrNone == err); } QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/loudness.h b/src/3rdparty/phonon/mmf/loudness.h index bb3380e..a688a67 100644 --- a/src/3rdparty/phonon/mmf/loudness.h +++ b/src/3rdparty/phonon/mmf/loudness.h @@ -46,8 +46,6 @@ public: protected: // AbstractAudioEffect virtual void createEffect(AudioPlayer::NativePlayer *player); - virtual int parameterChanged(const EffectParameter ¶m, - const QVariant &value); private: CLoudness *concreteEffect(); diff --git a/src/3rdparty/phonon/mmf/stereowidening.cpp b/src/3rdparty/phonon/mmf/stereowidening.cpp index d14617d..f90651b 100644 --- a/src/3rdparty/phonon/mmf/stereowidening.cpp +++ b/src/3rdparty/phonon/mmf/stereowidening.cpp @@ -40,7 +40,7 @@ StereoWidening::StereoWidening(QObject *parent, const QList& pa int StereoWidening::parameterChanged(const EffectParameter ¶m, const QVariant &value) { - Q_ASSERT_X(param.id() == 0, Q_FUNC_INFO, "Invalid parameter ID"); + Q_ASSERT_X(param.id() == ParameterBase, Q_FUNC_INFO, "Invalid parameter ID"); const qreal externalLevel = value.toReal(); const int internalLevel = param.toInternalValue(externalLevel); @@ -75,7 +75,7 @@ bool StereoWidening::getParameters(CMdaAudioOutputStream *stream, (effect->StereoWideningLevel(), 0, 100); EffectParameter param( - /* parameterId */ 0, + /* parameterId */ ParameterBase, /* name */ tr("Level (%)"), /* hints */ EffectParameter::IntegerHint, /* defaultValue */ QVariant(defaultValue), -- cgit v0.12 From bb689ca42deee2034a3475fa0c5f9337ec1aebbb Mon Sep 17 00:00:00 2001 From: axis Date: Tue, 12 Jan 2010 09:20:02 +0100 Subject: Added changelog entries. --- dist/changes-4.6.1 | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/dist/changes-4.6.1 b/dist/changes-4.6.1 index 145e09e..e26cc8d 100644 --- a/dist/changes-4.6.1 +++ b/dist/changes-4.6.1 @@ -145,6 +145,15 @@ Qt for Windows CE - +Qt for Symbian +-------------- + + - QApplication + * [QTBUG-6098] Added a flag to avoid construction of application panes. + + - Other: + * [QTBUG-4990] Rewrote most of the regular pointer handling. + **************************************************************************** * Tools * **************************************************************************** -- cgit v0.12 From 008bae01b016926209dddacc6e31c79b9d99d4f7 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Tue, 12 Jan 2010 12:29:35 +0200 Subject: Added absolute path to sqlite3.sis in s60installs.pro Relative path was only working when package was created from s60installs directory. Binary installer creation requires package creation to work also from Qt root, so added absolute path to sqlite3.sis. Task-number: QTBUG-7275 Reviewed-by: Janne Anttila --- src/s60installs/s60installs.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/s60installs/s60installs.pro b/src/s60installs/s60installs.pro index eb35419..bbc758b 100644 --- a/src/s60installs/s60installs.pro +++ b/src/s60installs/s60installs.pro @@ -36,7 +36,7 @@ symbian: { sqlitedeployment = \ "; Deploy sqlite onto phone that does not have it already" \ - "@\"sqlite3.sis\", (0x2002af5f)" + "@\"$$PWD/sqlite3.sis\", (0x2002af5f)" qtlibraries.pkg_postrules += sqlitedeployment qtlibraries.path = c:/sys/bin -- cgit v0.12