diff options
author | Gareth Stockwell <ext-gareth.stockwell@nokia.com> | 2010-01-11 15:30:15 (GMT) |
---|---|---|
committer | Gareth Stockwell <ext-gareth.stockwell@nokia.com> | 2010-01-11 15:30:15 (GMT) |
commit | e53306725e52407146304df9d8d3a65920fc3e8d (patch) | |
tree | b3b8f4d25616ac8171af60f86ad1c060d26ac33c /src/3rdparty/phonon/mmf/abstractaudioeffect.cpp | |
parent | 483893142dcec15c646ef997309dcede76466766 (diff) | |
download | Qt-e53306725e52407146304df9d8d3a65920fc3e8d.zip Qt-e53306725e52407146304df9d8d3a65920fc3e8d.tar.gz Qt-e53306725e52407146304df9d8d3a65920fc3e8d.tar.bz2 |
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
Diffstat (limited to 'src/3rdparty/phonon/mmf/abstractaudioeffect.cpp')
-rw-r--r-- | src/3rdparty/phonon/mmf/abstractaudioeffect.cpp | 59 |
1 files changed, 43 insertions, 16 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<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) @@ -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<AbstractMediaPlayer *>(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<AudioPlayer *>(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<AudioPlayer *>(m_player)) { + createEffect(audioPlayer->nativePlayer()); + } + + if (m_effect.data()) { + applyParameters(); + // TODO: handle audio effect errors + TRAP_IGNORE(m_effect->EnableL()); + } } QT_END_NAMESPACE |