Commit 267b365f authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

mfplat: Implement GetVideoService() for the device manager.

parent b0ab5255
......@@ -8689,12 +8689,32 @@ static HRESULT WINAPI dxgi_device_manager_CloseDeviceHandle(IMFDXGIDeviceManager
return hr;
}
static HRESULT WINAPI dxgi_device_manager_GetVideoService(IMFDXGIDeviceManager *iface, HANDLE device,
REFIID riid, void **service)
static HRESULT WINAPI dxgi_device_manager_GetVideoService(IMFDXGIDeviceManager *iface, HANDLE hdevice,
REFIID riid, void **service)
{
FIXME("(%p, %p, %s, %p): stub.\n", iface, device, debugstr_guid(riid), service);
struct dxgi_device_manager *manager = impl_from_IMFDXGIDeviceManager(iface);
HRESULT hr;
size_t idx;
return E_NOTIMPL;
TRACE("%p, %p, %s, %p.\n", iface, hdevice, debugstr_guid(riid), service);
EnterCriticalSection(&manager->cs);
if (!manager->device)
hr = MF_E_DXGI_DEVICE_NOT_INITIALIZED;
else if (SUCCEEDED(hr = dxgi_device_manager_get_handle_index(manager, hdevice, &idx)))
{
if (manager->handles[idx] & DXGI_DEVICE_HANDLE_FLAG_INVALID)
hr = MF_E_DXGI_NEW_VIDEO_DEVICE;
else if (manager->handles[idx] & DXGI_DEVICE_HANDLE_FLAG_OPEN)
hr = IDXGIDevice_QueryInterface(manager->device, riid, service);
else
hr = E_HANDLE;
}
LeaveCriticalSection(&manager->cs);
return hr;
}
static HRESULT WINAPI dxgi_device_manager_LockDevice(IMFDXGIDeviceManager *iface, HANDLE hdevice,
......
......@@ -4530,6 +4530,7 @@ static void test_dxgi_device_manager(void)
struct test_thread_param param;
HANDLE handle1, handle, thread;
UINT token, token2;
IUnknown *unk;
HRESULT hr;
if (!pMFCreateDXGIDeviceManager)
......@@ -4560,6 +4561,9 @@ static void test_dxgi_device_manager(void)
ok(manager != manager2, "got wrong pointer: %p.\n", manager2);
EXPECT_REF(manager, 1);
hr = IMFDXGIDeviceManager_GetVideoService(manager, NULL, &IID_ID3D11Device, (void **)&unk);
ok(hr == MF_E_DXGI_DEVICE_NOT_INITIALIZED, "Unexpected hr %#x.\n", hr);
hr = IMFDXGIDeviceManager_OpenDeviceHandle(manager, &handle);
ok(hr == MF_E_DXGI_DEVICE_NOT_INITIALIZED, "Unexpected hr %#x.\n", hr);
......@@ -4593,6 +4597,12 @@ static void test_dxgi_device_manager(void)
EXPECT_REF(manager, 1);
EXPECT_REF(d3d11_dev, 2);
/* GetVideoService() on device change. */
handle = NULL;
hr = IMFDXGIDeviceManager_OpenDeviceHandle(manager, &handle);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
ok(!!handle, "Unexpected handle value %p.\n", handle);
hr = pD3D11CreateDevice(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, 0,
NULL, 0, D3D11_SDK_VERSION, &d3d11_dev2, NULL, NULL);
ok(hr == S_OK, "D3D11CreateDevice failed: %#x.\n", hr);
......@@ -4603,11 +4613,32 @@ static void test_dxgi_device_manager(void)
EXPECT_REF(d3d11_dev2, 2);
EXPECT_REF(d3d11_dev, 1);
hr = IMFDXGIDeviceManager_GetVideoService(manager, handle, &IID_ID3D11Device, (void **)&unk);
ok(hr == MF_E_DXGI_NEW_VIDEO_DEVICE, "Unexpected hr %#x.\n", hr);
hr = IMFDXGIDeviceManager_CloseDeviceHandle(manager, handle);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
handle = NULL;
hr = IMFDXGIDeviceManager_OpenDeviceHandle(manager, &handle);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
ok(!!handle, "Unexpected handle value %p.\n", handle);
hr = IMFDXGIDeviceManager_GetVideoService(manager, NULL, &IID_ID3D11Device, (void **)&unk);
ok(hr == E_HANDLE, "Unexpected hr %#x.\n", hr);
hr = IMFDXGIDeviceManager_GetVideoService(manager, handle, &IID_ID3D11Device, (void **)&unk);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
IUnknown_Release(unk);
hr = IMFDXGIDeviceManager_GetVideoService(manager, handle, &IID_IUnknown, (void **)&unk);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
IUnknown_Release(unk);
hr = IMFDXGIDeviceManager_GetVideoService(manager, handle, &IID_IDXGIDevice, (void **)&unk);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
IUnknown_Release(unk);
handle1 = NULL;
hr = IMFDXGIDeviceManager_OpenDeviceHandle(manager, &handle1);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment