mfplat: Implement IMFAttributes::GetItemByIndex().

Signed-off-by: Jactry Zeng <jzeng@codeweavers.com>
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jactry Zeng 2019-03-14 11:03:10 +03:00 committed by Alexandre Julliard
parent 50a57f8613
commit a80b603c03
2 changed files with 26 additions and 3 deletions

View File

@ -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) 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) static HRESULT WINAPI mfattributes_CopyAllItems(IMFAttributes *iface, IMFAttributes *dest)

View File

@ -504,6 +504,7 @@ static void test_MFCreateAttributes(void)
IMFAttributes *attributes; IMFAttributes *attributes;
UINT32 count; UINT32 count;
HRESULT hr; HRESULT hr;
GUID key;
hr = MFCreateAttributes( &attributes, 3 ); hr = MFCreateAttributes( &attributes, 3 );
ok(hr == S_OK, "got 0x%08x\n", hr); ok(hr == S_OK, "got 0x%08x\n", hr);
@ -603,6 +604,15 @@ static void test_MFCreateAttributes(void)
PropVariantClear(&ret_propvar); PropVariantClear(&ret_propvar);
PropVariantClear(&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); IMFAttributes_Release(attributes);
} }