From a80b603c03194fa567d29258b1b76db768161027 Mon Sep 17 00:00:00 2001 From: Jactry Zeng Date: Thu, 14 Mar 2019 11:03:10 +0300 Subject: [PATCH] mfplat: Implement IMFAttributes::GetItemByIndex(). Signed-off-by: Jactry Zeng Signed-off-by: Nikolay Sivov Signed-off-by: Alexandre Julliard --- dlls/mfplat/main.c | 19 ++++++++++++++++--- dlls/mfplat/tests/mfplat.c | 10 ++++++++++ 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/dlls/mfplat/main.c b/dlls/mfplat/main.c index e12847e90d5..c339f23ff6c 100644 --- a/dlls/mfplat/main.c +++ b/dlls/mfplat/main.c @@ -952,11 +952,24 @@ static HRESULT WINAPI mfattributes_GetCount(IMFAttributes *iface, UINT32 *items) static HRESULT WINAPI mfattributes_GetItemByIndex(IMFAttributes *iface, UINT32 index, GUID *key, PROPVARIANT *value) { - mfattributes *This = impl_from_IMFAttributes(iface); + struct attributes *attributes = impl_from_IMFAttributes(iface); + HRESULT hr = S_OK; - FIXME("%p, %d, %p, %p\n", This, index, key, value); + TRACE("%p, %u, %p, %p.\n", iface, index, key, value); - return E_NOTIMPL; + EnterCriticalSection(&attributes->cs); + + if (index < attributes->count) + { + *key = attributes->attributes[index].key; + PropVariantCopy(value, &attributes->attributes[index].value); + } + else + hr = E_INVALIDARG; + + LeaveCriticalSection(&attributes->cs); + + return hr; } static HRESULT WINAPI mfattributes_CopyAllItems(IMFAttributes *iface, IMFAttributes *dest) diff --git a/dlls/mfplat/tests/mfplat.c b/dlls/mfplat/tests/mfplat.c index 3a94d4bd172..273aa2684bb 100644 --- a/dlls/mfplat/tests/mfplat.c +++ b/dlls/mfplat/tests/mfplat.c @@ -504,6 +504,7 @@ static void test_MFCreateAttributes(void) IMFAttributes *attributes; UINT32 count; HRESULT hr; + GUID key; hr = MFCreateAttributes( &attributes, 3 ); ok(hr == S_OK, "got 0x%08x\n", hr); @@ -603,6 +604,15 @@ static void test_MFCreateAttributes(void) PropVariantClear(&ret_propvar); PropVariantClear(&propvar); + /* Item ordering is not consistent across Windows version. */ + hr = IMFAttributes_GetItemByIndex(attributes, 0, &key, &ret_propvar); + ok(hr == S_OK, "Failed to get item, hr %#x.\n", hr); + PropVariantClear(&ret_propvar); + + hr = IMFAttributes_GetItemByIndex(attributes, 100, &key, &ret_propvar); + ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr); + PropVariantClear(&ret_propvar); + IMFAttributes_Release(attributes); }