diff options
author | Yoann Lopes <yoann.lopes@theqtcompany.com> | 2015-11-01 17:17:12 +0100 |
---|---|---|
committer | Yoann Lopes <yoann.lopes@theqtcompany.com> | 2016-01-06 15:20:50 +0000 |
commit | 4fcf153d688097f504d6ee454adfeecb7ec6bfd8 (patch) | |
tree | 66b2551d65036634e38c1cbdb3c4f07c7baf1cfb /src/plugins/directshow/player/directshowplayerservice.cpp | |
parent | 315a946e4088f9b5e8c4aad76fbb155654688172 (diff) | |
download | qtmultimedia-4fcf153d688097f504d6ee454adfeecb7ec6bfd8.tar.gz |
DirectShow: fix media player's positionChanged() signal.
The signal was not emitted at the right time or with incorrect values
under certain circumstances.
Change-Id: Ib8b1d38381d908399752856db7b0a987c4422bb1
Reviewed-by: Christian Stromme <christian.stromme@theqtcompany.com>
Diffstat (limited to 'src/plugins/directshow/player/directshowplayerservice.cpp')
-rw-r--r-- | src/plugins/directshow/player/directshowplayerservice.cpp | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/src/plugins/directshow/player/directshowplayerservice.cpp b/src/plugins/directshow/player/directshowplayerservice.cpp index 07427583d..eac37f538 100644 --- a/src/plugins/directshow/player/directshowplayerservice.cpp +++ b/src/plugins/directshow/player/directshowplayerservice.cpp @@ -103,6 +103,7 @@ DirectShowPlayerService::DirectShowPlayerService(QObject *parent) , m_buffering(false) , m_seekable(false) , m_atEnd(false) + , m_dontCacheNextSeekResult(false) { m_playerControl = new DirectShowPlayerControl(this); m_metaDataControl = new DirectShowMetaDataControl(this); @@ -229,6 +230,7 @@ void DirectShowPlayerService::load(const QMediaContent &media, QIODevice *stream m_buffering = false; m_seekable = false; m_atEnd = false; + m_dontCacheNextSeekResult = false; m_metaDataControl->updateGraph(0, 0); if (m_resources.isEmpty() && !stream) { @@ -672,7 +674,9 @@ void DirectShowPlayerService::play() if (m_executedTasks & Stop) { m_atEnd = false; if (m_seekPosition == -1) { + m_dontCacheNextSeekResult = true; m_seekPosition = 0; + m_position = 0; m_pendingTasks |= Seek; } m_executedTasks ^= Stop; @@ -718,7 +722,9 @@ void DirectShowPlayerService::pause() if (m_executedTasks & Stop) { m_atEnd = false; if (m_seekPosition == -1) { + m_dontCacheNextSeekResult = true; m_seekPosition = 0; + m_position = 0; m_pendingTasks |= Seek; } m_executedTasks ^= Stop; @@ -791,6 +797,8 @@ void DirectShowPlayerService::doStop(QMutexLocker *locker) } m_seekPosition = 0; + m_position = 0; + m_dontCacheNextSeekResult = true; m_pendingTasks |= Seek; m_executedTasks &= ~(Play | Pause); @@ -913,8 +921,10 @@ void DirectShowPlayerService::doSeek(QMutexLocker *locker) // Cache current values as we can't query IMediaSeeking during a seek due to the // possibility of a deadlock when flushing the VideoSurfaceFilter. LONGLONG currentPosition = 0; - seeking->GetCurrentPosition(¤tPosition); - m_position = currentPosition / qt_directShowTimeScale; + if (!m_dontCacheNextSeekResult) { + seeking->GetCurrentPosition(¤tPosition); + m_position = currentPosition / qt_directShowTimeScale; + } LONGLONG minimum = 0; LONGLONG maximum = 0; @@ -928,8 +938,10 @@ void DirectShowPlayerService::doSeek(QMutexLocker *locker) &seekPosition, AM_SEEKING_AbsolutePositioning, 0, AM_SEEKING_NoPositioning); locker->relock(); - seeking->GetCurrentPosition(¤tPosition); - m_position = currentPosition / qt_directShowTimeScale; + if (!m_dontCacheNextSeekResult) { + seeking->GetCurrentPosition(¤tPosition); + m_position = currentPosition / qt_directShowTimeScale; + } seeking->Release(); @@ -937,6 +949,7 @@ void DirectShowPlayerService::doSeek(QMutexLocker *locker) } m_seekPosition = -1; + m_dontCacheNextSeekResult = false; } int DirectShowPlayerService::bufferStatus() const |