diff --git a/dlls/mfplat/main.c b/dlls/mfplat/main.c index ea4387e9ae8..7c3bad3e1f5 100644 --- a/dlls/mfplat/main.c +++ b/dlls/mfplat/main.c @@ -1132,11 +1132,30 @@ static HRESULT WINAPI mfattributes_GetItemByIndex(IMFAttributes *iface, UINT32 i static HRESULT WINAPI mfattributes_CopyAllItems(IMFAttributes *iface, IMFAttributes *dest) { - mfattributes *This = impl_from_IMFAttributes(iface); + struct attributes *attributes = impl_from_IMFAttributes(iface); + HRESULT hr = S_OK; + size_t i; - FIXME("%p, %p\n", This, dest); + TRACE("%p, %p.\n", iface, dest); - return E_NOTIMPL; + EnterCriticalSection(&attributes->cs); + + IMFAttributes_LockStore(dest); + + IMFAttributes_DeleteAllItems(dest); + + for (i = 0; i < attributes->count; ++i) + { + hr = IMFAttributes_SetItem(dest, &attributes->attributes[i].key, &attributes->attributes[i].value); + if (FAILED(hr)) + break; + } + + IMFAttributes_UnlockStore(dest); + + LeaveCriticalSection(&attributes->cs); + + return hr; } static const IMFAttributesVtbl mfattributes_vtbl = diff --git a/dlls/mfplat/tests/mfplat.c b/dlls/mfplat/tests/mfplat.c index a999b9bbe91..613c2aa264e 100644 --- a/dlls/mfplat/tests/mfplat.c +++ b/dlls/mfplat/tests/mfplat.c @@ -507,9 +507,9 @@ static void check_attr_count(IMFAttributes* obj, UINT32 expected, int line) static void test_MFCreateAttributes(void) { static const WCHAR stringW[] = {'W','i','n','e',0}; + IMFAttributes *attributes, *attributes1; PROPVARIANT propvar, ret_propvar; UINT32 value, string_length; - IMFAttributes *attributes; double double_value; IUnknown *unk_value; WCHAR bufferW[256]; @@ -714,11 +714,24 @@ static void test_MFCreateAttributes(void) hr = IMFAttributes_GetUnknown(attributes, &DUMMY_CLSID, &IID_IUnknown, (void **)&unk_value); ok(hr == MF_E_INVALIDTYPE, "Unexpected hr %#x.\n", hr); - hr = IMFAttributes_DeleteAllItems(attributes); + /* CopyAllItems() */ + hr = MFCreateAttributes(&attributes1, 0); + ok(hr == S_OK, "Failed to create attributes object, hr %#x.\n", hr); + hr = IMFAttributes_CopyAllItems(attributes, attributes1); + ok(hr == S_OK, "Failed to copy items, hr %#x.\n", hr); + CHECK_ATTR_COUNT(attributes, 5); + CHECK_ATTR_COUNT(attributes1, 5); + + hr = IMFAttributes_DeleteAllItems(attributes1); ok(hr == S_OK, "Failed to delete items, hr %#x.\n", hr); + CHECK_ATTR_COUNT(attributes1, 0); + + hr = IMFAttributes_CopyAllItems(attributes1, attributes); + ok(hr == S_OK, "Failed to copy items, hr %#x.\n", hr); CHECK_ATTR_COUNT(attributes, 0); IMFAttributes_Release(attributes); + IMFAttributes_Release(attributes1); } static void test_MFCreateMFByteStreamOnStream(void)