diff options
Diffstat (limited to 'src/3rdparty')
22 files changed, 1136 insertions, 226 deletions
diff --git a/src/3rdparty/phonon/mmf/abstractaudioeffect.cpp b/src/3rdparty/phonon/mmf/abstractaudioeffect.cpp index e7ef9b2453..132eb79957 100644 --- a/src/3rdparty/phonon/mmf/abstractaudioeffect.cpp +++ b/src/3rdparty/phonon/mmf/abstractaudioeffect.cpp @@ -37,18 +37,24 @@ using namespace Phonon::MMF; AbstractAudioEffect::AbstractAudioEffect(QObject *parent, const QList<EffectParameter> ¶ms) - : MediaNode::MediaNode(parent) - , m_player(0) + : MediaNode(parent) , m_params(params) + , m_player(0) { + } -QList<EffectParameter> AbstractAudioEffect::parameters() const +QList<Phonon::EffectParameter> AbstractAudioEffect::parameters() const { - return m_params; + // Convert from QList<MMF::EffectParameter> to QList<Phonon::EffectParameter> + QList<Phonon::EffectParameter> 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()); @@ -58,13 +64,31 @@ 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); - parameterChanged(param.id(), newValue); - // TODO: handle audio effect errors - TRAP_IGNORE(m_effect->ApplyL()); + + if (m_effect.data()) { + const EffectParameter& internalParam = internalParameter(param.id()); + int err = parameterChanged(internalParam, newValue); + // TODO: handle audio effect errors + Q_UNUSED(err); + } +} + +void AbstractAudioEffect::abstractPlayerChanged(AbstractPlayer *player) +{ + m_player = qobject_cast<AbstractMediaPlayer *>(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) @@ -72,26 +96,99 @@ 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<AbstractMediaPlayer *>(mediaObject->abstractPlayer()); + abstractPlayerChanged(mediaObject->abstractPlayer()); + + connect(mediaObject, SIGNAL(stateChanged(Phonon::State, Phonon::State)), + SLOT(stateChanged(Phonon::State, Phonon::State))); + + connect(mediaObject, SIGNAL(abstractPlayerChanged(AbstractPlayer *)), + SLOT(abstractPlayerChanged(AbstractPlayer *))); + + if (mediaObject->state() != Phonon::LoadingState) + createEffect(); +} + +void AbstractAudioEffect::disconnectMediaObject(MediaObject *mediaObject) +{ + mediaObject->disconnect(this); + abstractPlayerChanged(0); +} - if (player) { - m_player = player; +void AbstractAudioEffect::setEnabled(bool enabled) +{ + TInt err = KErrNone; - if (AudioPlayer *audioPlayer = qobject_cast<AudioPlayer *>(player)) { - connectAudioPlayer(audioPlayer->nativePlayer()); - applyParameters(); - // TODO: handle audio effect errors - TRAP_IGNORE(m_effect->EnableL()); + if (enabled) + // TODO: handle audio effect errors + TRAP(err, m_effect->EnableL()) + else + // TODO: handle audio effect errors + TRAP(err, m_effect->DisableL()) + + Q_UNUSED(err); +} + +void AbstractAudioEffect::createEffect() +{ + Q_ASSERT_X(m_player, Q_FUNC_INFO, "Invalid media player pointer"); + + if (AudioPlayer *audioPlayer = qobject_cast<AudioPlayer *>(m_player)) { + createEffect(audioPlayer->nativePlayer()); + } + + if (m_effect.data()) { + EffectParameter param; + int err = 0; + foreach (param, m_params) { + const QVariant value = parameterValue(param); + err = parameterChanged(param, value); } + Q_UNUSED(err) } } -void AbstractAudioEffect::disconnectMediaObject(MediaObject * /*mediaObject*/) +const MMF::EffectParameter& AbstractAudioEffect::internalParameter(int id) const { - m_player = 0; - m_effect.reset(); + const EffectParameter *result = 0; + for (int i=0; i<m_params.count() && !result; ++i) { + if (m_params[i].id() == id) + result = &m_params[i]; + } + Q_ASSERT_X(result, Q_FUNC_INFO, "Parameter not found"); + 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 6f74a73b84..9878472e94 100644 --- a/src/3rdparty/phonon/mmf/abstractaudioeffect.h +++ b/src/3rdparty/phonon/mmf/abstractaudioeffect.h @@ -24,18 +24,21 @@ along with this library. If not, see <http://www.gnu.org/licenses/>. #include <AudioEffectBase.h> #include <Phonon/EffectInterface> -#include <Phonon/EffectParameter> #include "audioplayer.h" +#include "effectparameter.h" #include "mmf_medianode.h" #include "mmf_videoplayer.h" +class CMdaAudioOutputStream; + QT_BEGIN_NAMESPACE namespace Phonon { namespace MMF { +class AbstractPlayer; class AbstractMediaPlayer; /** @@ -63,46 +66,73 @@ public: AbstractAudioEffect(QObject *parent, const QList<EffectParameter> ¶ms); - virtual QList<EffectParameter> parameters() const; - virtual QVariant parameterValue(const EffectParameter ¶m) const; - virtual void setParameterValue(const EffectParameter &, + // Phonon::EffectInterface + virtual QList<Phonon::EffectParameter> parameters() const; + virtual QVariant parameterValue(const Phonon::EffectParameter ¶m) const; + virtual void setParameterValue(const Phonon::EffectParameter &, const QVariant &newValue); - enum Type + // Parameters which are shared by all effects + enum CommonParameters { - EffectAudioEqualizer = 1, - EffectBassBoost, - EffectDistanceAttenuation, - EffectEnvironmentalReverb, - EffectListenerOrientation, - EffectLoudness, - EffectSourceOrientation, - EffectStereoWidening + ParameterEnable = 0, + ParameterBase // must be last entry in enum }; +public Q_SLOTS: + void abstractPlayerChanged(AbstractPlayer *player); + void stateChanged(Phonon::State newState, + Phonon::State oldState); + protected: // MediaNode void connectMediaObject(MediaObject *mediaObject); void disconnectMediaObject(MediaObject *mediaObject); - virtual void connectAudioPlayer(AudioPlayer::NativePlayer *player) = 0; - virtual void applyParameters() = 0; + virtual void createEffect(AudioPlayer::NativePlayer *player) = 0; - virtual void parameterChanged(const int id, - 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<CAudioEffect> m_effect; private: - AbstractMediaPlayer * m_player; const QList<EffectParameter> m_params; + AbstractMediaPlayer * m_player; QHash<int, QVariant> m_values; }; } } + +// Macro for defining functions which depend on the native class name +// for each of the effects. Using this reduces repetition of boilerplate +// in the implementations of the backend effect nodes. + +#define PHONON_MMF_DEFINE_EFFECT_FUNCTIONS(Effect) \ + \ +void Effect##::createEffect(AudioPlayer::NativePlayer *player) \ +{ \ + C##Effect *ptr = 0; \ + QT_TRAP_THROWING(ptr = C##Effect::NewL(*player)); \ + m_effect.reset(ptr); \ +} \ + \ +C##Effect* Effect::concreteEffect() \ +{ \ + return static_cast<C##Effect *>(m_effect.data()); \ +} + QT_END_NAMESPACE #endif diff --git a/src/3rdparty/phonon/mmf/abstractplayer.h b/src/3rdparty/phonon/mmf/abstractplayer.h index 40ad7f8008..dbcbe63b03 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<QString, QString>& metaData); void aboutToFinish(); void prefinishMarkReached(qint32 remaining); diff --git a/src/3rdparty/phonon/mmf/audioequalizer.cpp b/src/3rdparty/phonon/mmf/audioequalizer.cpp index c2936c55c5..1d2bbd4dd0 100644 --- a/src/3rdparty/phonon/mmf/audioequalizer.cpp +++ b/src/3rdparty/phonon/mmf/audioequalizer.cpp @@ -28,80 +28,79 @@ using namespace Phonon::MMF; \internal */ -AudioEqualizer::AudioEqualizer(QObject *parent) : AbstractAudioEffect::AbstractAudioEffect(parent, createParams()) +// Define functions which depend on concrete native effect class name +PHONON_MMF_DEFINE_EFFECT_FUNCTIONS(AudioEqualizer) + +AudioEqualizer::AudioEqualizer(QObject *parent, const QList<EffectParameter>& parameters) + : AbstractAudioEffect::AbstractAudioEffect(parent, parameters) { + } -void AudioEqualizer::parameterChanged(const int pid, +int AudioEqualizer::effectParameterChanged(const EffectParameter ¶m, const QVariant &value) { - if (m_effect.data()) { - const int band = pid; - const int level = value.toInt(); - setBandLevel(band, level); - } -} + const int band = param.id() - ParameterBase + 1; -void AudioEqualizer::connectAudioPlayer(AudioPlayer::NativePlayer *player) -{ - CAudioEqualizer *ptr = 0; - QT_TRAP_THROWING(ptr = CAudioEqualizer::NewL(*player)); - m_effect.reset(ptr); -} + const qreal externalLevel = value.toReal(); + const int internalLevel = param.toInternalValue(externalLevel); -void AudioEqualizer::applyParameters() -{ - if (m_effect.data()) { - EffectParameter param; - foreach (param, parameters()) { - const int band = param.id(); - const int level = parameterValue(param).toInt(); - setBandLevel(band, level); - } - } + TRAPD(err, concreteEffect()->SetBandLevelL(band, internalLevel)); + return err; } -void AudioEqualizer::setBandLevel(int band, int level) + +//----------------------------------------------------------------------------- +// Static functions +//----------------------------------------------------------------------------- + +const char* AudioEqualizer::description() { - CAudioEqualizer *const effect = static_cast<CAudioEqualizer *>(m_effect.data()); - // TODO: handle audio effect errors - TRAP_IGNORE(effect->SetBandLevelL(band, level)); + return "Audio equalizer"; } -QList<EffectParameter> AudioEqualizer::createParams() +bool AudioEqualizer::getParameters(CMdaAudioOutputStream *stream, + QList<EffectParameter>& parameters) { - QList<EffectParameter> retval; + bool supported = false; + + QScopedPointer<CAudioEqualizer> effect; + TRAPD(err, effect.reset(CAudioEqualizer::NewL(*stream))); - // We temporarily create an AudioPlayer, and run the effect on it, so - // we can extract the readonly data we need. - AudioPlayer dummyPlayer; + if (KErrNone == err) { + supported = true; - CAudioEqualizer *eqPtr = 0; - QT_TRAP_THROWING(eqPtr = CAudioEqualizer::NewL(*dummyPlayer.nativePlayer())); - QScopedPointer<CAudioEqualizer> e(eqPtr); + TInt32 dbMin; + TInt32 dbMax; + effect->DbLevelLimits(dbMin, dbMax); - TInt32 dbMin; - TInt32 dbMax; - e->DbLevelLimits(dbMin, dbMax); + const int bandCount = effect->NumberOfBands(); - const int bandCount = e->NumberOfBands(); + 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; - for (int i = 0; i < bandCount; ++i) { - const qint32 hz = e->CenterFrequency(i); + const qint32 hz = effect->CenterFrequency(band); - const qint32 defVol = e->BandLevel(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 */ ParameterBase + 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))); - retval.append(EffectParameter(i, - tr("Frequency band, %1 Hz").arg(hz), - EffectParameter::LogarithmicHint, - QVariant(qint32(defVol)), - QVariant(qint32(dbMin)), - QVariant(qint32(dbMax)), - QVariantList(), - QString())); + param.setInternalRange(dbMin, dbMax); + parameters.append(param); + } } - return retval; + return supported; } QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/audioequalizer.h b/src/3rdparty/phonon/mmf/audioequalizer.h index 10fe9ad297..9c3770a114 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 <http://www.gnu.org/licenses/>. #include "abstractaudioeffect.h" +class CAudioEqualizer; + QT_BEGIN_NAMESPACE namespace Phonon @@ -39,19 +41,21 @@ class AudioEqualizer : public AbstractAudioEffect { Q_OBJECT public: - AudioEqualizer(QObject *parent); + AudioEqualizer(QObject *parent, const QList<EffectParameter> ¶meters); + + // Static interface required by EffectFactory + static const char* description(); + static bool getParameters(CMdaAudioOutputStream *stream, + QList<EffectParameter>& parameters); protected: // AbstractAudioEffect - virtual void connectAudioPlayer(AudioPlayer::NativePlayer *player); - virtual void applyParameters(); - virtual void parameterChanged(const int id, const QVariant &value); - -private: - void setBandLevel(int band, int level); + virtual void createEffect(AudioPlayer::NativePlayer *player); + virtual int effectParameterChanged(const EffectParameter ¶m, + const QVariant &value); private: - static QList<EffectParameter> createParams(); + CAudioEqualizer *concreteEffect(); }; } diff --git a/src/3rdparty/phonon/mmf/backend.cpp b/src/3rdparty/phonon/mmf/backend.cpp index 0c07f66178..3568a49293 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<EffectFactory::Type>(args.first().toInt()); + return m_effectFactory->createAudioEffect(type, parent); } case VideoWidgetClass: result = new VideoWidget(m_ancestorMoveMonitor.data(), qobject_cast<QWidget *>(parent)); @@ -105,7 +106,7 @@ QList<int> 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<QByteArray, QVariant> 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 9e3d3b3aa8..6b85625ca1 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 <http://www.gnu.org/licenses/>. #define PHONON_MMF_BACKEND_H #include "ancestormovemonitor.h" +#include "effectfactory.h" #include <Phonon/MediaSource> #include <Phonon/BackendInterface> @@ -53,6 +54,7 @@ Q_SIGNALS: private: QScopedPointer<AncestorMoveMonitor> m_ancestorMoveMonitor; + QScopedPointer<EffectFactory> m_effectFactory; }; } diff --git a/src/3rdparty/phonon/mmf/bassboost.cpp b/src/3rdparty/phonon/mmf/bassboost.cpp index ae96b456af..c7af93924b 100644 --- a/src/3rdparty/phonon/mmf/bassboost.cpp +++ b/src/3rdparty/phonon/mmf/bassboost.cpp @@ -24,31 +24,34 @@ 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 */ -BassBoost::BassBoost(QObject *parent) : AbstractAudioEffect::AbstractAudioEffect(parent, - QList<EffectParameter>()) +BassBoost::BassBoost(QObject *parent, const QList<EffectParameter> ¶meters) + : AbstractAudioEffect::AbstractAudioEffect(parent, parameters) { -} -void BassBoost::parameterChanged(const int, - const QVariant &) -{ - Q_ASSERT_X(false, Q_FUNC_INFO, "BassBoost has not parameters"); } -void BassBoost::connectAudioPlayer(AudioPlayer::NativePlayer *player) +//----------------------------------------------------------------------------- +// Static functions +//----------------------------------------------------------------------------- + +const char* BassBoost::description() { - CBassBoost *ptr = 0; - QT_TRAP_THROWING(ptr = CBassBoost::NewL(*player)); - m_effect.reset(ptr); + return "Bass boost"; } -void BassBoost::applyParameters() +bool BassBoost::getParameters(CMdaAudioOutputStream *stream, + QList<EffectParameter> ¶meters) { - // No parameters to apply + QScopedPointer<CBassBoost> effect; + TRAPD(err, effect.reset(CBassBoost::NewL(*stream))); + return (KErrNone == err); } QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/bassboost.h b/src/3rdparty/phonon/mmf/bassboost.h index 4ad0a6c49d..fc40e21f6a 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 <http://www.gnu.org/licenses/>. #include "abstractaudioeffect.h" +class CBassBoost; + QT_BEGIN_NAMESPACE namespace Phonon @@ -28,22 +30,25 @@ 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 { Q_OBJECT public: - BassBoost(QObject *parent); + BassBoost(QObject *parent, const QList<EffectParameter> ¶meters); + + // Static interface required by EffectFactory + static const char* description(); + static bool getParameters(CMdaAudioOutputStream *stream, + QList<EffectParameter>& parameters); protected: // AbstractAudioEffect - virtual void connectAudioPlayer(AudioPlayer::NativePlayer *player); - virtual void applyParameters(); - virtual void parameterChanged(const int id, const QVariant &value); + virtual void createEffect(AudioPlayer::NativePlayer *player); + +private: + CBassBoost *concreteEffect(); }; } diff --git a/src/3rdparty/phonon/mmf/effectfactory.cpp b/src/3rdparty/phonon/mmf/effectfactory.cpp index cc94367159..c5e33d5c7a 100644 --- a/src/3rdparty/phonon/mmf/effectfactory.cpp +++ b/src/3rdparty/phonon/mmf/effectfactory.cpp @@ -19,19 +19,13 @@ along with this library. If not, see <http://www.gnu.org/licenses/>. #include <QObject> #include <QCoreApplication> -#include <AudioEqualizerBase.h> -#include <BassBoostBase.h> -#include <DistanceAttenuationBase.h> -#include <DopplerBase.h> -#include <EnvironmentalReverbBase.h> -#include <ListenerOrientationBase.h> -#include <LocationBase.h> -#include <LoudnessBase.h> -#include <SourceOrientationBase.h> -#include <StereoWideningBase.h> +#include <mdaaudiooutputstream.h> #include "audioequalizer.h" #include "bassboost.h" +#include "environmentalreverb.h" +#include "loudness.h" +#include "stereowidening.h" #include "effectfactory.h" @@ -44,111 +38,176 @@ using namespace Phonon::MMF; \internal */ -QHash<QByteArray, QVariant> EffectFactory::constructEffectDescription(const QString &name, - const QString &description) +EffectFactory::EffectFactory(QObject *parent) + : QObject(parent) + , m_initialized(false) { - QHash<QByteArray, QVariant> retval; - retval.insert("name", name); - retval.insert("description", description); - retval.insert("available", true); - - return retval; } - -QHash<QByteArray, QVariant> 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<QByteArray, QVariant>(); } -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<EffectParameter>& 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); + break; + case TypeAudioEqualizer: + effect = new AudioEqualizer(parent, parameters); + break; + case TypeEnvironmentalReverb: + effect = new EnvironmentalReverb(parent, parameters); + break; + case TypeLoudness: + effect = new Loudness(parent, parameters); + break; + case TypeStereoWidening: + effect = new StereoWidening(parent, parameters); + break; + + // Not implemented + case TypeDistanceAttenuation: + case TypeListenerOrientation: + case TypeSourceOrientation: + // Fall through + default: + Q_ASSERT_X(false, Q_FUNC_INFO, "Unknown effect"); } - Q_ASSERT_X(false, Q_FUNC_INFO, "Unknown effect."); - return 0; + return effect; } -template<typename TEffect> -bool isEffectSupported() +QHash<QByteArray, QVariant> EffectFactory::audioEffectDescriptions(Type type) { - AudioPlayer audioPlayer; - - QScopedPointer<TEffect> eff; - TRAPD(errorCode, eff.reset(TEffect::NewL(*audioPlayer.nativePlayer()))); + // Lazily initialize + if (!m_initialized) + initialize(); - return errorCode != KErrNone; + return data(type).m_descriptions; } QList<int> EffectFactory::effectIndexes() { - QList<int> retval; + // Lazily initialize + if (!m_initialized) + initialize(); - if (isEffectSupported<CAudioEqualizer>()) - retval.append(AbstractAudioEffect::EffectAudioEqualizer); + QList<int> result; - if (isEffectSupported<CBassBoost>()) - retval.append(AbstractAudioEffect::EffectBassBoost); + QHash<Type, EffectData>::const_iterator i = m_effectData.begin(); + for ( ; i != m_effectData.end(); ++i) + if (i.value().m_supported) + result.append(i.key()); - /* We haven't implemented these yet. - if (isEffectSupported<CDistanceAttenuation>()) - retval.append(AbstractAudioEffect::EffectDistanceAttenuation); + return result; +} - if (isEffectSupported<CEnvironmentalReverb>()) - retval.append(AbstractAudioEffect::EffectEnvironmentalReverb); +//----------------------------------------------------------------------------- +// Private functions +//----------------------------------------------------------------------------- - if (isEffectSupported<CLoudness>()) - retval.append(AbstractAudioEffect::EffectLoudness); +#define INITIALIZE_EFFECT(Effect) \ + { \ + EffectData data = getData<Effect>(); \ + m_effectData.insert(Type##Effect, data); \ + } - if (isEffectSupported<CListenerOrientation>()) - retval.append(AbstractAudioEffect::EffectListenerOrientation); +void EffectFactory::initialize() +{ + Q_ASSERT_X(!m_initialized, Q_FUNC_INFO, "Already initialized"); - if (isEffectSupported<CSourceOrientation>()) - retval.append(AbstractAudioEffect::EffectSourceOrientation); + INITIALIZE_EFFECT(AudioEqualizer) + INITIALIZE_EFFECT(BassBoost) + INITIALIZE_EFFECT(EnvironmentalReverb) + INITIALIZE_EFFECT(Loudness) + INITIALIZE_EFFECT(StereoWidening) - if (isEffectSupported<CStereoWidening>()) - retval.append(AbstractAudioEffect::EffectStereoWidening); - */ + m_initialized = true; +} + +// 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<typename BackendNode> +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<CMdaAudioOutputStream> 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 + ("Phonon::MMF::EffectFactory", BackendNode::description()); + data.m_descriptions.insert("name", description); + data.m_descriptions.insert("description", description); + data.m_descriptions.insert("available", true); + } + + // Sanity check to ensure that all parameter IDs are unique + QSet<int> 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 retval; + return data; +} + +const EffectFactory::EffectData& EffectFactory::data(Type type) const +{ + QHash<Type, EffectData>::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 e83ad15967..dd4b58d785 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 <http://www.gnu.org/licenses/>. #define PHONON_MMF_EFFECTFACTORY_H #include "abstractaudioeffect.h" +#include "effectparameter.h" QT_BEGIN_NAMESPACE @@ -31,14 +32,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 +63,7 @@ public: * This handles the effects for * BackendInterface::objectDescriptionProperties(). */ - static QHash<QByteArray, QVariant> audioEffectDescriptions(AbstractAudioEffect::Type type); + QHash<QByteArray, QVariant> audioEffectDescriptions(Type type); /** * @short Returns the indexes for the supported effects. @@ -54,19 +71,27 @@ public: * This handles the effects for * BackendInterface::objectDescriptionIndexes(). */ - static QList<int> effectIndexes(); + QList<int> effectIndexes(); private: - static inline QHash<QByteArray, QVariant> constructEffectDescription(const QString &name, - const QString &description); + void initialize(); + + struct EffectData + { + bool m_supported; + QHash<QByteArray, QVariant> m_descriptions; + QList<EffectParameter> m_parameters; + }; + + template<typename BackendNode> EffectData getData(); + const EffectData& data(Type type) const; + +private: + bool m_initialized; + QHash<Type, EffectData> 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/3rdparty/phonon/mmf/effectparameter.cpp b/src/3rdparty/phonon/mmf/effectparameter.cpp new file mode 100644 index 0000000000..17c1315ab5 --- /dev/null +++ b/src/3rdparty/phonon/mmf/effectparameter.cpp @@ -0,0 +1,71 @@ +/* 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 <http://www.gnu.org/licenses/>. + +*/ + +#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<qint32, qint32>(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; +} + +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 new file mode 100644 index 0000000000..27cc018a83 --- /dev/null +++ b/src/3rdparty/phonon/mmf/effectparameter.h @@ -0,0 +1,74 @@ +/* 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 <http://www.gnu.org/licenses/>. + +*/ + +#ifndef PHONON_MMF_EFFECTPARAMETER_H +#define PHONON_MMF_EFFECTPARAMETER_H + +#include <Phonon/EffectParameter> + +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; + + static qreal toExternalValue(qint32 value, qint32 min, qint32 max); + +private: + bool m_hasInternalRange; + QPair<qint32, qint32> m_internalRange; + +}; + +} +} + +QT_END_NAMESPACE + +#endif + diff --git a/src/3rdparty/phonon/mmf/environmentalreverb.cpp b/src/3rdparty/phonon/mmf/environmentalreverb.cpp new file mode 100644 index 0000000000..89f8d60b9f --- /dev/null +++ b/src/3rdparty/phonon/mmf/environmentalreverb.cpp @@ -0,0 +1,201 @@ +/* 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 <http://www.gnu.org/licenses/>. + +*/ + +#include <EnvironmentalReverbBase.h> +#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 = AbstractAudioEffect::ParameterBase, + DecayTime, + Density, + Diffusion, + ReflectionsDelay, + ReflectionsLevel, + ReverbDelay, + ReverbLevel, + RoomHFLevel, + RoomLevel +}; + +EnvironmentalReverb::EnvironmentalReverb(QObject *parent, const QList<EffectParameter>& parameters) + : AbstractAudioEffect::AbstractAudioEffect(parent, parameters) +{ + +} + +int EnvironmentalReverb::effectParameterChanged(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"); + } + + return 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<EffectParameter>& parameters) +{ + bool supported = false; + + QScopedPointer<CEnvironmentalReverb> 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 0000000000..eab68c63cb --- /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 <http://www.gnu.org/licenses/>. + +*/ + +#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<EffectParameter>& parameters); + + // Static interface required by EffectFactory + static const char* description(); + static bool getParameters(CMdaAudioOutputStream *stream, + QList<EffectParameter>& parameters); + +protected: + // AbstractAudioEffect + virtual void createEffect(AudioPlayer::NativePlayer *player); + virtual int effectParameterChanged(const EffectParameter ¶m, + const QVariant &value); + +private: + CEnvironmentalReverb *concreteEffect(); + +}; +} +} + +QT_END_NAMESPACE + +#endif + diff --git a/src/3rdparty/phonon/mmf/loudness.cpp b/src/3rdparty/phonon/mmf/loudness.cpp new file mode 100644 index 0000000000..1079a35653 --- /dev/null +++ b/src/3rdparty/phonon/mmf/loudness.cpp @@ -0,0 +1,58 @@ +/* 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 <http://www.gnu.org/licenses/>. + +*/ + +#include <LoudnessBase.h> +#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<EffectParameter>& parameters) + : AbstractAudioEffect::AbstractAudioEffect(parent, parameters) +{ + +} + +//----------------------------------------------------------------------------- +// Static functions +//----------------------------------------------------------------------------- + +const char* Loudness::description() +{ + return "Loudness"; +} + +bool Loudness::getParameters(CMdaAudioOutputStream *stream, + QList<EffectParameter> ¶meters) +{ + QScopedPointer<CLoudness> effect; + TRAPD(err, effect.reset(CLoudness::NewL(*stream))); + return (KErrNone == err); +} + +QT_END_NAMESPACE + diff --git a/src/3rdparty/phonon/mmf/loudness.h b/src/3rdparty/phonon/mmf/loudness.h new file mode 100644 index 0000000000..a688a67468 --- /dev/null +++ b/src/3rdparty/phonon/mmf/loudness.h @@ -0,0 +1,60 @@ +/* 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 <http://www.gnu.org/licenses/>. + +*/ + +#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<EffectParameter>& parameters); + + // Static interface required by EffectFactory + static const char* description(); + static bool getParameters(CMdaAudioOutputStream *stream, + QList<EffectParameter>& parameters); + +protected: + // AbstractAudioEffect + virtual void createEffect(AudioPlayer::NativePlayer *player); + +private: + CLoudness *concreteEffect(); + +}; +} +} + +QT_END_NAMESPACE + +#endif + diff --git a/src/3rdparty/phonon/mmf/mediaobject.cpp b/src/3rdparty/phonon/mmf/mediaobject.cpp index 4653fee048..97447745f9 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 668b953264..c87d7551b7 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); @@ -101,8 +102,8 @@ Q_SIGNALS: // TODO: emit metaDataChanged from MediaObject void metaDataChanged(const QMultiMap<QString, QString>& 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); diff --git a/src/3rdparty/phonon/mmf/stereowidening.cpp b/src/3rdparty/phonon/mmf/stereowidening.cpp new file mode 100644 index 0000000000..f90651b484 --- /dev/null +++ b/src/3rdparty/phonon/mmf/stereowidening.cpp @@ -0,0 +1,93 @@ +/* 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 <http://www.gnu.org/licenses/>. + +*/ + +#include <StereoWideningBase.h> +#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<EffectParameter>& parameters) + : AbstractAudioEffect::AbstractAudioEffect(parent, parameters) +{ + +} + +int StereoWidening::parameterChanged(const EffectParameter ¶m, + const QVariant &value) +{ + Q_ASSERT_X(param.id() == ParameterBase, Q_FUNC_INFO, "Invalid parameter ID"); + + const qreal externalLevel = value.toReal(); + const int internalLevel = param.toInternalValue(externalLevel); + + TRAPD(err, concreteEffect()->SetStereoWideningLevelL(internalLevel)); + + return err; +} + +//----------------------------------------------------------------------------- +// Static functions +//----------------------------------------------------------------------------- + +const char* StereoWidening::description() +{ + return "Stereo widening"; +} + +bool StereoWidening::getParameters(CMdaAudioOutputStream *stream, + QList<EffectParameter> ¶meters) +{ + bool supported = false; + + QScopedPointer<CStereoWidening> 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 */ ParameterBase, + /* 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 0000000000..c967e37f29 --- /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 <http://www.gnu.org/licenses/>. + +*/ + +#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<EffectParameter>& parameters); + + // Static interface required by EffectFactory + static const char* description(); + static bool getParameters(CMdaAudioOutputStream *stream, + QList<EffectParameter>& parameters); + +protected: + // AbstractAudioEffect + virtual void createEffect(AudioPlayer::NativePlayer *player); + virtual int parameterChanged(const EffectParameter ¶m, + const QVariant &value); + +private: + CStereoWidening *concreteEffect(); + +}; +} +} + +QT_END_NAMESPACE + +#endif + diff --git a/src/3rdparty/phonon/phonon/effectwidget.cpp b/src/3rdparty/phonon/phonon/effectwidget.cpp index 2334d7f978..a2fe50fea4 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 <http://www.gnu.org/licenses/>. */ @@ -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()); |