mfplat: Implement IMFByteStream::SetCurrentPosition() for file streams.

Signed-off-by: Derek Lesho <dlesho@codeweavers.com>
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
feature/deterministic
Derek Lesho 2020-02-12 08:46:37 +03:00 committed by Alexandre Julliard
parent 107c616bc4
commit 37d977da22
2 changed files with 42 additions and 28 deletions

View File

@ -3287,22 +3287,18 @@ static HRESULT WINAPI mfbytestream_SetLength(IMFByteStream *iface, QWORD length)
return E_NOTIMPL;
}
static HRESULT WINAPI mfbytestream_GetCurrentPosition(IMFByteStream *iface, QWORD *position)
static HRESULT WINAPI bytestream_file_GetCurrentPosition(IMFByteStream *iface, QWORD *position)
{
mfbytestream *This = impl_from_IMFByteStream(iface);
struct bytestream *stream = impl_from_IMFByteStream(iface);
FIXME("%p, %p\n", This, position);
TRACE("%p, %p.\n", iface, position);
return E_NOTIMPL;
}
if (!position)
return E_INVALIDARG;
static HRESULT WINAPI mfbytestream_SetCurrentPosition(IMFByteStream *iface, QWORD position)
{
mfbytestream *This = impl_from_IMFByteStream(iface);
*position = stream->position;
FIXME("%p, %s\n", This, wine_dbgstr_longlong(position));
return E_NOTIMPL;
return S_OK;
}
static HRESULT WINAPI bytestream_file_GetLength(IMFByteStream *iface, QWORD *length)
@ -3445,6 +3441,19 @@ static HRESULT WINAPI mfbytestream_Close(IMFByteStream *iface)
return E_NOTIMPL;
}
static HRESULT WINAPI bytestream_SetCurrentPosition(IMFByteStream *iface, QWORD position)
{
struct bytestream *stream = impl_from_IMFByteStream(iface);
TRACE("%p, %s.\n", iface, wine_dbgstr_longlong(position));
EnterCriticalSection(&stream->cs);
stream->position = position;
LeaveCriticalSection(&stream->cs);
return S_OK;
}
static const IMFByteStreamVtbl bytestream_file_vtbl =
{
bytestream_QueryInterface,
@ -3453,8 +3462,8 @@ static const IMFByteStreamVtbl bytestream_file_vtbl =
bytestream_GetCapabilities,
bytestream_file_GetLength,
mfbytestream_SetLength,
mfbytestream_GetCurrentPosition,
mfbytestream_SetCurrentPosition,
bytestream_file_GetCurrentPosition,
bytestream_SetCurrentPosition,
bytestream_file_IsEndOfStream,
bytestream_file_Read,
bytestream_BeginRead,
@ -3512,19 +3521,6 @@ static HRESULT WINAPI bytestream_stream_GetCurrentPosition(IMFByteStream *iface,
return S_OK;
}
static HRESULT WINAPI bytestream_stream_SetCurrentPosition(IMFByteStream *iface, QWORD position)
{
struct bytestream *stream = impl_from_IMFByteStream(iface);
TRACE("%p, %s.\n", iface, wine_dbgstr_longlong(position));
EnterCriticalSection(&stream->cs);
stream->position = position;
LeaveCriticalSection(&stream->cs);
return S_OK;
}
static HRESULT WINAPI bytestream_stream_IsEndOfStream(IMFByteStream *iface, BOOL *ret)
{
struct bytestream *stream = impl_from_IMFByteStream(iface);
@ -3642,7 +3638,7 @@ static const IMFByteStreamVtbl bytestream_stream_vtbl =
bytestream_stream_GetLength,
bytestream_stream_SetLength,
bytestream_stream_GetCurrentPosition,
bytestream_stream_SetCurrentPosition,
bytestream_SetCurrentPosition,
bytestream_stream_IsEndOfStream,
bytestream_stream_Read,
bytestream_BeginRead,

View File

@ -1340,15 +1340,16 @@ static void test_MFCreateMFByteStreamOnStream(void)
static void test_file_stream(void)
{
IMFByteStream *bytestream, *bytestream2;
QWORD bytestream_length, position;
IMFAttributes *attributes = NULL;
MF_ATTRIBUTE_TYPE item_type;
QWORD bytestream_length;
WCHAR pathW[MAX_PATH];
DWORD caps, count;
WCHAR *filename;
IUnknown *unk;
HRESULT hr;
WCHAR *str;
BOOL eos;
static const WCHAR newfilename[] = {'n','e','w','.','m','p','4',0};
@ -1415,6 +1416,23 @@ static void test_file_stream(void)
ok(hr == S_OK, "Failed to get bytestream length, hr %#x.\n", hr);
ok(bytestream_length > 0, "Unexpected bytestream length %s.\n", wine_dbgstr_longlong(bytestream_length));
hr = IMFByteStream_SetCurrentPosition(bytestream, bytestream_length);
ok(hr == S_OK, "Failed to set bytestream position, hr %#x.\n", hr);
hr = IMFByteStream_IsEndOfStream(bytestream, &eos);
ok(hr == S_OK, "Failed query end of stream, hr %#x.\n", hr);
ok(eos == TRUE, "Unexpected IsEndOfStream result, %u.\n", eos);
hr = IMFByteStream_SetCurrentPosition(bytestream, 2 * bytestream_length);
ok(hr == S_OK, "Failed to set bytestream position, hr %#x.\n", hr);
hr = IMFByteStream_GetCurrentPosition(bytestream, NULL);
ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
hr = IMFByteStream_GetCurrentPosition(bytestream, &position);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
ok(position == 2 * bytestream_length, "Unexpected position.\n");
hr = MFCreateFile(MF_ACCESSMODE_READ, MF_OPENMODE_FAIL_IF_NOT_EXIST,
MF_FILEFLAGS_NONE, filename, &bytestream2);
ok(hr == S_OK, "got 0x%08x\n", hr);