Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/mfplat/main.c | 8 +++++--- dlls/mfplat/tests/mfplat.c | 41 +++++++++++++++----------------------- 2 files changed, 21 insertions(+), 28 deletions(-)
diff --git a/dlls/mfplat/main.c b/dlls/mfplat/main.c index 57bed4ac3e..6aaa29daa3 100644 --- a/dlls/mfplat/main.c +++ b/dlls/mfplat/main.c @@ -1971,6 +1971,7 @@ typedef struct bytestream IMFAsyncCallback read_callback; IMFAsyncCallback write_callback; IStream *stream; + HANDLE hfile; QWORD position; DWORD capabilities; struct list pending; @@ -2235,6 +2236,8 @@ static ULONG WINAPI bytestream_Release(IMFByteStream *iface) DeleteCriticalSection(&stream->cs); if (stream->stream) IStream_Release(stream->stream); + if (stream->hfile) + CloseHandle(stream->hfile); heap_free(stream); }
@@ -2820,7 +2823,7 @@ static const IMFGetServiceVtbl bytestream_file_getservice_vtbl = HRESULT WINAPI MFCreateFile(MF_FILE_ACCESSMODE accessmode, MF_FILE_OPENMODE openmode, MF_FILE_FLAGS flags, LPCWSTR url, IMFByteStream **bytestream) { - mfbytestream *object; + struct bytestream *object; DWORD fileaccessmode = 0; DWORD filesharemode = FILE_SHARE_READ; DWORD filecreation_disposition = 0; @@ -2894,6 +2897,7 @@ HRESULT WINAPI MFCreateFile(MF_FILE_ACCESSMODE accessmode, MF_FILE_OPENMODE open object->write_callback.lpVtbl = &bytestream_file_write_callback_vtbl; InitializeCriticalSection(&object->cs); list_init(&object->pending); + object->hfile = file;
if (GetFileTime(file, NULL, NULL, &writetime)) { @@ -2905,8 +2909,6 @@ HRESULT WINAPI MFCreateFile(MF_FILE_ACCESSMODE accessmode, MF_FILE_OPENMODE open
*bytestream = &object->IMFByteStream_iface;
- CloseHandle(file); - return S_OK; }
diff --git a/dlls/mfplat/tests/mfplat.c b/dlls/mfplat/tests/mfplat.c index 6c6bfc16b6..f280a35a58 100644 --- a/dlls/mfplat/tests/mfplat.c +++ b/dlls/mfplat/tests/mfplat.c @@ -1187,15 +1187,11 @@ todo_wine ok(hr == S_OK, "got 0x%08x\n", hr); IMFByteStream_Release(bytestream2);
- hr = MFCreateFile(MF_ACCESSMODE_WRITE, MF_OPENMODE_FAIL_IF_NOT_EXIST, - MF_FILEFLAGS_NONE, filename, &bytestream2); - todo_wine ok(hr == HRESULT_FROM_WIN32(ERROR_SHARING_VIOLATION), "got 0x%08x\n", hr); - if (hr == S_OK) IMFByteStream_Release(bytestream2); + hr = MFCreateFile(MF_ACCESSMODE_WRITE, MF_OPENMODE_FAIL_IF_NOT_EXIST, MF_FILEFLAGS_NONE, filename, &bytestream2); + ok(hr == HRESULT_FROM_WIN32(ERROR_SHARING_VIOLATION), "Unexpected hr %#x.\n", hr);
- hr = MFCreateFile(MF_ACCESSMODE_READWRITE, MF_OPENMODE_FAIL_IF_NOT_EXIST, - MF_FILEFLAGS_NONE, filename, &bytestream2); - todo_wine ok(hr == HRESULT_FROM_WIN32(ERROR_SHARING_VIOLATION), "got 0x%08x\n", hr); - if (hr == S_OK) IMFByteStream_Release(bytestream2); + hr = MFCreateFile(MF_ACCESSMODE_READWRITE, MF_OPENMODE_FAIL_IF_NOT_EXIST, MF_FILEFLAGS_NONE, filename, &bytestream2); + ok(hr == HRESULT_FROM_WIN32(ERROR_SHARING_VIOLATION), "Unexpected hr %#x.\n", hr);
IMFByteStream_Release(bytestream);
@@ -1211,20 +1207,15 @@ todo_wine MF_FILEFLAGS_NONE, newfilename, &bytestream); ok(hr == S_OK, "got 0x%08x\n", hr);
- hr = MFCreateFile(MF_ACCESSMODE_READ, MF_OPENMODE_FAIL_IF_NOT_EXIST, - MF_FILEFLAGS_NONE, newfilename, &bytestream2); - todo_wine ok(hr == HRESULT_FROM_WIN32(ERROR_SHARING_VIOLATION), "got 0x%08x\n", hr); - if (hr == S_OK) IMFByteStream_Release(bytestream2); + hr = MFCreateFile(MF_ACCESSMODE_READ, MF_OPENMODE_FAIL_IF_NOT_EXIST, MF_FILEFLAGS_NONE, newfilename, &bytestream2); + ok(hr == HRESULT_FROM_WIN32(ERROR_SHARING_VIOLATION), "Unexpected hr %#x.\n", hr);
- hr = MFCreateFile(MF_ACCESSMODE_WRITE, MF_OPENMODE_FAIL_IF_NOT_EXIST, - MF_FILEFLAGS_NONE, newfilename, &bytestream2); - todo_wine ok(hr == HRESULT_FROM_WIN32(ERROR_SHARING_VIOLATION), "got 0x%08x\n", hr); - if (hr == S_OK) IMFByteStream_Release(bytestream2); + hr = MFCreateFile(MF_ACCESSMODE_WRITE, MF_OPENMODE_FAIL_IF_NOT_EXIST, MF_FILEFLAGS_NONE, newfilename, &bytestream2); + ok(hr == HRESULT_FROM_WIN32(ERROR_SHARING_VIOLATION), "Unexpected hr %#x.\n", hr);
- hr = MFCreateFile(MF_ACCESSMODE_WRITE, MF_OPENMODE_FAIL_IF_NOT_EXIST, - MF_FILEFLAGS_ALLOW_WRITE_SHARING, newfilename, &bytestream2); - todo_wine ok(hr == HRESULT_FROM_WIN32(ERROR_SHARING_VIOLATION), "got 0x%08x\n", hr); - if (hr == S_OK) IMFByteStream_Release(bytestream2); + hr = MFCreateFile(MF_ACCESSMODE_WRITE, MF_OPENMODE_FAIL_IF_NOT_EXIST, MF_FILEFLAGS_ALLOW_WRITE_SHARING, + newfilename, &bytestream2); + ok(hr == HRESULT_FROM_WIN32(ERROR_SHARING_VIOLATION), "Unexpected hr %#x.\n", hr);
IMFByteStream_Release(bytestream);
@@ -1233,14 +1224,14 @@ todo_wine ok(hr == S_OK, "got 0x%08x\n", hr);
/* Opening the file again fails even though MF_FILEFLAGS_ALLOW_WRITE_SHARING is set. */ - hr = MFCreateFile(MF_ACCESSMODE_WRITE, MF_OPENMODE_FAIL_IF_NOT_EXIST, - MF_FILEFLAGS_ALLOW_WRITE_SHARING, newfilename, &bytestream2); - todo_wine ok(hr == HRESULT_FROM_WIN32(ERROR_SHARING_VIOLATION), "got 0x%08x\n", hr); - if (hr == S_OK) IMFByteStream_Release(bytestream2); + hr = MFCreateFile(MF_ACCESSMODE_WRITE, MF_OPENMODE_FAIL_IF_NOT_EXIST, MF_FILEFLAGS_ALLOW_WRITE_SHARING, + newfilename, &bytestream2); + ok(hr == HRESULT_FROM_WIN32(ERROR_SHARING_VIOLATION), "Unexpected hr %#x.\n", hr);
IMFByteStream_Release(bytestream);
- MFShutdown(); + hr = MFShutdown(); + ok(hr == S_OK, "Failed to shut down, hr %#x.\n", hr);
DeleteFileW(filename); DeleteFileW(newfilename);