summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaurice Kalinowski <maurice.kalinowski@theqtcompany.com>2016-01-18 15:52:14 +0100
committerMaurice Kalinowski <maurice.kalinowski@theqtcompany.com>2016-01-18 15:39:43 +0000
commitc9a841a37614cc2b4f70df935fc097d4627f04a3 (patch)
treef975d86ef6b84b586f88e69d2390dad2aceb36f4
parent406f76b90342bfcfb982ea40a2c3141dc8556dbd (diff)
downloadqtmultimedia-c9a841a37614cc2b4f70df935fc097d4627f04a3.tar.gz
winrt: Fix playback of files
The backend uses triple buffering in the background to prefetch some buffers. However, at some point it tries to invoke SetCurrentPosition beyond the end of the file. MSDN states that for IMFByteStream one should return E_INVALIDARG, but that has negative sideeffects. What happens is that immediately MF_MEDIA_ENGINE_ERR_DECODE is sent causing the playback to stop, even if there are still valid buffers in the queue. The example in the bug reports causes up to 5 seconds of playback to be lost. This can also be reproduced with larger files. To circumvent this, return S_FALSE instead to still notify that seeking in the buffer did not work. Task-number: QTBUG-49236 Change-Id: Id4b093bf9480f5d02c7f9191fa4424f51c60e078 Reviewed-by: Andrew Knight <andrew.knight@intopalo.com> Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
-rw-r--r--src/plugins/winrt/qwinrtmediaplayercontrol.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/plugins/winrt/qwinrtmediaplayercontrol.cpp b/src/plugins/winrt/qwinrtmediaplayercontrol.cpp
index ed2dbb943..d00788e64 100644
--- a/src/plugins/winrt/qwinrtmediaplayercontrol.cpp
+++ b/src/plugins/winrt/qwinrtmediaplayercontrol.cpp
@@ -388,8 +388,13 @@ public:
HRESULT __stdcall SetCurrentPosition(QWORD position)
{
qint64 pos(position);
- if (pos >= d->stream->size())
- return E_INVALIDARG;
+ if (pos >= d->stream->size()) {
+ // MSDN states we should return E_INVALIDARG, but that immediately
+ // stops playback and does not play remaining buffers in the queue.
+ // For some formats this can cause losing up to 5 seconds of the
+ // end of the stream.
+ return S_FALSE;
+ }
const bool ok = d->stream->seek(pos);
return ok ? S_OK : S_FALSE;