summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/3rdparty/phonon/mmf/abstractmediaplayer.cpp65
-rw-r--r--src/3rdparty/phonon/mmf/abstractmediaplayer.h20
-rw-r--r--src/3rdparty/phonon/mmf/abstractplayer.cpp2
-rw-r--r--src/3rdparty/phonon/mmf/abstractplayer.h2
-rw-r--r--src/3rdparty/phonon/mmf/abstractvideoplayer.cpp5
-rw-r--r--src/3rdparty/phonon/mmf/audioplayer.cpp6
-rw-r--r--tests/auto/mediaobject/tst_mediaobject.cpp2
7 files changed, 72 insertions, 30 deletions
diff --git a/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp b/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp
index ea2d536..7104ebd 100644
--- a/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp
+++ b/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp
@@ -48,7 +48,7 @@ MMF::AbstractMediaPlayer::AbstractMediaPlayer
(MediaObject *parent, const AbstractPlayer *player)
: AbstractPlayer(player)
, m_parent(parent)
- , m_playPending(false)
+ , m_pending(NothingPending)
, m_positionTimer(new QTimer(this))
, m_bufferStatusTimer(new QTimer(this))
, m_mmfMaxVolume(NullMaxVolume)
@@ -74,7 +74,7 @@ void MMF::AbstractMediaPlayer::play()
break;
case LoadingState:
- m_playPending = true;
+ setPending(PlayPending);
break;
case StoppedState:
@@ -101,14 +101,16 @@ void MMF::AbstractMediaPlayer::pause()
TRACE_CONTEXT(AbstractMediaPlayer::pause, EAudioApi);
TRACE_ENTRY("state %d", privateState());
- m_playPending = false;
stopTimers();
switch (privateState()) {
case GroundState:
case LoadingState:
- case PausedState:
case StoppedState:
+ setPending(PausePending);
+ break;
+
+ case PausedState:
// Do nothing
break;
@@ -133,7 +135,7 @@ void MMF::AbstractMediaPlayer::stop()
TRACE_CONTEXT(AbstractMediaPlayer::stop, EAudioApi);
TRACE_ENTRY("state %d", privateState());
- m_playPending = false;
+ setPending(NothingPending);
stopTimers();
switch (privateState()) {
@@ -363,6 +365,18 @@ void MMF::AbstractMediaPlayer::maxVolumeChanged(int mmfMaxVolume)
doVolumeChanged();
}
+void MMF::AbstractMediaPlayer::loadingComplete(int error)
+{
+ Q_ASSERT(Phonon::LoadingState == state());
+
+ if (KErrNone == error) {
+ updateMetaData();
+ changeState(StoppedState);
+ } else {
+ setError(tr("Loading clip failed"), error);
+ }
+}
+
void MMF::AbstractMediaPlayer::playbackComplete(int error)
{
stopTimers();
@@ -439,6 +453,15 @@ void MMF::AbstractMediaPlayer::resetMarksIfRewound()
m_aboutToFinishSent = false;
}
+void MMF::AbstractMediaPlayer::setPending(Pending pending)
+{
+ const Phonon::State oldState = state();
+ m_pending = pending;
+ const Phonon::State newState = state();
+ if (newState != oldState)
+ emit stateChanged(newState, oldState);
+}
+
void MMF::AbstractMediaPlayer::startPlayback()
{
doPlay();
@@ -451,6 +474,18 @@ void MMF::AbstractMediaPlayer::bufferStatusTick()
emit MMF::AbstractPlayer::bufferStatus(bufferStatus());
}
+Phonon::State MMF::AbstractMediaPlayer::phononState(PrivateState state) const
+{
+ Phonon::State result = AbstractPlayer::phononState(state);
+
+ if (PausePending == m_pending) {
+ Q_ASSERT(Phonon::StoppedState == result || Phonon::LoadingState == result);
+ result = Phonon::PausedState;
+ }
+
+ return result;
+}
+
void MMF::AbstractMediaPlayer::changeState(PrivateState newState)
{
TRACE_CONTEXT(AbstractMediaPlayer::changeState, EAudioInternal);
@@ -462,15 +497,21 @@ void MMF::AbstractMediaPlayer::changeState(PrivateState newState)
// Ensure initial volume is set on MMF API before starting playback
doVolumeChanged();
- // Check whether play() was called while clip was being loaded. If so,
- // playback should be started now
- if (m_playPending) {
- TRACE_0("play was called while loading; starting playback now");
- m_playPending = false;
- startPlayback();
- } else {
+ switch (m_pending) {
+ case NothingPending:
AbstractPlayer::changeState(newState);
+ break;
+
+ case PlayPending:
+ startPlayback();
+ break;
+
+ case PausePending:
+ AbstractPlayer::changeState(PausedState);
+ break;
}
+
+ setPending(NothingPending);
} else {
AbstractPlayer::changeState(newState);
}
diff --git a/src/3rdparty/phonon/mmf/abstractmediaplayer.h b/src/3rdparty/phonon/mmf/abstractmediaplayer.h
index f8f86af..23a8233 100644
--- a/src/3rdparty/phonon/mmf/abstractmediaplayer.h
+++ b/src/3rdparty/phonon/mmf/abstractmediaplayer.h
@@ -60,6 +60,8 @@ public:
protected:
// AbstractPlayer
virtual void doSetTickInterval(qint32 interval);
+ virtual Phonon::State phononState(PrivateState state) const;
+ virtual void changeState(PrivateState newState);
virtual void doPlay() = 0;
virtual void doPause() = 0;
@@ -71,8 +73,6 @@ protected:
virtual int bufferStatus() const = 0;
virtual void close() = 0;
- void changeState(PrivateState newState);
-
void updateMetaData();
virtual int numberOfMetaDataEntries() const = 0;
virtual QPair<QString, QString> metaDataEntry(int index) const = 0;
@@ -81,6 +81,7 @@ protected:
void bufferingStarted();
void bufferingComplete();
void maxVolumeChanged(int maxVolume);
+ void loadingComplete(int error);
void playbackComplete(int error);
static qint64 toMilliSeconds(const TTimeIntervalMicroSeconds &);
@@ -96,6 +97,14 @@ private:
void resetMarksIfRewound();
void startPlayback();
+ enum Pending {
+ NothingPending,
+ PausePending,
+ PlayPending
+ };
+
+ void setPending(Pending pending);
+
private Q_SLOTS:
void positionTick();
void bufferStatusTick();
@@ -103,12 +112,7 @@ private Q_SLOTS:
private:
MediaObject *const m_parent;
- /**
- * This flag is set to true if play is called when the object is
- * in a Loading state. Once loading is complete, playback will
- * be started.
- */
- bool m_playPending;
+ Pending m_pending;
QScopedPointer<QTimer> m_positionTimer;
diff --git a/src/3rdparty/phonon/mmf/abstractplayer.cpp b/src/3rdparty/phonon/mmf/abstractplayer.cpp
index 421155b..8c3f5cb 100644
--- a/src/3rdparty/phonon/mmf/abstractplayer.cpp
+++ b/src/3rdparty/phonon/mmf/abstractplayer.cpp
@@ -141,7 +141,7 @@ Phonon::State MMF::AbstractPlayer::phononState() const
return phononState(m_state);
}
-Phonon::State MMF::AbstractPlayer::phononState(PrivateState state)
+Phonon::State MMF::AbstractPlayer::phononState(PrivateState state) const
{
const Phonon::State phononState =
GroundState == state
diff --git a/src/3rdparty/phonon/mmf/abstractplayer.h b/src/3rdparty/phonon/mmf/abstractplayer.h
index 92bd87e..ab892f5 100644
--- a/src/3rdparty/phonon/mmf/abstractplayer.h
+++ b/src/3rdparty/phonon/mmf/abstractplayer.h
@@ -133,7 +133,7 @@ protected:
/**
* Converts PrivateState into the corresponding Phonon::State
*/
- static Phonon::State phononState(PrivateState state);
+ virtual Phonon::State phononState(PrivateState state) const;
virtual void videoOutputChanged();
diff --git a/src/3rdparty/phonon/mmf/abstractvideoplayer.cpp b/src/3rdparty/phonon/mmf/abstractvideoplayer.cpp
index c2bcce0..2e0ab1c 100644
--- a/src/3rdparty/phonon/mmf/abstractvideoplayer.cpp
+++ b/src/3rdparty/phonon/mmf/abstractvideoplayer.cpp
@@ -268,11 +268,10 @@ void MMF::AbstractVideoPlayer::MvpuoPrepareComplete(TInt aError)
handlePendingParametersChanged();
emit totalTimeChanged(totalTime());
- changeState(StoppedState);
- } else {
- setError(tr("Buffering clip failed"), err);
}
+ loadingComplete(aError);
+
TRACE_EXIT_0();
}
diff --git a/src/3rdparty/phonon/mmf/audioplayer.cpp b/src/3rdparty/phonon/mmf/audioplayer.cpp
index ee07229..77a0964 100644
--- a/src/3rdparty/phonon/mmf/audioplayer.cpp
+++ b/src/3rdparty/phonon/mmf/audioplayer.cpp
@@ -203,12 +203,10 @@ void MMF::AudioPlayer::MapcInitComplete(TInt aError,
maxVolumeChanged(m_player->MaxVolume());
m_totalTime = toMilliSeconds(m_player->Duration());
emit totalTimeChanged(m_totalTime);
- updateMetaData();
- changeState(StoppedState);
- } else {
- setError(tr("Opening clip failed"), aError);
}
+ loadingComplete(aError);
+
TRACE_EXIT_0();
}
diff --git a/tests/auto/mediaobject/tst_mediaobject.cpp b/tests/auto/mediaobject/tst_mediaobject.cpp
index 127b775..994057b 100644
--- a/tests/auto/mediaobject/tst_mediaobject.cpp
+++ b/tests/auto/mediaobject/tst_mediaobject.cpp
@@ -575,7 +575,7 @@ void tst_MediaObject::playSDP()
// MediaObject should have loaded the SDP, but be in error state due to absent media
const bool stateMatch = (m_media->state() == Phonon::ErrorState);
- const bool errorStringMatch = (m_media->errorString() == QString::fromLatin1("Buffering clip failed: Unknown error (-39)"));
+ const bool errorStringMatch = (m_media->errorString() == QString::fromLatin1("Loading clip failed: Unknown error (-39)"));
// Ensure that m_media is back in ground state prior to starting next test step
m_media->setCurrentSource(oldSource);