From: Nikolay Sivov nsivov@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/windowscodecs/metadatahandler.c | 18 +++++++++++++----- dlls/windowscodecs/tests/metadata.c | 13 ------------- 2 files changed, 13 insertions(+), 18 deletions(-)
diff --git a/dlls/windowscodecs/metadatahandler.c b/dlls/windowscodecs/metadatahandler.c index 7618d8cd6aa..d399e31bc9b 100644 --- a/dlls/windowscodecs/metadatahandler.c +++ b/dlls/windowscodecs/metadatahandler.c @@ -41,6 +41,7 @@ typedef struct MetadataHandler { const MetadataHandlerVtbl *vtable; MetadataItem *items; DWORD item_count; + DWORD persist_options; CRITICAL_SECTION lock; } MetadataHandler;
@@ -379,6 +380,8 @@ static HRESULT WINAPI MetadataHandler_LoadEx(IWICPersistStream *iface, MetadataHandler_FreeItems(This); This->items = new_items; This->item_count = item_count; + + This->persist_options = dwPersistOptions & WICPersistOptionMask; }
LeaveCriticalSection(&This->lock); @@ -433,9 +436,16 @@ static HRESULT WINAPI metadatahandler_stream_provider_GetStream(IWICStreamProvid
static HRESULT WINAPI metadatahandler_stream_provider_GetPersistOptions(IWICStreamProvider *iface, DWORD *options) { - FIXME("%p, %p stub\n", iface, options); + MetadataHandler *handler = impl_from_IWICStreamProvider(iface);
- return E_NOTIMPL; + TRACE("%p, %p.\n", iface, options); + + if (!options) + return E_INVALIDARG; + + *options = handler->persist_options; + + return S_OK; }
static HRESULT WINAPI metadatahandler_stream_provider_GetPreferredVendorGUID(IWICStreamProvider *iface, GUID *guid) @@ -472,7 +482,7 @@ HRESULT MetadataReader_Create(const MetadataHandlerVtbl *vtable, REFIID iid, voi
*ppv = NULL;
- This = malloc(sizeof(MetadataHandler)); + This = calloc(1, sizeof(*This)); if (!This) return E_OUTOFMEMORY;
This->IWICMetadataWriter_iface.lpVtbl = &MetadataHandler_Vtbl; @@ -480,8 +490,6 @@ HRESULT MetadataReader_Create(const MetadataHandlerVtbl *vtable, REFIID iid, voi This->IWICStreamProvider_iface.lpVtbl = &MetadataHandler_StreamProvider_Vtbl; This->ref = 1; This->vtable = vtable; - This->items = NULL; - This->item_count = 0;
InitializeCriticalSectionEx(&This->lock, 0, RTL_CRITICAL_SECTION_FLAG_FORCE_DEBUG_INFO); This->lock.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": MetadataHandler.lock"); diff --git a/dlls/windowscodecs/tests/metadata.c b/dlls/windowscodecs/tests/metadata.c index 238acd7cd65..6fd307b26c7 100644 --- a/dlls/windowscodecs/tests/metadata.c +++ b/dlls/windowscodecs/tests/metadata.c @@ -346,14 +346,11 @@ static void load_stream(void *iface_ptr, const char *data, int data_size, DWORD ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
hr = IWICStreamProvider_GetPersistOptions(stream_provider, NULL); - todo_wine ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
flags = 123; hr = IWICStreamProvider_GetPersistOptions(stream_provider, &flags); - todo_wine ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - todo_wine ok(!flags, "Unexpected options %#lx.\n", flags);
stream2 = (void *)0xdeadbeef; @@ -374,9 +371,7 @@ static void load_stream(void *iface_ptr, const char *data, int data_size, DWORD
flags = ~persist_options; hr = IWICStreamProvider_GetPersistOptions(stream_provider, &flags); - todo_wine ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - todo_wine ok(flags == persist_options, "Unexpected options %#lx.\n", flags);
if (persist_options & WICPersistOptionNoCacheStream) @@ -1281,7 +1276,6 @@ static void test_ifd_content(IWICMetadataReader *reader) memcpy(IFD_data_swapped, &IFD_data, sizeof(IFD_data)); byte_swap_ifd_data(IFD_data_swapped); load_stream(reader, IFD_data_swapped, sizeof(IFD_data), WICPersistOptionBigEndian); - todo_wine check_persist_options(reader, WICPersistOptionBigEndian); hr = IWICMetadataReader_GetCount(reader, &count); ok(hr == S_OK, "GetCount error %#lx\n", hr); @@ -1760,7 +1754,6 @@ static void test_CreateMetadataReader(void) hr = get_persist_stream(reader, &stream2); todo_wine ok(hr == WINCODEC_ERR_STREAMNOTAVAILABLE, "Unexpected hr %#lx.\n", hr); - todo_wine check_persist_options(reader, WICPersistOptionNoCacheStream);
IWICPersistStream_Release(persist_stream); @@ -2563,7 +2556,6 @@ static void test_metadata_LSD(void)
hr = IWICPersistStream_Load(persist, stream); ok(hr == S_OK, "Load error %#lx\n", hr); - todo_wine check_persist_options(reader, 0);
IWICPersistStream_Release(persist); @@ -2664,7 +2656,6 @@ static void test_metadata_IMD(void)
hr = IWICPersistStream_Load(persist, stream); ok(hr == S_OK, "Load error %#lx\n", hr); - todo_wine check_persist_options(reader, 0);
IWICPersistStream_Release(persist); @@ -2762,7 +2753,6 @@ static void test_metadata_GCE(void)
hr = IWICPersistStream_Load(persist, stream); ok(hr == S_OK, "Load error %#lx\n", hr); - todo_wine check_persist_options(reader, 0);
IWICPersistStream_Release(persist); @@ -2858,7 +2848,6 @@ static void test_metadata_APE(void)
hr = IWICPersistStream_Load(persist, stream); ok(hr == S_OK, "Load error %#lx\n", hr); - todo_wine check_persist_options(reader, 0);
IWICPersistStream_Release(persist); @@ -2965,7 +2954,6 @@ static void test_metadata_GIF_comment(void)
hr = IWICPersistStream_Load(persist, stream); ok(hr == S_OK, "Load error %#lx\n", hr); - todo_wine check_persist_options(reader, 0);
IWICPersistStream_Release(persist); @@ -4220,7 +4208,6 @@ static void test_CreateMetadataWriterFromReader(void) hr = IWICComponentFactory_CreateMetadataReader(factory, &GUID_MetadataFormatChunktEXt, NULL, 0, NULL, &reader); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - todo_wine check_persist_options(reader, 0);
hr = IWICComponentFactory_CreateMetadataWriterFromReader(factory, reader, NULL, &writer);