From: "RĂ©mi Bernon" rbernon@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com ---
Supersedes 184179.
dlls/mfplat/main.c | 45 +++++++++++++++++--------------------- dlls/mfplat/tests/mfplat.c | 4 ++++ 2 files changed, 24 insertions(+), 25 deletions(-)
diff --git a/dlls/mfplat/main.c b/dlls/mfplat/main.c index 923905399b..0a5958acb2 100644 --- a/dlls/mfplat/main.c +++ b/dlls/mfplat/main.c @@ -5883,6 +5883,7 @@ static HRESULT resolver_handler_end_create(struct source_resolver *resolver, enu IRtwqAsyncResult *result) { IRtwqAsyncResult *inner_result = (IRtwqAsyncResult *)IRtwqAsyncResult_GetStateNoAddRef(result); + RTWQASYNCRESULT *data = (RTWQASYNCRESULT *)inner_result; struct resolver_queued_result *queued_result; union { @@ -5891,7 +5892,8 @@ static HRESULT resolver_handler_end_create(struct source_resolver *resolver, enu IMFSchemeHandler *scheme_handler; } handler;
- queued_result = heap_alloc_zero(sizeof(*queued_result)); + if (!(queued_result = heap_alloc_zero(sizeof(*queued_result)))) + return E_OUTOFMEMORY;
IRtwqAsyncResult_GetObject(inner_result, &handler.handler);
@@ -5911,37 +5913,30 @@ static HRESULT resolver_handler_end_create(struct source_resolver *resolver, enu
IUnknown_Release(handler.handler);
- if (SUCCEEDED(queued_result->hr)) + if (data->hEvent) { - RTWQASYNCRESULT *data = (RTWQASYNCRESULT *)inner_result; + queued_result->inner_result = inner_result; + IRtwqAsyncResult_AddRef(queued_result->inner_result); + }
- if (data->hEvent) - { - queued_result->inner_result = inner_result; - IRtwqAsyncResult_AddRef(queued_result->inner_result); - } + /* Push resolved object type and created object, so we don't have to guess on End*() call. */ + EnterCriticalSection(&resolver->cs); + list_add_tail(&resolver->pending, &queued_result->entry); + LeaveCriticalSection(&resolver->cs);
- /* Push resolved object type and created object, so we don't have to guess on End*() call. */ - EnterCriticalSection(&resolver->cs); - list_add_tail(&resolver->pending, &queued_result->entry); - LeaveCriticalSection(&resolver->cs); + if (data->hEvent) + SetEvent(data->hEvent); + else + { + IUnknown *caller_state = IRtwqAsyncResult_GetStateNoAddRef(inner_result); + IRtwqAsyncResult *caller_result;
- if (data->hEvent) - SetEvent(data->hEvent); - else + if (SUCCEEDED(RtwqCreateAsyncResult(queued_result->object, data->pCallback, caller_state, &caller_result))) { - IUnknown *caller_state = IRtwqAsyncResult_GetStateNoAddRef(inner_result); - IRtwqAsyncResult *caller_result; - - if (SUCCEEDED(RtwqCreateAsyncResult(queued_result->object, data->pCallback, caller_state, &caller_result))) - { - RtwqInvokeCallback(caller_result); - IRtwqAsyncResult_Release(caller_result); - } + RtwqInvokeCallback(caller_result); + IRtwqAsyncResult_Release(caller_result); } } - else - heap_free(queued_result);
return S_OK; } diff --git a/dlls/mfplat/tests/mfplat.c b/dlls/mfplat/tests/mfplat.c index e623b4c0ed..4bc0813624 100644 --- a/dlls/mfplat/tests/mfplat.c +++ b/dlls/mfplat/tests/mfplat.c @@ -605,6 +605,10 @@ skip_source_tests: /* Create from URL. */ callback.event = CreateEventA(NULL, FALSE, FALSE, NULL);
+ hr = IMFSourceResolver_CreateObjectFromURL(resolver, L"nonexisting.mp4", MF_RESOLUTION_BYTESTREAM, NULL, &obj_type, + (IUnknown **)&stream); + ok(hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), "Unexpected hr %#x.\n", hr); + hr = IMFSourceResolver_CreateObjectFromURL(resolver, filename, MF_RESOLUTION_BYTESTREAM, NULL, &obj_type, (IUnknown **)&stream); ok(hr == S_OK, "Failed to resolve url, hr %#x.\n", hr);