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>
This commit is contained in:
Maurice Kalinowski
2016-01-18 15:52:14 +01:00
parent 406f76b903
commit c9a841a376

View File

@@ -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;