Signed-off-by: Jactry Zeng jzeng@codeweavers.com --- dlls/mfplat/main.c | 16 ++++++++++++++-- dlls/mfplat/tests/mfplat.c | 15 +++++++++------ 2 files changed, 23 insertions(+), 8 deletions(-)
diff --git a/dlls/mfplat/main.c b/dlls/mfplat/main.c index f897325502..06a49b237f 100644 --- a/dlls/mfplat/main.c +++ b/dlls/mfplat/main.c @@ -903,9 +903,21 @@ 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 5dcb641486..7f7f413096 100644 --- a/dlls/mfplat/tests/mfplat.c +++ b/dlls/mfplat/tests/mfplat.c @@ -765,21 +765,24 @@ static void test_IMFAttributes_item(void) hr = IMFAttributes_DeleteItem(attributes, &DUMMY_GUID2); ok(hr == S_OK, "IMFAttributes_DeleteItem failed: 0x%08x.\n", hr); 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_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; U(propvar).uhVal.QuadPart = 65536; 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_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_DeleteItem(attributes, &DUMMY_GUID2); ok(hr == S_OK, "IMFAttributes_DeleteItem failed: 0x%08x.\n", hr);
+ hr = IMFAttributes_GetItemByIndex(attributes, 2, &key, &ret_propvar); + ok(hr == E_INVALIDARG, "IMFAttributes_GetItemByIndex should fail: 0x%08x.\n", hr); + IMFAttributes_Release(attributes); }