Signed-off-by: Jactry Zeng jzeng@codeweavers.com --- dlls/mfplat/main.c | 17 +++++++++++++++-- dlls/mfplat/tests/mfplat.c | 15 +++++++++------ 2 files changed, 24 insertions(+), 8 deletions(-)
diff --git a/dlls/mfplat/main.c b/dlls/mfplat/main.c index 05e56ccb72..5ae3b4ff07 100644 --- a/dlls/mfplat/main.c +++ b/dlls/mfplat/main.c @@ -949,9 +949,22 @@ static HRESULT WINAPI mfattributes_GetItemByIndex(IMFAttributes *iface, UINT32 i { mfattributes *This = impl_from_IMFAttributes(iface);
- FIXME("%p, %d, %p, %p\n", This, index, key, value); + TRACE("(%p, %d, %p, %p)\n", This, index, key, value);
- return E_NOTIMPL; + EnterCriticalSection(&This->lock); + + if (index >= This->count) + { + LeaveCriticalSection(&This->lock); + return E_INVALIDARG; + } + + *key = This->attributes[This->count - index - 1].key; + PropVariantCopy(value, &This->attributes[This->count - index - 1].value); + + LeaveCriticalSection(&This->lock); + + return S_OK; }
static HRESULT WINAPI mfattributes_CopyAllItems(IMFAttributes *iface, IMFAttributes *dest) diff --git a/dlls/mfplat/tests/mfplat.c b/dlls/mfplat/tests/mfplat.c index c355e792a7..ea70b4bf5f 100644 --- a/dlls/mfplat/tests/mfplat.c +++ b/dlls/mfplat/tests/mfplat.c @@ -508,9 +508,9 @@ static void test_MFCreateAttributes(void) hr = IMFAttributes_GetItemByIndex(attributes, 0, &key, &ret_propvar); else hr = IMFAttributes_GetItemByIndex(attributes, 1, &key, &ret_propvar); - todo_wine ok(hr == S_OK, "IMFAttributes_GetItemByIndex failed: 0x%08x.\n", hr); - todo_wine ok(!PropVariantCompareEx(&propvar, &ret_propvar, 0, 0), "got wrong property.\n"); - todo_wine ok(IsEqualIID(&key, &DUMMY_GUID3), "got wrong key: %s.\n", wine_dbgstr_guid(&key)); + ok(hr == S_OK, "IMFAttributes_GetItemByIndex failed: 0x%08x.\n", hr); + ok(!PropVariantCompareEx(&propvar, &ret_propvar, 0, 0), "got wrong property.\n"); + ok(IsEqualIID(&key, &DUMMY_GUID3), "got wrong key: %s.\n", wine_dbgstr_guid(&key)); PropVariantClear(&ret_propvar); PropVariantClear(&propvar); propvar.vt = MF_ATTRIBUTE_UINT64; @@ -520,9 +520,12 @@ static void test_MFCreateAttributes(void) hr = IMFAttributes_GetItemByIndex(attributes, 1, &key, &ret_propvar); else hr = IMFAttributes_GetItemByIndex(attributes, 0, &key, &ret_propvar); - todo_wine ok(hr == S_OK, "IMFAttributes_GetItemByIndex failed: 0x%08x.\n", hr); - todo_wine ok(!PropVariantCompareEx(&propvar, &ret_propvar, 0, 0), "got wrong property.\n"); - todo_wine ok(IsEqualIID(&key, &DUMMY_GUID1), "got wrong key: %s.\n", wine_dbgstr_guid(&key)); + ok(hr == S_OK, "IMFAttributes_GetItemByIndex failed: 0x%08x.\n", hr); + ok(!PropVariantCompareEx(&propvar, &ret_propvar, 0, 0), "got wrong property.\n"); + ok(IsEqualIID(&key, &DUMMY_GUID1), "got wrong key: %s.\n", wine_dbgstr_guid(&key)); + + hr = IMFAttributes_GetItemByIndex(attributes, 999, &key, &ret_propvar); + ok(hr == E_INVALIDARG, "IMFAttributes_GetItemByIndex returned: 0x%08x.\n", hr);
hr = IMFAttributes_DeleteItem(attributes, &DUMMY_GUID2); ok(hr == S_OK, "IMFAttributes_DeleteItem failed: 0x%08x.\n", hr);