summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp
diff options
context:
space:
mode:
authorGareth Stockwell <ext-gareth.stockwell@nokia.com>2009-12-01 17:55:30 (GMT)
committerGareth Stockwell <ext-gareth.stockwell@nokia.com>2009-12-08 11:15:28 (GMT)
commitbed33ac62d87073120d56ff75a3d2356c99c64ea (patch)
tree5a949097061061981afe3d92a32855591ebcd8bd /src/3rdparty/phonon/mmf/abstractmediaplayer.cpp
parent3117e3a6a9c1bf95fc30ebee4d8d11b646cb7125 (diff)
downloadQt-bed33ac62d87073120d56ff75a3d2356c99c64ea.zip
Qt-bed33ac62d87073120d56ff75a3d2356c99c64ea.tar.gz
Qt-bed33ac62d87073120d56ff75a3d2356c99c64ea.tar.bz2
Implemented buffer status notifications in Phonon MMF backend
When clips are buffering (either at the start of playback, or during playback, when buffer levels drop due to e.g. CPU, file system or network load), the backend receives notification from the MMF. While buffering is ongoing, the backend periodically queries the filling status and emits a signal. Task-number: QTBUG-4660 Reviewed-by: Frans Englich
Diffstat (limited to 'src/3rdparty/phonon/mmf/abstractmediaplayer.cpp')
-rw-r--r--src/3rdparty/phonon/mmf/abstractmediaplayer.cpp80
1 files changed, 61 insertions, 19 deletions
diff --git a/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp b/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp
index 260d8e6..6e7f458 100644
--- a/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp
+++ b/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp
@@ -36,6 +36,7 @@ using namespace Phonon::MMF;
//-----------------------------------------------------------------------------
const int NullMaxVolume = -1;
+const int BufferStatusTimerInterval = 100; // ms
//-----------------------------------------------------------------------------
@@ -44,19 +45,23 @@ const int NullMaxVolume = -1;
MMF::AbstractMediaPlayer::AbstractMediaPlayer() :
m_playPending(false)
- , m_tickTimer(new QTimer(this))
+ , m_positionTimer(new QTimer(this))
+ , m_bufferStatusTimer(new QTimer(this))
, m_mmfMaxVolume(NullMaxVolume)
{
- connect(m_tickTimer.data(), SIGNAL(timeout()), this, SLOT(tick()));
+ connect(m_positionTimer.data(), SIGNAL(timeout()), this, SLOT(positionTick()));
+ connect(m_bufferStatusTimer.data(), SIGNAL(timeout()), this, SLOT(bufferStatusTick()));
}
MMF::AbstractMediaPlayer::AbstractMediaPlayer(const AbstractPlayer& player) :
AbstractPlayer(player)
, m_playPending(false)
- , m_tickTimer(new QTimer(this))
+ , m_positionTimer(new QTimer(this))
+ , m_bufferStatusTimer(new QTimer(this))
, m_mmfMaxVolume(NullMaxVolume)
{
- connect(m_tickTimer.data(), SIGNAL(timeout()), this, SLOT(tick()));
+ connect(m_positionTimer.data(), SIGNAL(timeout()), this, SLOT(positionTick()));
+ connect(m_bufferStatusTimer.data(), SIGNAL(timeout()), this, SLOT(bufferStatusTick()));
}
//-----------------------------------------------------------------------------
@@ -80,7 +85,7 @@ void MMF::AbstractMediaPlayer::play()
case StoppedState:
case PausedState:
doPlay();
- startTickTimer();
+ startPositionTimer();
changeState(PlayingState);
break;
@@ -104,7 +109,7 @@ void MMF::AbstractMediaPlayer::pause()
TRACE_ENTRY("state %d", privateState());
m_playPending = false;
- stopTickTimer();
+ stopTimers();
switch (privateState()) {
case GroundState:
@@ -136,7 +141,7 @@ void MMF::AbstractMediaPlayer::stop()
TRACE_ENTRY("state %d", privateState());
m_playPending = false;
- stopTickTimer();
+ stopTimers();
switch (privateState()) {
case GroundState:
@@ -174,14 +179,13 @@ void MMF::AbstractMediaPlayer::seek(qint64 ms)
case PlayingState:
case LoadingState:
{
- const bool tickTimerWasRunning = m_tickTimer->isActive();
- stopTickTimer();
+ const bool positionTimerWasRunning = m_positionTimer->isActive();
+ stopPositionTimer();
doSeek(ms);
- if (tickTimerWasRunning) {
- startTickTimer();
- }
+ if (positionTimerWasRunning)
+ startPositionTimer();
break;
}
case BufferingState:
@@ -204,7 +208,7 @@ void MMF::AbstractMediaPlayer::doSetTickInterval(qint32 interval)
TRACE_CONTEXT(AbstractMediaPlayer::doSetTickInterval, EAudioApi);
TRACE_ENTRY("state %d m_interval %d interval %d", privateState(), tickInterval(), interval);
- m_tickTimer->setInterval(interval);
+ m_positionTimer->setInterval(interval);
TRACE_EXIT_0();
}
@@ -307,6 +311,35 @@ void MMF::AbstractMediaPlayer::volumeChanged(qreal volume)
TRACE_EXIT_0();
}
+//-----------------------------------------------------------------------------
+// Private functions
+//-----------------------------------------------------------------------------
+
+void MMF::AbstractMediaPlayer::startPositionTimer()
+{
+ m_positionTimer->start(tickInterval());
+}
+
+void MMF::AbstractMediaPlayer::stopPositionTimer()
+{
+ m_positionTimer->stop();
+}
+
+void MMF::AbstractMediaPlayer::startBufferStatusTimer()
+{
+ m_bufferStatusTimer->start(BufferStatusTimerInterval);
+}
+
+void MMF::AbstractMediaPlayer::stopBufferStatusTimer()
+{
+ m_bufferStatusTimer->stop();
+}
+
+void MMF::AbstractMediaPlayer::stopTimers()
+{
+ stopPositionTimer();
+ stopBufferStatusTimer();
+}
void MMF::AbstractMediaPlayer::doVolumeChanged()
{
@@ -342,14 +375,19 @@ void MMF::AbstractMediaPlayer::doVolumeChanged()
// Protected functions
//-----------------------------------------------------------------------------
-void MMF::AbstractMediaPlayer::startTickTimer()
+void MMF::AbstractMediaPlayer::bufferingStarted()
{
- m_tickTimer->start(tickInterval());
+ m_stateBeforeBuffering = privateState();
+ changeState(BufferingState);
+ bufferStatusTick();
+ startBufferStatusTimer();
}
-void MMF::AbstractMediaPlayer::stopTickTimer()
+void MMF::AbstractMediaPlayer::bufferingComplete()
{
- m_tickTimer->stop();
+ stopBufferStatusTimer();
+ emit MMF::AbstractPlayer::bufferStatus(100);
+ changeState(m_stateBeforeBuffering);
}
void MMF::AbstractMediaPlayer::maxVolumeChanged(int mmfMaxVolume)
@@ -367,12 +405,16 @@ qint64 MMF::AbstractMediaPlayer::toMilliSeconds(const TTimeIntervalMicroSeconds
// Slots
//-----------------------------------------------------------------------------
-void MMF::AbstractMediaPlayer::tick()
+void MMF::AbstractMediaPlayer::positionTick()
{
- // For the MWC compiler, we need to qualify the base class.
emit MMF::AbstractPlayer::tick(currentTime());
}
+void MMF::AbstractMediaPlayer::bufferStatusTick()
+{
+ emit MMF::AbstractPlayer::bufferStatus(bufferStatus());
+}
+
void MMF::AbstractMediaPlayer::changeState(PrivateState newState)
{
TRACE_CONTEXT(AbstractMediaPlayer::changeState, EAudioInternal);