Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/mfplat/main.c | 149 ++++++++++++++++++++++++--------------------- 1 file changed, 80 insertions(+), 69 deletions(-)
diff --git a/dlls/mfplat/main.c b/dlls/mfplat/main.c index c7f4fea6b4..c8c19aa404 100644 --- a/dlls/mfplat/main.c +++ b/dlls/mfplat/main.c @@ -34,6 +34,7 @@ #include "wine/list.h"
#include "mfplat_private.h" +#include "mfreadwrite.h"
WINE_DEFAULT_DEBUG_CHANNEL(mfplat);
@@ -532,6 +533,62 @@ HRESULT WINAPI MFCopyImage(BYTE *dest, LONG deststride, const BYTE *src, LONG sr return S_OK; }
+struct guid_def +{ + const GUID *guid; + const char *name; +}; + +static int debug_compare_guid(const void *a, const void *b) +{ + const GUID *guid = a; + const struct guid_def *guid_def = b; + return memcmp(guid, guid_def->guid, sizeof(*guid)); +} + +static const char *debugstr_attr(const GUID *guid) +{ + static const struct guid_def guid_defs[] = + { +#define X(g) { &(g), #g } + X(MF_READWRITE_MMCSS_CLASS), + X(MF_SINK_WRITER_ENCODER_CONFIG), + X(MF_READWRITE_ENABLE_HARDWARE_TRANSFORMS), + X(MF_MT_PIXEL_ASPECT_RATIO), + X(MF_MT_AVG_BITRATE), + X(MF_MT_ALL_SAMPLES_INDEPENDENT), + X(MF_MT_FRAME_SIZE), + X(MF_SINK_WRITER_ASYNC_CALLBACK), + X(MF_MT_FRAME_RATE_RANGE_MAX), + X(MF_MT_USER_DATA), + X(MF_READWRITE_DISABLE_CONVERTERS), + X(MF_READWRITE_MMCSS_PRIORITY_AUDIO), + X(MF_BYTESTREAM_ORIGIN_NAME), + X(MF_BYTESTREAM_CONTENT_TYPE), + X(MF_BYTESTREAM_DURATION), + X(MF_BYTESTREAM_LAST_MODIFIED_TIME), + X(MF_MT_FRAME_RATE_RANGE_MIN), + X(MF_BYTESTREAM_IFO_FILE_URI), + X(MF_BYTESTREAM_DLNA_PROFILE_ID), + X(MF_MT_MAJOR_TYPE), + X(MF_MT_SUBTYPE), + X(MF_SINK_WRITER_D3D_MANAGER), + X(MF_MT_INTERLACE_MODE), + X(MF_READWRITE_MMCSS_PRIORITY), + X(MF_SINK_WRITER_DISABLE_THROTTLING), + X(MF_READWRITE_D3D_OPTIONAL), + X(MF_READWRITE_MMCSS_CLASS_AUDIO), + X(MF_MT_FRAME_RATE), +#undef X + }; + struct guid_def *ret = NULL; + + if (guid) + ret = bsearch(guid, guid_defs, ARRAY_SIZE(guid_defs), sizeof(*guid_defs), debug_compare_guid); + + return ret ? wine_dbg_sprintf("%s", ret->name) : wine_dbgstr_guid(guid); +} + static inline mfattributes *impl_from_IMFAttributes(IMFAttributes *iface) { return CONTAINING_RECORD(iface, mfattributes, IMFAttributes_iface); @@ -586,27 +643,21 @@ static ULONG WINAPI mfattributes_Release(IMFAttributes *iface)
static HRESULT WINAPI mfattributes_GetItem(IMFAttributes *iface, REFGUID key, PROPVARIANT *value) { - mfattributes *This = impl_from_IMFAttributes(iface); - - FIXME("%p, %s, %p\n", This, debugstr_guid(key), value); + FIXME("%p, %s, %p.\n", iface, debugstr_attr(key), value);
return E_NOTIMPL; }
static HRESULT WINAPI mfattributes_GetItemType(IMFAttributes *iface, REFGUID key, MF_ATTRIBUTE_TYPE *type) { - mfattributes *This = impl_from_IMFAttributes(iface); - - FIXME("%p, %s, %p\n", This, debugstr_guid(key), type); + FIXME("%p, %s, %p.\n", iface, debugstr_attr(key), type);
return E_NOTIMPL; }
static HRESULT WINAPI mfattributes_CompareItem(IMFAttributes *iface, REFGUID key, REFPROPVARIANT value, BOOL *result) { - mfattributes *This = impl_from_IMFAttributes(iface); - - FIXME("%p, %s, %p, %p\n", This, debugstr_guid(key), value, result); + FIXME("%p, %s, %p, %p.\n", iface, debugstr_attr(key), value, result);
return E_NOTIMPL; } @@ -623,45 +674,35 @@ static HRESULT WINAPI mfattributes_Compare(IMFAttributes *iface, IMFAttributes *
static HRESULT WINAPI mfattributes_GetUINT32(IMFAttributes *iface, REFGUID key, UINT32 *value) { - mfattributes *This = impl_from_IMFAttributes(iface); - - FIXME("%p, %s, %p\n", This, debugstr_guid(key), value); + FIXME("%p, %s, %p.\n", iface, debugstr_attr(key), value);
return E_NOTIMPL; }
static HRESULT WINAPI mfattributes_GetUINT64(IMFAttributes *iface, REFGUID key, UINT64 *value) { - mfattributes *This = impl_from_IMFAttributes(iface); - - FIXME("%p, %s, %p\n", This, debugstr_guid(key), value); + FIXME("%p, %s, %p.\n", iface, debugstr_attr(key), value);
return E_NOTIMPL; }
static HRESULT WINAPI mfattributes_GetDouble(IMFAttributes *iface, REFGUID key, double *value) { - mfattributes *This = impl_from_IMFAttributes(iface); - - FIXME("%p, %s, %p\n", This, debugstr_guid(key), value); + FIXME("%p, %s, %p.\n", iface, debugstr_attr(key), value);
return E_NOTIMPL; }
static HRESULT WINAPI mfattributes_GetGUID(IMFAttributes *iface, REFGUID key, GUID *value) { - mfattributes *This = impl_from_IMFAttributes(iface); - - FIXME("%p, %s, %p\n", This, debugstr_guid(key), value); + FIXME("%p, %s, %p.\n", iface, debugstr_attr(key), value);
return E_NOTIMPL; }
static HRESULT WINAPI mfattributes_GetStringLength(IMFAttributes *iface, REFGUID key, UINT32 *length) { - mfattributes *This = impl_from_IMFAttributes(iface); - - FIXME("%p, %s, %p\n", This, debugstr_guid(key), length); + FIXME("%p, %s, %p.\n", iface, debugstr_attr(key), length);
return E_NOTIMPL; } @@ -669,9 +710,7 @@ static HRESULT WINAPI mfattributes_GetStringLength(IMFAttributes *iface, REFGUID static HRESULT WINAPI mfattributes_GetString(IMFAttributes *iface, REFGUID key, WCHAR *value, UINT32 size, UINT32 *length) { - mfattributes *This = impl_from_IMFAttributes(iface); - - FIXME("%p, %s, %p, %d, %p\n", This, debugstr_guid(key), value, size, length); + FIXME("%p, %s, %p, %d, %p.\n", iface, debugstr_attr(key), value, size, length);
return E_NOTIMPL; } @@ -679,18 +718,14 @@ static HRESULT WINAPI mfattributes_GetString(IMFAttributes *iface, REFGUID key, static HRESULT WINAPI mfattributes_GetAllocatedString(IMFAttributes *iface, REFGUID key, WCHAR **value, UINT32 *length) { - mfattributes *This = impl_from_IMFAttributes(iface); - - FIXME("%p, %s, %p, %p\n", This, debugstr_guid(key), value, length); + FIXME("%p, %s, %p, %p.\n", iface, debugstr_attr(key), value, length);
return E_NOTIMPL; }
static HRESULT WINAPI mfattributes_GetBlobSize(IMFAttributes *iface, REFGUID key, UINT32 *size) { - mfattributes *This = impl_from_IMFAttributes(iface); - - FIXME("%p, %s, %p\n", This, debugstr_guid(key), size); + FIXME("%p, %s, %p.\n", iface, debugstr_attr(key), size);
return E_NOTIMPL; } @@ -698,45 +733,35 @@ static HRESULT WINAPI mfattributes_GetBlobSize(IMFAttributes *iface, REFGUID key static HRESULT WINAPI mfattributes_GetBlob(IMFAttributes *iface, REFGUID key, UINT8 *buf, UINT32 bufsize, UINT32 *blobsize) { - mfattributes *This = impl_from_IMFAttributes(iface); - - FIXME("%p, %s, %p, %d, %p\n", This, debugstr_guid(key), buf, bufsize, blobsize); + FIXME("%p, %s, %p, %d, %p.\n", iface, debugstr_attr(key), buf, bufsize, blobsize);
return E_NOTIMPL; }
static HRESULT WINAPI mfattributes_GetAllocatedBlob(IMFAttributes *iface, REFGUID key, UINT8 **buf, UINT32 *size) { - mfattributes *This = impl_from_IMFAttributes(iface); - - FIXME("%p, %s, %p, %p\n", This, debugstr_guid(key), buf, size); + FIXME("%p, %s, %p, %p.\n", iface, debugstr_attr(key), buf, size);
return E_NOTIMPL; }
static HRESULT WINAPI mfattributes_GetUnknown(IMFAttributes *iface, REFGUID key, REFIID riid, void **ppv) { - mfattributes *This = impl_from_IMFAttributes(iface); - - FIXME("%p, %s, %s, %p\n", This, debugstr_guid(key), debugstr_guid(riid), ppv); + FIXME("%p, %s, %s, %p.\n", iface, debugstr_attr(key), debugstr_guid(riid), ppv);
return E_NOTIMPL; }
static HRESULT WINAPI mfattributes_SetItem(IMFAttributes *iface, REFGUID key, REFPROPVARIANT Value) { - mfattributes *This = impl_from_IMFAttributes(iface); - - FIXME("%p, %s, %p\n", This, debugstr_guid(key), Value); + FIXME("%p, %s, %p.\n", iface, debugstr_attr(key), Value);
return E_NOTIMPL; }
static HRESULT WINAPI mfattributes_DeleteItem(IMFAttributes *iface, REFGUID key) { - mfattributes *This = impl_from_IMFAttributes(iface); - - FIXME("%p, %s\n", This, debugstr_guid(key)); + FIXME("%p, %s.\n", iface, debugstr_attr(key));
return E_NOTIMPL; } @@ -752,63 +777,49 @@ static HRESULT WINAPI mfattributes_DeleteAllItems(IMFAttributes *iface)
static HRESULT WINAPI mfattributes_SetUINT32(IMFAttributes *iface, REFGUID key, UINT32 value) { - mfattributes *This = impl_from_IMFAttributes(iface); - - FIXME("%p, %s, %d\n", This, debugstr_guid(key), value); + FIXME("%p, %s, %d.\n", iface, debugstr_attr(key), value);
return E_NOTIMPL; }
static HRESULT WINAPI mfattributes_SetUINT64(IMFAttributes *iface, REFGUID key, UINT64 value) { - mfattributes *This = impl_from_IMFAttributes(iface); - - FIXME("%p, %s, %s\n", This, debugstr_guid(key), wine_dbgstr_longlong(value)); + FIXME("%p, %s, %s.\n", iface, debugstr_attr(key), wine_dbgstr_longlong(value));
return E_NOTIMPL; }
static HRESULT WINAPI mfattributes_SetDouble(IMFAttributes *iface, REFGUID key, double value) { - mfattributes *This = impl_from_IMFAttributes(iface); - - FIXME("%p, %s, %f\n", This, debugstr_guid(key), value); + FIXME("%p, %s, %f.\n", iface, debugstr_attr(key), value);
return E_NOTIMPL; }
static HRESULT WINAPI mfattributes_SetGUID(IMFAttributes *iface, REFGUID key, REFGUID value) { - mfattributes *This = impl_from_IMFAttributes(iface); - - FIXME("%p, %s, %s\n", This, debugstr_guid(key), debugstr_guid(value)); + FIXME("%p, %s, %s.\n", iface, debugstr_attr(key), debugstr_guid(value));
return E_NOTIMPL; }
static HRESULT WINAPI mfattributes_SetString(IMFAttributes *iface, REFGUID key, const WCHAR *value) { - mfattributes *This = impl_from_IMFAttributes(iface); - - FIXME("%p, %s, %s\n", This, debugstr_guid(key), debugstr_w(value)); + FIXME("%p, %s, %s.\n", iface, debugstr_attr(key), debugstr_w(value));
return E_NOTIMPL; }
static HRESULT WINAPI mfattributes_SetBlob(IMFAttributes *iface, REFGUID key, const UINT8 *buf, UINT32 size) { - mfattributes *This = impl_from_IMFAttributes(iface); - - FIXME("%p, %s, %p, %d\n", This, debugstr_guid(key), buf, size); + FIXME("%p, %s, %p, %u.\n", iface, debugstr_attr(key), buf, size);
return E_NOTIMPL; }
static HRESULT WINAPI mfattributes_SetUnknown(IMFAttributes *iface, REFGUID key, IUnknown *unknown) { - mfattributes *This = impl_from_IMFAttributes(iface); - - FIXME("%p, %s, %p\n", This, debugstr_guid(key), unknown); + FIXME("%p, %s, %p.\n", iface, debugstr_attr(key), unknown);
return E_NOTIMPL; }
From: Jactry Zeng jzeng@codeweavers.com
Signed-off-by: Jactry Zeng jzeng@codeweavers.com Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/mfplat/buffer.c | 9 +++- dlls/mfplat/main.c | 80 ++++++++++++++++++++++++++++-------- dlls/mfplat/mediatype.c | 30 ++++++++++---- dlls/mfplat/mfplat_private.h | 13 +++++- 4 files changed, 107 insertions(+), 25 deletions(-)
diff --git a/dlls/mfplat/buffer.c b/dlls/mfplat/buffer.c index f6eecb68cb..b07ec875f9 100644 --- a/dlls/mfplat/buffer.c +++ b/dlls/mfplat/buffer.c @@ -271,6 +271,7 @@ static ULONG WINAPI sample_Release(IMFSample *iface) { for (i = 0; i < sample->buffer_count; ++i) IMFMediaBuffer_Release(sample->buffers[i]); + clear_attributes_object(&sample->attributes); DeleteCriticalSection(&sample->cs); heap_free(sample->buffers); heap_free(sample); @@ -704,6 +705,7 @@ static const IMFSampleVtbl samplevtbl = HRESULT WINAPI MFCreateSample(IMFSample **sample) { struct sample *object; + HRESULT hr;
TRACE("%p.\n", sample);
@@ -711,7 +713,12 @@ HRESULT WINAPI MFCreateSample(IMFSample **sample) if (!object) return E_OUTOFMEMORY;
- init_attribute_object(&object->attributes, 0); + if (FAILED(hr = init_attributes_object(&object->attributes, 0))) + { + heap_free(object); + return hr; + } + object->IMFSample_iface.lpVtbl = &samplevtbl; InitializeCriticalSection(&object->cs);
diff --git a/dlls/mfplat/main.c b/dlls/mfplat/main.c index c8c19aa404..9d8a3ae2fe 100644 --- a/dlls/mfplat/main.c +++ b/dlls/mfplat/main.c @@ -628,17 +628,18 @@ static ULONG WINAPI mfattributes_AddRef(IMFAttributes *iface)
static ULONG WINAPI mfattributes_Release(IMFAttributes *iface) { - mfattributes *This = impl_from_IMFAttributes(iface); - ULONG ref = InterlockedDecrement(&This->ref); + struct attributes *attributes = impl_from_IMFAttributes(iface); + ULONG refcount = InterlockedDecrement(&attributes->ref);
- TRACE("(%p) ref=%u\n", This, ref); + TRACE("%p, refcount %d.\n", iface, refcount);
- if (!ref) + if (!refcount) { - HeapFree(GetProcessHeap(), 0, This); + clear_attributes_object(attributes); + heap_free(attributes); }
- return ref; + return refcount; }
static HRESULT WINAPI mfattributes_GetItem(IMFAttributes *iface, REFGUID key, PROPVARIANT *value) @@ -909,10 +910,34 @@ static const IMFAttributesVtbl mfattributes_vtbl = mfattributes_CopyAllItems };
-void init_attribute_object(mfattributes *object, UINT32 size) +HRESULT init_attributes_object(struct attributes *object, UINT32 size) { - object->ref = 1; object->IMFAttributes_iface.lpVtbl = &mfattributes_vtbl; + object->ref = 1; + InitializeCriticalSection(&object->cs); + + object->attributes = NULL; + object->count = 0; + object->capacity = 0; + if (!mf_array_reserve((void **)&object->attributes, &object->capacity, size, + sizeof(*object->attributes))) + { + DeleteCriticalSection(&object->cs); + return E_OUTOFMEMORY; + } + + return S_OK; +} + +void clear_attributes_object(struct attributes *object) +{ + size_t i; + + for (i = 0; i < object->count; i++) + PropVariantClear(&object->attributes[i].value); + heap_free(object->attributes); + + DeleteCriticalSection(&object->cs); }
/*********************************************************************** @@ -920,15 +945,20 @@ void init_attribute_object(mfattributes *object, UINT32 size) */ HRESULT WINAPI MFCreateAttributes(IMFAttributes **attributes, UINT32 size) { - mfattributes *object; + struct attributes *object; + HRESULT hr;
TRACE("%p, %d\n", attributes, size);
- object = HeapAlloc( GetProcessHeap(), 0, sizeof(*object) ); - if(!object) + object = heap_alloc_zero(sizeof(*object)); + if (!object) return E_OUTOFMEMORY;
- init_attribute_object(object, size); + if (FAILED(hr = init_attributes_object(object, size))) + { + heap_free(object); + return hr; + } *attributes = &object->IMFAttributes_iface;
return S_OK; @@ -990,6 +1020,7 @@ static ULONG WINAPI mfbytestream_Release(IMFByteStream *iface)
if (!ref) { + clear_attributes_object(&This->attributes); HeapFree(GetProcessHeap(), 0, This); }
@@ -1223,6 +1254,7 @@ static const IMFAttributesVtbl mfbytestream_attributes_vtbl = HRESULT WINAPI MFCreateMFByteStreamOnStream(IStream *stream, IMFByteStream **bytestream) { mfbytestream *object; + HRESULT hr;
TRACE("(%p, %p): stub\n", stream, bytestream);
@@ -1230,7 +1262,11 @@ HRESULT WINAPI MFCreateMFByteStreamOnStream(IStream *stream, IMFByteStream **byt if(!object) return E_OUTOFMEMORY;
- init_attribute_object(&object->attributes, 0); + if (FAILED(hr = init_attributes_object(&object->attributes, 0))) + { + heap_free(object); + return hr; + } object->IMFByteStream_iface.lpVtbl = &mfbytestream_vtbl; object->attributes.IMFAttributes_iface.lpVtbl = &mfbytestream_attributes_vtbl;
@@ -1248,6 +1284,7 @@ HRESULT WINAPI MFCreateFile(MF_FILE_ACCESSMODE accessmode, MF_FILE_OPENMODE open DWORD filecreation_disposition = 0; DWORD fileattributes = 0; HANDLE file; + HRESULT hr;
FIXME("(%d, %d, %d, %s, %p): stub\n", accessmode, openmode, flags, debugstr_w(url), bytestream);
@@ -1301,7 +1338,11 @@ HRESULT WINAPI MFCreateFile(MF_FILE_ACCESSMODE accessmode, MF_FILE_OPENMODE open if(!object) return E_OUTOFMEMORY;
- init_attribute_object(&object->attributes, 0); + if (FAILED(hr = init_attributes_object(&object->attributes, 0))) + { + heap_free(object); + return hr; + } object->IMFByteStream_iface.lpVtbl = &mfbytestream_vtbl; object->attributes.IMFAttributes_iface.lpVtbl = &mfbytestream_attributes_vtbl;
@@ -1457,6 +1498,7 @@ static ULONG WINAPI mfpresentationdescriptor_Release(IMFPresentationDescriptor *
if (!ref) { + clear_attributes_object(&This->attributes); HeapFree(GetProcessHeap(), 0, This); }
@@ -1855,7 +1897,7 @@ static HRESULT WINAPI mfsource_CreatePresentationDescriptor(IMFMediaSource *ifac if (!object) return E_OUTOFMEMORY;
- init_attribute_object(&object->attributes, 0); + init_attributes_object(&object->attributes, 0); object->IMFPresentationDescriptor_iface.lpVtbl = &mfpresentationdescriptor_vtbl;
*descriptor = &object->IMFPresentationDescriptor_iface; @@ -2754,6 +2796,7 @@ static ULONG WINAPI mfmediaevent_Release(IMFMediaEvent *iface)
if (!ref) { + clear_attributes_object(&event->attributes); PropVariantClear(&event->value); heap_free(event); } @@ -3035,6 +3078,7 @@ HRESULT WINAPI MFCreateMediaEvent(MediaEventType type, REFGUID extended_type, HR const PROPVARIANT *value, IMFMediaEvent **event) { mfmediaevent *object; + HRESULT hr;
TRACE("%#x, %s, %08x, %p, %p\n", type, debugstr_guid(extended_type), status, value, event);
@@ -3042,7 +3086,11 @@ HRESULT WINAPI MFCreateMediaEvent(MediaEventType type, REFGUID extended_type, HR if(!object) return E_OUTOFMEMORY;
- init_attribute_object(&object->attributes, 0); + if (FAILED(hr = init_attributes_object(&object->attributes, 0))) + { + heap_free(object); + return hr; + } object->IMFMediaEvent_iface.lpVtbl = &mfmediaevent_vtbl;
object->type = type; diff --git a/dlls/mfplat/mediatype.c b/dlls/mfplat/mediatype.c index d27d5ef12b..b526509ab3 100644 --- a/dlls/mfplat/mediatype.c +++ b/dlls/mfplat/mediatype.c @@ -116,6 +116,7 @@ static ULONG WINAPI mediatype_Release(IMFMediaType *iface)
if (!refcount) { + clear_attributes_object(&media_type->attributes); heap_free(media_type); }
@@ -496,6 +497,7 @@ static const IMFMediaTypeVtbl mediatypevtbl = HRESULT WINAPI MFCreateMediaType(IMFMediaType **media_type) { struct media_type *object; + HRESULT hr;
TRACE("%p.\n", media_type);
@@ -506,7 +508,11 @@ HRESULT WINAPI MFCreateMediaType(IMFMediaType **media_type) if (!object) return E_OUTOFMEMORY;
- init_attribute_object(&object->attributes, 0); + if (FAILED(hr = init_attributes_object(&object->attributes, 0))) + { + heap_free(object); + return hr; + } object->IMFMediaType_iface.lpVtbl = &mediatypevtbl;
*media_type = &object->IMFMediaType_iface; @@ -561,6 +567,7 @@ static ULONG WINAPI stream_descriptor_Release(IMFStreamDescriptor *iface) heap_free(stream_desc->media_types); if (stream_desc->current_type) IMFMediaType_Release(stream_desc->current_type); + clear_attributes_object(&stream_desc->attributes); DeleteCriticalSection(&stream_desc->cs); heap_free(stream_desc); } @@ -950,6 +957,7 @@ HRESULT WINAPI MFCreateStreamDescriptor(DWORD identifier, DWORD count, { struct stream_desc *object; unsigned int i; + HRESULT hr;
TRACE("%d, %d, %p, %p.\n", identifier, count, types, descriptor);
@@ -960,14 +968,19 @@ HRESULT WINAPI MFCreateStreamDescriptor(DWORD identifier, DWORD count, if (!object) return E_OUTOFMEMORY;
- init_attribute_object(&object->attributes, 0); + if (FAILED(hr = init_attributes_object(&object->attributes, 0))) + { + heap_free(object); + return hr; + } object->IMFStreamDescriptor_iface.lpVtbl = &streamdescriptorvtbl; object->IMFMediaTypeHandler_iface.lpVtbl = &mediatypehandlervtbl; object->identifier = identifier; object->media_types = heap_alloc(count * sizeof(*object->media_types)); + InitializeCriticalSection(&object->cs); if (!object->media_types) { - heap_free(object); + IMFStreamDescriptor_Release(&object->IMFStreamDescriptor_iface); return E_OUTOFMEMORY; } for (i = 0; i < count; ++i) @@ -977,7 +990,6 @@ HRESULT WINAPI MFCreateStreamDescriptor(DWORD identifier, DWORD count, IMFMediaType_AddRef(object->media_types[i]); } object->media_types_count = count; - InitializeCriticalSection(&object->cs);
*descriptor = &object->IMFStreamDescriptor_iface;
@@ -1027,6 +1039,7 @@ static ULONG WINAPI presentation_descriptor_Release(IMFPresentationDescriptor *i if (presentation_desc->descriptors[i].descriptor) IMFStreamDescriptor_Release(presentation_desc->descriptors[i].descriptor); } + clear_attributes_object(&presentation_desc->attributes); DeleteCriticalSection(&presentation_desc->cs); heap_free(presentation_desc->descriptors); heap_free(presentation_desc); @@ -1369,16 +1382,19 @@ static const IMFPresentationDescriptorVtbl presentationdescriptorvtbl =
static HRESULT presentation_descriptor_init(struct presentation_desc *object, DWORD count) { - init_attribute_object(&object->attributes, 0); + HRESULT hr; + + if (FAILED(hr = init_attributes_object(&object->attributes, 0))) + return hr; object->IMFPresentationDescriptor_iface.lpVtbl = &presentationdescriptorvtbl; object->descriptors = heap_alloc_zero(count * sizeof(*object->descriptors)); + InitializeCriticalSection(&object->cs); if (!object->descriptors) { - heap_free(object); + IMFPresentationDescriptor_Release(&object->IMFPresentationDescriptor_iface); return E_OUTOFMEMORY; } object->count = count; - InitializeCriticalSection(&object->cs);
return S_OK; } diff --git a/dlls/mfplat/mfplat_private.h b/dlls/mfplat/mfplat_private.h index c42570c8a9..7d2e25f435 100644 --- a/dlls/mfplat/mfplat_private.h +++ b/dlls/mfplat/mfplat_private.h @@ -24,13 +24,24 @@
#include "wine/heap.h"
+struct attribute +{ + GUID key; + PROPVARIANT value; +}; + typedef struct attributes { IMFAttributes IMFAttributes_iface; LONG ref; + CRITICAL_SECTION cs; + struct attribute *attributes; + size_t capacity; + size_t count; } mfattributes;
-extern void init_attribute_object(mfattributes *object, UINT32 size) DECLSPEC_HIDDEN; +extern HRESULT init_attributes_object(struct attributes *object, UINT32 size) DECLSPEC_HIDDEN; +extern void clear_attributes_object(struct attributes *object) DECLSPEC_HIDDEN;
extern void init_system_queues(void) DECLSPEC_HIDDEN; extern void shutdown_system_queues(void) DECLSPEC_HIDDEN;
From: Jactry Zeng jzeng@codeweavers.com
Signed-off-by: Jactry Zeng jzeng@codeweavers.com Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/mfplat/main.c | 85 ++++++++++++++++++++++++++++++++--- dlls/mfplat/tests/Makefile.in | 2 +- dlls/mfplat/tests/mfplat.c | 85 ++++++++++++++++++++++++++++++++++- 3 files changed, 165 insertions(+), 7 deletions(-)
diff --git a/dlls/mfplat/main.c b/dlls/mfplat/main.c index 9d8a3ae2fe..8ab7c979a8 100644 --- a/dlls/mfplat/main.c +++ b/dlls/mfplat/main.c @@ -642,11 +642,41 @@ static ULONG WINAPI mfattributes_Release(IMFAttributes *iface) return refcount; }
+static struct attribute *attributes_find_item(struct attributes *attributes, REFGUID key, size_t *index) +{ + size_t i; + + for (i = 0; i < attributes->count; ++i) + { + if (IsEqualGUID(key, &attributes->attributes[i].key)) + { + if (index) + *index = i; + return &attributes->attributes[i]; + } + } + + return NULL; +} + static HRESULT WINAPI mfattributes_GetItem(IMFAttributes *iface, REFGUID key, PROPVARIANT *value) { - FIXME("%p, %s, %p.\n", iface, debugstr_attr(key), value); + struct attributes *attributes = impl_from_IMFAttributes(iface); + struct attribute *attribute; + HRESULT hr;
- return E_NOTIMPL; + TRACE("%p, %s, %p.\n", iface, debugstr_attr(key), value); + + EnterCriticalSection(&attributes->cs); + + if ((attribute = attributes_find_item(attributes, key, NULL))) + hr = PropVariantCopy(value, &attribute->value); + else + hr = MF_E_ATTRIBUTENOTFOUND; + + LeaveCriticalSection(&attributes->cs); + + return hr; }
static HRESULT WINAPI mfattributes_GetItemType(IMFAttributes *iface, REFGUID key, MF_ATTRIBUTE_TYPE *type) @@ -753,11 +783,56 @@ static HRESULT WINAPI mfattributes_GetUnknown(IMFAttributes *iface, REFGUID key, return E_NOTIMPL; }
-static HRESULT WINAPI mfattributes_SetItem(IMFAttributes *iface, REFGUID key, REFPROPVARIANT Value) +static HRESULT attributes_set_item(struct attributes *attributes, REFGUID key, REFPROPVARIANT value) { - FIXME("%p, %s, %p.\n", iface, debugstr_attr(key), Value); + struct attribute *attribute;
- return E_NOTIMPL; + EnterCriticalSection(&attributes->cs); + + attribute = attributes_find_item(attributes, key, NULL); + if (!attribute) + { + if (!mf_array_reserve((void **)&attributes->attributes, &attributes->capacity, attributes->count + 1, + sizeof(*attributes->attributes))) + { + LeaveCriticalSection(&attributes->cs); + return E_OUTOFMEMORY; + } + attributes->attributes[attributes->count].key = *key; + attribute = &attributes->attributes[attributes->count++]; + } + else + PropVariantClear(&attribute->value); + + PropVariantCopy(&attribute->value, value); + + LeaveCriticalSection(&attributes->cs); + + return S_OK; +} + +static HRESULT WINAPI mfattributes_SetItem(IMFAttributes *iface, REFGUID key, REFPROPVARIANT value) +{ + struct attributes *attributes = impl_from_IMFAttributes(iface); + PROPVARIANT empty; + + TRACE("%p, %s, %p.\n", iface, debugstr_attr(key), value); + + switch (value->vt) + { + case MF_ATTRIBUTE_UINT32: + case MF_ATTRIBUTE_UINT64: + case MF_ATTRIBUTE_DOUBLE: + case MF_ATTRIBUTE_GUID: + case MF_ATTRIBUTE_STRING: + case MF_ATTRIBUTE_BLOB: + case MF_ATTRIBUTE_IUNKNOWN: + return attributes_set_item(attributes, key, value); + default: + PropVariantInit(&empty); + attributes_set_item(attributes, key, &empty); + return MF_E_INVALIDTYPE; + } }
static HRESULT WINAPI mfattributes_DeleteItem(IMFAttributes *iface, REFGUID key) diff --git a/dlls/mfplat/tests/Makefile.in b/dlls/mfplat/tests/Makefile.in index 15b8e17842..150ca6f954 100644 --- a/dlls/mfplat/tests/Makefile.in +++ b/dlls/mfplat/tests/Makefile.in @@ -1,5 +1,5 @@ TESTDLL = mfplat.dll -IMPORTS = ole32 mfplat mfuuid +IMPORTS = ole32 mfplat mfuuid propsys
C_SRCS = \ mfplat.c diff --git a/dlls/mfplat/tests/mfplat.c b/dlls/mfplat/tests/mfplat.c index aa8029c98d..8550160b8e 100644 --- a/dlls/mfplat/tests/mfplat.c +++ b/dlls/mfplat/tests/mfplat.c @@ -35,6 +35,7 @@ DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0); DEFINE_GUID(DUMMY_CLSID, 0x12345678,0x1234,0x1234,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19); DEFINE_GUID(DUMMY_GUID1, 0x12345678,0x1234,0x1234,0x21,0x21,0x21,0x21,0x21,0x21,0x21,0x21); DEFINE_GUID(DUMMY_GUID2, 0x12345678,0x1234,0x1234,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22); +DEFINE_GUID(DUMMY_GUID3, 0x12345678,0x1234,0x1234,0x23,0x23,0x23,0x23,0x23,0x23,0x23,0x23);
#undef INITGUID #include <guiddef.h> @@ -42,6 +43,7 @@ DEFINE_GUID(DUMMY_GUID2, 0x12345678,0x1234,0x1234,0x22,0x22,0x22,0x22,0x22,0x22, #include "mfidl.h" #include "mferror.h" #include "mfreadwrite.h" +#include "propvarutil.h"
#include "wine/test.h"
@@ -498,9 +500,10 @@ static void test_MFCreateMediaEvent(void)
static void test_MFCreateAttributes(void) { + PROPVARIANT propvar, ret_propvar; IMFAttributes *attributes; - HRESULT hr; UINT32 count; + HRESULT hr;
hr = MFCreateAttributes( &attributes, 3 ); ok(hr == S_OK, "got 0x%08x\n", hr); @@ -518,6 +521,86 @@ static void test_MFCreateAttributes(void) todo_wine ok(count == 1, "got %d\n", count);
IMFAttributes_Release(attributes); + + hr = MFCreateAttributes(&attributes, 0); + ok(hr == S_OK, "Failed to create attributes object, hr %#x.\n", hr); + + PropVariantInit(&propvar); + propvar.vt = MF_ATTRIBUTE_UINT32; + U(propvar).ulVal = 123; + hr = IMFAttributes_SetItem(attributes, &DUMMY_GUID1, &propvar); + ok(hr == S_OK, "Failed to set item, hr %#x.\n", hr); + PropVariantInit(&ret_propvar); + ret_propvar.vt = MF_ATTRIBUTE_UINT32; + U(ret_propvar).ulVal = 0xdeadbeef; + hr = IMFAttributes_GetItem(attributes, &DUMMY_GUID1, &ret_propvar); + ok(hr == S_OK, "Failed to get item, hr %#x.\n", hr); + ok(!PropVariantCompareEx(&propvar, &ret_propvar, 0, 0), "Unexpected item value.\n"); + PropVariantClear(&ret_propvar); + + PropVariantInit(&ret_propvar); + ret_propvar.vt = MF_ATTRIBUTE_STRING; + U(ret_propvar).pwszVal = NULL; + hr = IMFAttributes_GetItem(attributes, &DUMMY_GUID1, &ret_propvar); + ok(hr == S_OK, "Failed to get item, hr %#x.\n", hr); + ok(!PropVariantCompareEx(&propvar, &ret_propvar, 0, 0), "Unexpected item value.\n"); + PropVariantClear(&ret_propvar); + + PropVariantClear(&propvar); + + PropVariantInit(&propvar); + propvar.vt = MF_ATTRIBUTE_UINT64; + U(propvar).uhVal.QuadPart = 65536; + hr = IMFAttributes_SetItem(attributes, &DUMMY_GUID1, &propvar); + ok(hr == S_OK, "Failed to set item, hr %#x.\n", hr); + PropVariantInit(&ret_propvar); + ret_propvar.vt = MF_ATTRIBUTE_UINT32; + U(ret_propvar).ulVal = 0xdeadbeef; + hr = IMFAttributes_GetItem(attributes, &DUMMY_GUID1, &ret_propvar); + ok(hr == S_OK, "Failed to get item, hr %#x.\n", hr); + ok(!PropVariantCompareEx(&propvar, &ret_propvar, 0, 0), "Unexpected item value.\n"); + PropVariantClear(&ret_propvar); + PropVariantClear(&propvar); + + PropVariantInit(&propvar); + propvar.vt = VT_I4; + U(propvar).lVal = 123; + hr = IMFAttributes_SetItem(attributes, &DUMMY_GUID2, &propvar); + ok(hr == MF_E_INVALIDTYPE, "Failed to set item, hr %#x.\n", hr); + PropVariantInit(&ret_propvar); + ret_propvar.vt = MF_ATTRIBUTE_UINT32; + U(ret_propvar).lVal = 0xdeadbeef; + hr = IMFAttributes_GetItem(attributes, &DUMMY_GUID2, &ret_propvar); + ok(hr == S_OK, "Failed to get item, hr %#x.\n", hr); + PropVariantClear(&propvar); + ok(!PropVariantCompareEx(&propvar, &ret_propvar, 0, 0), "Unexpected item value.\n"); + PropVariantClear(&ret_propvar); + + PropVariantInit(&propvar); + propvar.vt = MF_ATTRIBUTE_UINT32; + U(propvar).ulVal = 123; + hr = IMFAttributes_SetItem(attributes, &DUMMY_GUID3, &propvar); + ok(hr == S_OK, "Failed to set item, hr %#x.\n", hr); + + hr = IMFAttributes_DeleteItem(attributes, &DUMMY_GUID2); + todo_wine ok(hr == S_OK, "Failed to delete item, hr %#x.\n", hr); + + hr = IMFAttributes_GetItem(attributes, &DUMMY_GUID3, &ret_propvar); + ok(hr == S_OK, "Failed to get item, hr %#x.\n", hr); + ok(!PropVariantCompareEx(&propvar, &ret_propvar, 0, 0), "Unexpected item value.\n"); + PropVariantClear(&ret_propvar); + PropVariantClear(&propvar); + + propvar.vt = MF_ATTRIBUTE_UINT64; + U(propvar).uhVal.QuadPart = 65536; + + hr = IMFAttributes_GetItem(attributes, &DUMMY_GUID1, &ret_propvar); + ok(hr == S_OK, "Failed to get item, hr %#x.\n", hr); + ok(!PropVariantCompareEx(&propvar, &ret_propvar, 0, 0), "Unexpected item value.\n"); + PropVariantClear(&ret_propvar); + PropVariantClear(&propvar); + + IMFAttributes_Release(attributes); }
static void test_MFCreateMFByteStreamOnStream(void)
From: Jactry Zeng jzeng@codeweavers.com
Signed-off-by: Jactry Zeng jzeng@codeweavers.com Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/mfplat/main.c | 24 ++++++++++++++++++++++-- dlls/mfplat/tests/mfplat.c | 5 ++++- 2 files changed, 26 insertions(+), 3 deletions(-)
diff --git a/dlls/mfplat/main.c b/dlls/mfplat/main.c index 8ab7c979a8..e12847e90d 100644 --- a/dlls/mfplat/main.c +++ b/dlls/mfplat/main.c @@ -837,9 +837,29 @@ static HRESULT WINAPI mfattributes_SetItem(IMFAttributes *iface, REFGUID key, RE
static HRESULT WINAPI mfattributes_DeleteItem(IMFAttributes *iface, REFGUID key) { - FIXME("%p, %s.\n", iface, debugstr_attr(key)); + struct attributes *attributes = impl_from_IMFAttributes(iface); + struct attribute *attribute; + size_t index = 0;
- return E_NOTIMPL; + TRACE("%p, %s.\n", iface, debugstr_attr(key)); + + EnterCriticalSection(&attributes->cs); + + if ((attribute = attributes_find_item(attributes, key, &index))) + { + size_t count; + + PropVariantClear(&attribute->value); + + attributes->count--; + count = attributes->count - index; + if (count) + memmove(&attributes->attributes[index], &attributes->attributes[index + 1], count * sizeof(*attributes->attributes)); + } + + LeaveCriticalSection(&attributes->cs); + + return S_OK; }
static HRESULT WINAPI mfattributes_DeleteAllItems(IMFAttributes *iface) diff --git a/dlls/mfplat/tests/mfplat.c b/dlls/mfplat/tests/mfplat.c index 8550160b8e..3a94d4bd17 100644 --- a/dlls/mfplat/tests/mfplat.c +++ b/dlls/mfplat/tests/mfplat.c @@ -583,7 +583,10 @@ static void test_MFCreateAttributes(void) ok(hr == S_OK, "Failed to set item, hr %#x.\n", hr);
hr = IMFAttributes_DeleteItem(attributes, &DUMMY_GUID2); - todo_wine ok(hr == S_OK, "Failed to delete item, hr %#x.\n", hr); + ok(hr == S_OK, "Failed to delete item, hr %#x.\n", hr); + + hr = IMFAttributes_DeleteItem(attributes, &DUMMY_GUID2); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
hr = IMFAttributes_GetItem(attributes, &DUMMY_GUID3, &ret_propvar); ok(hr == S_OK, "Failed to get item, hr %#x.\n", hr);
Hi,
While running your changed tests on Windows, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=49320
Your paranoid android.
=== wxppro (32 bit report) ===
mfplat: 0b40:mfplat: unhandled exception c0000005 at 2F2E2E2F
From: Jactry Zeng jzeng@codeweavers.com
Signed-off-by: Jactry Zeng jzeng@codeweavers.com Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/mfplat/main.c | 19 ++++++++++++++++--- dlls/mfplat/tests/mfplat.c | 10 ++++++++++ 2 files changed, 26 insertions(+), 3 deletions(-)
diff --git a/dlls/mfplat/main.c b/dlls/mfplat/main.c index e12847e90d..c339f23ff6 100644 --- a/dlls/mfplat/main.c +++ b/dlls/mfplat/main.c @@ -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) { - 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) diff --git a/dlls/mfplat/tests/mfplat.c b/dlls/mfplat/tests/mfplat.c index 3a94d4bd17..273aa2684b 100644 --- a/dlls/mfplat/tests/mfplat.c +++ b/dlls/mfplat/tests/mfplat.c @@ -504,6 +504,7 @@ static void test_MFCreateAttributes(void) IMFAttributes *attributes; UINT32 count; HRESULT hr; + GUID key;
hr = MFCreateAttributes( &attributes, 3 ); ok(hr == S_OK, "got 0x%08x\n", hr); @@ -603,6 +604,15 @@ static void test_MFCreateAttributes(void) PropVariantClear(&ret_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); }
Hi,
While running your changed tests on Windows, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=49321
Your paranoid android.
=== wxppro (32 bit report) ===
mfplat: 0b40:mfplat: unhandled exception c0000005 at 2F2E2E2F
=== debian9 (32 bit report) ===
mfplat: mfplat.c:1934: Test failed: Unexpected refcount 1. Unhandled exception: page fault on execute access to 0x00000000 in 32-bit code (0x00000000).
Report errors: mfplat:mfplat crashed (c0000005)
From: Jactry Zeng jzeng@codeweavers.com
Signed-off-by: Jactry Zeng jzeng@codeweavers.com Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/mfplat/Makefile.in | 2 +- dlls/mfplat/main.c | 71 ++++++++++++++++++++++++++++----- dlls/mfplat/tests/mfplat.c | 35 ++++++++++++---- dlls/mfreadwrite/tests/mfplat.c | 2 +- 4 files changed, 91 insertions(+), 19 deletions(-)
diff --git a/dlls/mfplat/Makefile.in b/dlls/mfplat/Makefile.in index e64e4058c1..eb9b26f10a 100644 --- a/dlls/mfplat/Makefile.in +++ b/dlls/mfplat/Makefile.in @@ -1,6 +1,6 @@ MODULE = mfplat.dll IMPORTLIB = mfplat -IMPORTS = advapi32 ole32 mfuuid +IMPORTS = advapi32 ole32 mfuuid propsys
C_SRCS = \ buffer.c \ diff --git a/dlls/mfplat/main.c b/dlls/mfplat/main.c index c339f23ff6..4b4f262a31 100644 --- a/dlls/mfplat/main.c +++ b/dlls/mfplat/main.c @@ -20,6 +20,7 @@ #include <string.h>
#define COBJMACROS +#define NONAMELESSUNION
#include "windef.h" #include "winbase.h" @@ -35,6 +36,7 @@
#include "mfplat_private.h" #include "mfreadwrite.h" +#include "propvarutil.h"
WINE_DEFAULT_DEBUG_CHANNEL(mfplat);
@@ -659,6 +661,29 @@ static struct attribute *attributes_find_item(struct attributes *attributes, REF return NULL; }
+static HRESULT attributes_get_item(struct attributes *attributes, const GUID *key, PROPVARIANT *value) +{ + struct attribute *attribute; + HRESULT hr; + + EnterCriticalSection(&attributes->cs); + + attribute = attributes_find_item(attributes, key, NULL); + if (attribute) + { + if (attribute->value.vt == value->vt) + hr = PropVariantCopy(value, &attribute->value); + else + hr = MF_E_INVALIDTYPE; + } + else + hr = MF_E_ATTRIBUTENOTFOUND; + + LeaveCriticalSection(&attributes->cs); + + return hr; +} + static HRESULT WINAPI mfattributes_GetItem(IMFAttributes *iface, REFGUID key, PROPVARIANT *value) { struct attributes *attributes = impl_from_IMFAttributes(iface); @@ -705,16 +730,34 @@ static HRESULT WINAPI mfattributes_Compare(IMFAttributes *iface, IMFAttributes *
static HRESULT WINAPI mfattributes_GetUINT32(IMFAttributes *iface, REFGUID key, UINT32 *value) { - FIXME("%p, %s, %p.\n", iface, debugstr_attr(key), value); + struct attributes *attributes = impl_from_IMFAttributes(iface); + PROPVARIANT attrval; + HRESULT hr;
- return E_NOTIMPL; + TRACE("%p, %s, %p.\n", iface, debugstr_attr(key), value); + + PropVariantInit(&attrval); + attrval.vt = VT_UI4; + hr = attributes_get_item(attributes, key, &attrval); + if (SUCCEEDED(hr)) + hr = PropVariantToUInt32(&attrval, value); + return hr; }
static HRESULT WINAPI mfattributes_GetUINT64(IMFAttributes *iface, REFGUID key, UINT64 *value) { - FIXME("%p, %s, %p.\n", iface, debugstr_attr(key), value); + struct attributes *attributes = impl_from_IMFAttributes(iface); + PROPVARIANT attrval; + HRESULT hr;
- return E_NOTIMPL; + TRACE("%p, %s, %p.\n", iface, debugstr_attr(key), value); + + PropVariantInit(&attrval); + attrval.vt = VT_UI8; + hr = attributes_get_item(attributes, key, &attrval); + if (SUCCEEDED(hr)) + hr = PropVariantToUInt64(&attrval, value); + return hr; }
static HRESULT WINAPI mfattributes_GetDouble(IMFAttributes *iface, REFGUID key, double *value) @@ -873,16 +916,26 @@ static HRESULT WINAPI mfattributes_DeleteAllItems(IMFAttributes *iface)
static HRESULT WINAPI mfattributes_SetUINT32(IMFAttributes *iface, REFGUID key, UINT32 value) { - FIXME("%p, %s, %d.\n", iface, debugstr_attr(key), value); + struct attributes *attributes = impl_from_IMFAttributes(iface); + PROPVARIANT attrval;
- return E_NOTIMPL; + TRACE("%p, %s, %d.\n", iface, debugstr_attr(key), value); + + attrval.vt = VT_UI4; + attrval.u.ulVal = value; + return attributes_set_item(attributes, key, &attrval); }
static HRESULT WINAPI mfattributes_SetUINT64(IMFAttributes *iface, REFGUID key, UINT64 value) { - FIXME("%p, %s, %s.\n", iface, debugstr_attr(key), wine_dbgstr_longlong(value)); + struct attributes *attributes = impl_from_IMFAttributes(iface); + PROPVARIANT attrval;
- return E_NOTIMPL; + TRACE("%p, %s, %s.\n", iface, debugstr_attr(key), wine_dbgstr_longlong(value)); + + attrval.vt = VT_UI8; + attrval.u.uhVal.QuadPart = value; + return attributes_set_item(attributes, key, &attrval); }
static HRESULT WINAPI mfattributes_SetDouble(IMFAttributes *iface, REFGUID key, double value) @@ -3481,7 +3534,7 @@ static HRESULT WINAPI eventqueue_QueueEventParamUnk(IMFMediaEventQueue *iface, M TRACE("%p, %d, %s, %#x, %p.\n", iface, event_type, debugstr_guid(extended_type), status, unk);
value.vt = VT_UNKNOWN; - value.punkVal = unk; + value.u.punkVal = unk;
if (FAILED(hr = MFCreateMediaEvent(event_type, extended_type, status, &value, &event))) return hr; diff --git a/dlls/mfplat/tests/mfplat.c b/dlls/mfplat/tests/mfplat.c index 273aa2684b..b51e5e23ee 100644 --- a/dlls/mfplat/tests/mfplat.c +++ b/dlls/mfplat/tests/mfplat.c @@ -359,25 +359,21 @@ todo_wine ok(compressed, "Unexpected value %d.\n", compressed);
hr = IMFMediaType_SetUINT32(mediatype, &MF_MT_ALL_SAMPLES_INDEPENDENT, 0); -todo_wine ok(hr == S_OK, "Failed to set attribute, hr %#x.\n", hr);
compressed = FALSE; hr = IMFMediaType_IsCompressedFormat(mediatype, &compressed); -todo_wine ok(hr == S_OK, "Failed to get media type property, hr %#x.\n", hr); ok(compressed, "Unexpected value %d.\n", compressed);
hr = IMFMediaType_SetUINT32(mediatype, &MF_MT_ALL_SAMPLES_INDEPENDENT, 1); -todo_wine ok(hr == S_OK, "Failed to set attribute, hr %#x.\n", hr);
compressed = TRUE; hr = IMFMediaType_IsCompressedFormat(mediatype, &compressed); -todo_wine { ok(hr == S_OK, "Failed to get media type property, hr %#x.\n", hr); ok(!compressed, "Unexpected value %d.\n", compressed); -} + hr = IMFMediaType_SetGUID(mediatype, &MF_MT_MAJOR_TYPE, &MFMediaType_Video); todo_wine ok(hr == S_OK, "got 0x%08x\n", hr);
@@ -502,7 +498,8 @@ static void test_MFCreateAttributes(void) { PROPVARIANT propvar, ret_propvar; IMFAttributes *attributes; - UINT32 count; + UINT32 count, value; + UINT64 value64; HRESULT hr; GUID key;
@@ -514,13 +511,35 @@ static void test_MFCreateAttributes(void) todo_wine ok(hr == S_OK, "got 0x%08x\n", hr); ok(count == 0, "got %d\n", count);
- hr = IMFAttributes_SetUINT32(attributes, &MF_READWRITE_ENABLE_HARDWARE_TRANSFORMS, 0); - todo_wine ok(hr == S_OK, "got 0x%08x\n", hr); + hr = IMFAttributes_SetUINT32(attributes, &MF_READWRITE_ENABLE_HARDWARE_TRANSFORMS, 123); + ok(hr == S_OK, "Failed to set UINT32 value, hr %#x.\n", hr);
hr = IMFAttributes_GetCount(attributes, &count); todo_wine ok(hr == S_OK, "got 0x%08x\n", hr); todo_wine ok(count == 1, "got %d\n", count);
+ value = 0xdeadbeef; + hr = IMFAttributes_GetUINT32(attributes, &MF_READWRITE_ENABLE_HARDWARE_TRANSFORMS, &value); + ok(hr == S_OK, "Failed to get UINT32 value, hr %#x.\n", hr); + ok(value == 123, "Unexpected value %u, expected: 123.\n", value); + + value64 = 0xdeadbeef; + hr = IMFAttributes_GetUINT64(attributes, &MF_READWRITE_ENABLE_HARDWARE_TRANSFORMS, &value64); + ok(hr == MF_E_INVALIDTYPE, "Unexpected hr %#x.\n", hr); + ok(value64 == 0xdeadbeef, "Unexpected value.\n"); + + hr = IMFAttributes_SetUINT64(attributes, &MF_READWRITE_ENABLE_HARDWARE_TRANSFORMS, 65536); + ok(hr == S_OK, "Failed to set UINT64 value, hr %#x.\n", hr); + + hr = IMFAttributes_GetUINT64(attributes, &MF_READWRITE_ENABLE_HARDWARE_TRANSFORMS, &value64); + ok(hr == S_OK, "Failed to get UINT64 value, hr %#x.\n", hr); + ok(value64 == 65536, "Unexpected value.\n"); + + value = 0xdeadbeef; + hr = IMFAttributes_GetUINT32(attributes, &MF_READWRITE_ENABLE_HARDWARE_TRANSFORMS, &value); + ok(hr == MF_E_INVALIDTYPE, "Unexpected hr %#x.\n", hr); + ok(value == 0xdeadbeef, "Unexpected value.\n"); + IMFAttributes_Release(attributes);
hr = MFCreateAttributes(&attributes, 0); diff --git a/dlls/mfreadwrite/tests/mfplat.c b/dlls/mfreadwrite/tests/mfplat.c index 58533ccd3a..1767433e24 100644 --- a/dlls/mfreadwrite/tests/mfplat.c +++ b/dlls/mfreadwrite/tests/mfplat.c @@ -67,7 +67,7 @@ static void test_MFCreateSourceReaderFromByteStream(void) todo_wine ok(hr == S_OK, "got 0x%08x\n", hr);
hr = IMFAttributes_SetUINT32(attributes, &MF_READWRITE_MMCSS_PRIORITY_AUDIO, 0); - todo_wine ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "Failed to set attribute, hr %#x.\n", hr);
hr = CreateStreamOnHGlobal(NULL, TRUE, &stream); ok(hr == S_OK, "got 0x%08x\n", hr);
From: Jactry Zeng jzeng@codeweavers.com
Signed-off-by: Jactry Zeng jzeng@codeweavers.com Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/mfplat/main.c | 11 ++++++----- dlls/mfplat/tests/mfplat.c | 27 +++++++++++++++++---------- 2 files changed, 23 insertions(+), 15 deletions(-)
diff --git a/dlls/mfplat/main.c b/dlls/mfplat/main.c index 4b4f262a31..7bb09d6528 100644 --- a/dlls/mfplat/main.c +++ b/dlls/mfplat/main.c @@ -993,14 +993,15 @@ static HRESULT WINAPI mfattributes_UnlockStore(IMFAttributes *iface)
static HRESULT WINAPI mfattributes_GetCount(IMFAttributes *iface, UINT32 *items) { - mfattributes *This = impl_from_IMFAttributes(iface); + struct attributes *attributes = impl_from_IMFAttributes(iface);
- FIXME("%p, %p\n", This, items); + TRACE("%p, %p.\n", iface, items);
- if(items) - *items = 0; + EnterCriticalSection(&attributes->cs); + *items = attributes->count; + LeaveCriticalSection(&attributes->cs);
- return E_NOTIMPL; + return S_OK; }
static HRESULT WINAPI mfattributes_GetItemByIndex(IMFAttributes *iface, UINT32 index, GUID *key, PROPVARIANT *value) diff --git a/dlls/mfplat/tests/mfplat.c b/dlls/mfplat/tests/mfplat.c index b51e5e23ee..361584ff7b 100644 --- a/dlls/mfplat/tests/mfplat.c +++ b/dlls/mfplat/tests/mfplat.c @@ -494,29 +494,31 @@ static void test_MFCreateMediaEvent(void) IMFMediaEvent_Release(mediaevent); }
+#define CHECK_ATTR_COUNT(obj, expected) check_attr_count(obj, expected, __LINE__) +static void check_attr_count(IMFAttributes* obj, UINT32 expected, int line) +{ + UINT32 count = expected + 1; + HRESULT hr = IMFAttributes_GetCount(obj, &count); + ok_(__FILE__, line)(hr == S_OK, "Failed to get attributes count, hr %#x.\n", hr); + ok_(__FILE__, line)(count == expected, "Unexpected count %u, expected %u.\n", count, expected); +} + static void test_MFCreateAttributes(void) { PROPVARIANT propvar, ret_propvar; IMFAttributes *attributes; - UINT32 count, value; UINT64 value64; + UINT32 value; HRESULT hr; GUID key;
hr = MFCreateAttributes( &attributes, 3 ); ok(hr == S_OK, "got 0x%08x\n", hr);
- count = 88; - hr = IMFAttributes_GetCount(attributes, &count); - todo_wine ok(hr == S_OK, "got 0x%08x\n", hr); - ok(count == 0, "got %d\n", count); - + CHECK_ATTR_COUNT(attributes, 0); hr = IMFAttributes_SetUINT32(attributes, &MF_READWRITE_ENABLE_HARDWARE_TRANSFORMS, 123); ok(hr == S_OK, "Failed to set UINT32 value, hr %#x.\n", hr); - - hr = IMFAttributes_GetCount(attributes, &count); - todo_wine ok(hr == S_OK, "got 0x%08x\n", hr); - todo_wine ok(count == 1, "got %d\n", count); + CHECK_ATTR_COUNT(attributes, 1);
value = 0xdeadbeef; hr = IMFAttributes_GetUINT32(attributes, &MF_READWRITE_ENABLE_HARDWARE_TRANSFORMS, &value); @@ -530,6 +532,7 @@ static void test_MFCreateAttributes(void)
hr = IMFAttributes_SetUINT64(attributes, &MF_READWRITE_ENABLE_HARDWARE_TRANSFORMS, 65536); ok(hr == S_OK, "Failed to set UINT64 value, hr %#x.\n", hr); + CHECK_ATTR_COUNT(attributes, 1);
hr = IMFAttributes_GetUINT64(attributes, &MF_READWRITE_ENABLE_HARDWARE_TRANSFORMS, &value64); ok(hr == S_OK, "Failed to get UINT64 value, hr %#x.\n", hr); @@ -557,6 +560,7 @@ static void test_MFCreateAttributes(void) ok(hr == S_OK, "Failed to get item, hr %#x.\n", hr); ok(!PropVariantCompareEx(&propvar, &ret_propvar, 0, 0), "Unexpected item value.\n"); PropVariantClear(&ret_propvar); + CHECK_ATTR_COUNT(attributes, 1);
PropVariantInit(&ret_propvar); ret_propvar.vt = MF_ATTRIBUTE_STRING; @@ -581,6 +585,7 @@ static void test_MFCreateAttributes(void) ok(!PropVariantCompareEx(&propvar, &ret_propvar, 0, 0), "Unexpected item value.\n"); PropVariantClear(&ret_propvar); PropVariantClear(&propvar); + CHECK_ATTR_COUNT(attributes, 1);
PropVariantInit(&propvar); propvar.vt = VT_I4; @@ -604,9 +609,11 @@ static void test_MFCreateAttributes(void)
hr = IMFAttributes_DeleteItem(attributes, &DUMMY_GUID2); ok(hr == S_OK, "Failed to delete item, hr %#x.\n", hr); + CHECK_ATTR_COUNT(attributes, 2);
hr = IMFAttributes_DeleteItem(attributes, &DUMMY_GUID2); ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + CHECK_ATTR_COUNT(attributes, 2);
hr = IMFAttributes_GetItem(attributes, &DUMMY_GUID3, &ret_propvar); ok(hr == S_OK, "Failed to get item, hr %#x.\n", hr);
Hi,
While running your changed tests on Windows, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=49323
Your paranoid android.
=== w7u (32 bit report) ===
mfplat: mfplat.c:1960: Test failed: Unexpected refcount 1.
=== debian9 (32 bit Chinese:China report) ===
mfplat: mfplat.c:1960: Test failed: Unexpected refcount 1. Unhandled exception: page fault on read access to 0x00000009 in 32-bit code (0x7e5da39a).
Report errors: mfplat:mfplat crashed (c0000005)
=== debian9 (64 bit WoW report) ===
mfplat: mfplat.c:1960: Test failed: Unexpected refcount 1. Unhandled exception: page fault on read access to 0x00000011 in 64-bit code (0x00007f06aaf5b675).
Report errors: mfplat:mfplat crashed (c0000005)
From: Jactry Zeng jzeng@codeweavers.com
Signed-off-by: Jactry Zeng jzeng@codeweavers.com Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/mfplat/main.c | 22 ++++++++++++++++++---- dlls/mfplat/tests/mfplat.c | 10 ++++++++++ 2 files changed, 28 insertions(+), 4 deletions(-)
diff --git a/dlls/mfplat/main.c b/dlls/mfplat/main.c index 7bb09d6528..6fb917e219 100644 --- a/dlls/mfplat/main.c +++ b/dlls/mfplat/main.c @@ -762,9 +762,18 @@ static HRESULT WINAPI mfattributes_GetUINT64(IMFAttributes *iface, REFGUID key,
static HRESULT WINAPI mfattributes_GetDouble(IMFAttributes *iface, REFGUID key, double *value) { - FIXME("%p, %s, %p.\n", iface, debugstr_attr(key), value); + struct attributes *attributes = impl_from_IMFAttributes(iface); + PROPVARIANT attrval; + HRESULT hr;
- return E_NOTIMPL; + TRACE("%p, %s, %p.\n", iface, debugstr_attr(key), value); + + PropVariantInit(&attrval); + attrval.vt = VT_R8; + hr = attributes_get_item(attributes, key, &attrval); + if (SUCCEEDED(hr)) + hr = PropVariantToDouble(&attrval, value); + return hr; }
static HRESULT WINAPI mfattributes_GetGUID(IMFAttributes *iface, REFGUID key, GUID *value) @@ -940,9 +949,14 @@ static HRESULT WINAPI mfattributes_SetUINT64(IMFAttributes *iface, REFGUID key,
static HRESULT WINAPI mfattributes_SetDouble(IMFAttributes *iface, REFGUID key, double value) { - FIXME("%p, %s, %f.\n", iface, debugstr_attr(key), value); + struct attributes *attributes = impl_from_IMFAttributes(iface); + PROPVARIANT attrval;
- return E_NOTIMPL; + TRACE("%p, %s, %f.\n", iface, debugstr_attr(key), value); + + attrval.vt = VT_R8; + attrval.u.dblVal = value; + return attributes_set_item(attributes, key, &attrval); }
static HRESULT WINAPI mfattributes_SetGUID(IMFAttributes *iface, REFGUID key, REFGUID value) diff --git a/dlls/mfplat/tests/mfplat.c b/dlls/mfplat/tests/mfplat.c index 361584ff7b..e6a3f4b9d5 100644 --- a/dlls/mfplat/tests/mfplat.c +++ b/dlls/mfplat/tests/mfplat.c @@ -507,6 +507,7 @@ static void test_MFCreateAttributes(void) { PROPVARIANT propvar, ret_propvar; IMFAttributes *attributes; + double double_value; UINT64 value64; UINT32 value; HRESULT hr; @@ -639,6 +640,15 @@ static void test_MFCreateAttributes(void) ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr); PropVariantClear(&ret_propvar);
+ hr = IMFAttributes_SetDouble(attributes, &GUID_NULL, 22.0); + ok(hr == S_OK, "Failed to set double value, hr %#x.\n", hr); + CHECK_ATTR_COUNT(attributes, 3); + + double_value = 0xdeadbeef; + hr = IMFAttributes_GetDouble(attributes, &GUID_NULL, &double_value); + ok(hr == S_OK, "Failed to get double value, hr %#x.\n", hr); + ok(double_value == 22.0, "Unexpected value: %f, expected: 22.0.\n", double_value); + IMFAttributes_Release(attributes); }
From: Jactry Zeng jzeng@codeweavers.com
Signed-off-by: Jactry Zeng jzeng@codeweavers.com Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/mfplat/main.c | 63 +++++++++++++++++++++++++++------ dlls/mfplat/tests/mfplat.c | 44 +++++++++++++++++++++-- dlls/mfreadwrite/tests/mfplat.c | 2 +- 3 files changed, 95 insertions(+), 14 deletions(-)
diff --git a/dlls/mfplat/main.c b/dlls/mfplat/main.c index 6fb917e219..d73076bd83 100644 --- a/dlls/mfplat/main.c +++ b/dlls/mfplat/main.c @@ -785,25 +785,61 @@ static HRESULT WINAPI mfattributes_GetGUID(IMFAttributes *iface, REFGUID key, GU
static HRESULT WINAPI mfattributes_GetStringLength(IMFAttributes *iface, REFGUID key, UINT32 *length) { - FIXME("%p, %s, %p.\n", iface, debugstr_attr(key), length); + struct attributes *attributes = impl_from_IMFAttributes(iface); + PROPVARIANT attrval; + HRESULT hr;
- return E_NOTIMPL; + TRACE("%p, %s, %p.\n", iface, debugstr_attr(key), length); + + PropVariantInit(&attrval); + attrval.vt = VT_LPWSTR; + hr = attributes_get_item(attributes, key, &attrval); + if (SUCCEEDED(hr) && length) + *length = lstrlenW(attrval.u.pwszVal); + PropVariantClear(&attrval); + + return hr; }
static HRESULT WINAPI mfattributes_GetString(IMFAttributes *iface, REFGUID key, WCHAR *value, - UINT32 size, UINT32 *length) + UINT32 size, UINT32 *length) { - FIXME("%p, %s, %p, %d, %p.\n", iface, debugstr_attr(key), value, size, length); + struct attributes *attributes = impl_from_IMFAttributes(iface); + PROPVARIANT attrval; + HRESULT hr;
- return E_NOTIMPL; + TRACE("%p, %s, %p, %d, %p.\n", iface, debugstr_attr(key), value, size, length); + + PropVariantInit(&attrval); + attrval.vt = VT_LPWSTR; + hr = attributes_get_item(attributes, key, &attrval); + if (SUCCEEDED(hr)) + hr = PropVariantToString(&attrval, value, size); + if (SUCCEEDED(hr) && length) + *length = lstrlenW(value); + PropVariantClear(&attrval); + + return hr; }
-static HRESULT WINAPI mfattributes_GetAllocatedString(IMFAttributes *iface, REFGUID key, - WCHAR **value, UINT32 *length) +static HRESULT WINAPI mfattributes_GetAllocatedString(IMFAttributes *iface, REFGUID key, WCHAR **value, UINT32 *length) { - FIXME("%p, %s, %p, %p.\n", iface, debugstr_attr(key), value, length); + struct attributes *attributes = impl_from_IMFAttributes(iface); + PROPVARIANT attrval; + HRESULT hr;
- return E_NOTIMPL; + TRACE("%p, %s, %p, %p.\n", iface, debugstr_attr(key), value, length); + + PropVariantInit(&attrval); + attrval.vt = VT_LPWSTR; + hr = attributes_get_item(attributes, key, &attrval); + if (SUCCEEDED(hr)) + { + *value = attrval.u.pwszVal; + *length = lstrlenW(*value); + } + + return hr; }
static HRESULT WINAPI mfattributes_GetBlobSize(IMFAttributes *iface, REFGUID key, UINT32 *size) @@ -968,9 +1004,14 @@ static HRESULT WINAPI mfattributes_SetGUID(IMFAttributes *iface, REFGUID key, RE
static HRESULT WINAPI mfattributes_SetString(IMFAttributes *iface, REFGUID key, const WCHAR *value) { - FIXME("%p, %s, %s.\n", iface, debugstr_attr(key), debugstr_w(value)); + struct attributes *attributes = impl_from_IMFAttributes(iface); + PROPVARIANT attrval;
- return E_NOTIMPL; + TRACE("%p, %s, %s.\n", iface, debugstr_attr(key), debugstr_w(value)); + + attrval.vt = VT_LPWSTR; + attrval.u.pwszVal = (WCHAR *)value; + return attributes_set_item(attributes, key, &attrval); }
static HRESULT WINAPI mfattributes_SetBlob(IMFAttributes *iface, REFGUID key, const UINT8 *buf, UINT32 size) diff --git a/dlls/mfplat/tests/mfplat.c b/dlls/mfplat/tests/mfplat.c index e6a3f4b9d5..3fda11d0c7 100644 --- a/dlls/mfplat/tests/mfplat.c +++ b/dlls/mfplat/tests/mfplat.c @@ -44,6 +44,7 @@ DEFINE_GUID(DUMMY_GUID3, 0x12345678,0x1234,0x1234,0x23,0x23,0x23,0x23,0x23,0x23, #include "mferror.h" #include "mfreadwrite.h" #include "propvarutil.h" +#include "strsafe.h"
#include "wine/test.h"
@@ -285,7 +286,7 @@ static void test_source_resolver(void) (void **)&attributes); ok(hr == S_OK, "got 0x%08x\n", hr); hr = IMFAttributes_SetString(attributes, &MF_BYTESTREAM_CONTENT_TYPE, file_type); - todo_wine ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "Failed to set string value, hr %#x.\n", hr); IMFAttributes_Release(attributes);
hr = IMFSourceResolver_CreateObjectFromByteStream( @@ -505,11 +506,14 @@ 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}; PROPVARIANT propvar, ret_propvar; + UINT32 value, string_length; IMFAttributes *attributes; double double_value; + WCHAR bufferW[256]; UINT64 value64; - UINT32 value; + WCHAR *string; HRESULT hr; GUID key;
@@ -649,6 +653,42 @@ static void test_MFCreateAttributes(void) ok(hr == S_OK, "Failed to get double value, hr %#x.\n", hr); ok(double_value == 22.0, "Unexpected value: %f, expected: 22.0.\n", double_value);
+ hr = IMFAttributes_SetString(attributes, &DUMMY_GUID1, stringW); + ok(hr == S_OK, "Failed to set string attribute, hr %#x.\n", hr); + CHECK_ATTR_COUNT(attributes, 3); + + hr = IMFAttributes_GetStringLength(attributes, &DUMMY_GUID1, &string_length); + ok(hr == S_OK, "Failed to get string length, hr %#x.\n", hr); + ok(string_length == lstrlenW(stringW), "Unexpected length %u.\n", string_length); + + string_length = 0xdeadbeef; + hr = IMFAttributes_GetAllocatedString(attributes, &DUMMY_GUID1, &string, &string_length); + ok(hr == S_OK, "Failed to get allocated string, hr %#x.\n", hr); + ok(!lstrcmpW(string, stringW), "Unexpected string %s.\n", wine_dbgstr_w(string)); + ok(string_length == lstrlenW(stringW), "Unexpected length %u.\n", string_length); + CoTaskMemFree(string); + + string_length = 0xdeadbeef; + hr = IMFAttributes_GetString(attributes, &DUMMY_GUID1, bufferW, ARRAY_SIZE(bufferW), &string_length); + ok(hr == S_OK, "Failed to get string value, hr %#x.\n", hr); + ok(!lstrcmpW(bufferW, stringW), "Unexpected string %s.\n", wine_dbgstr_w(bufferW)); + ok(string_length == lstrlenW(stringW), "Unexpected length %u.\n", string_length); + memset(bufferW, 0, sizeof(bufferW)); + + hr = IMFAttributes_GetString(attributes, &DUMMY_GUID1, bufferW, ARRAY_SIZE(bufferW), NULL); + ok(hr == S_OK, "Failed to get string value, hr %#x.\n", hr); + ok(!lstrcmpW(bufferW, stringW), "Unexpected string %s.\n", wine_dbgstr_w(bufferW)); + memset(bufferW, 0, sizeof(bufferW)); + + hr = IMFAttributes_GetString(attributes, &DUMMY_GUID1, bufferW, 1, NULL); + ok(hr == STRSAFE_E_INSUFFICIENT_BUFFER, "Unexpected hr %#x.\n", hr); + ok(!bufferW[0], "Unexpected string %s.\n", wine_dbgstr_w(bufferW)); + + string_length = 0xdeadbeef; + hr = IMFAttributes_GetStringLength(attributes, &GUID_NULL, &string_length); + ok(hr == MF_E_INVALIDTYPE, "Unexpected hr %#x.\n", hr); + ok(string_length == 0xdeadbeef, "Unexpected length %u.\n", string_length); + IMFAttributes_Release(attributes); }
diff --git a/dlls/mfreadwrite/tests/mfplat.c b/dlls/mfreadwrite/tests/mfplat.c index 1767433e24..609510d427 100644 --- a/dlls/mfreadwrite/tests/mfplat.c +++ b/dlls/mfreadwrite/tests/mfplat.c @@ -64,7 +64,7 @@ static void test_MFCreateSourceReaderFromByteStream(void) ok(hr == S_OK, "got 0x%08x\n", hr);
hr = IMFAttributes_SetString(attributes, &MF_READWRITE_MMCSS_CLASS_AUDIO, audio); - todo_wine ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "Failed to set string value, hr %#x.\n", hr);
hr = IMFAttributes_SetUINT32(attributes, &MF_READWRITE_MMCSS_PRIORITY_AUDIO, 0); ok(hr == S_OK, "Failed to set attribute, hr %#x.\n", hr);
From: Jactry Zeng jzeng@codeweavers.com
Signed-off-by: Jactry Zeng jzeng@codeweavers.com Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/mfplat/main.c | 25 ++++++++++++++++++++----- dlls/mfplat/tests/mfplat.c | 25 +++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 5 deletions(-)
diff --git a/dlls/mfplat/main.c b/dlls/mfplat/main.c index d73076bd83..31bed3340e 100644 --- a/dlls/mfplat/main.c +++ b/dlls/mfplat/main.c @@ -671,7 +671,7 @@ static HRESULT attributes_get_item(struct attributes *attributes, const GUID *ke attribute = attributes_find_item(attributes, key, NULL); if (attribute) { - if (attribute->value.vt == value->vt) + if (attribute->value.vt == value->vt && !(value->vt == VT_UNKNOWN && !attribute->value.u.punkVal)) hr = PropVariantCopy(value, &attribute->value); else hr = MF_E_INVALIDTYPE; @@ -866,9 +866,19 @@ static HRESULT WINAPI mfattributes_GetAllocatedBlob(IMFAttributes *iface, REFGUI
static HRESULT WINAPI mfattributes_GetUnknown(IMFAttributes *iface, REFGUID key, REFIID riid, void **ppv) { - FIXME("%p, %s, %s, %p.\n", iface, debugstr_attr(key), debugstr_guid(riid), ppv); + struct attributes *attributes = impl_from_IMFAttributes(iface); + PROPVARIANT attrval; + HRESULT hr;
- return E_NOTIMPL; + TRACE("%p, %s, %s, %p.\n", iface, debugstr_attr(key), debugstr_guid(riid), ppv); + + PropVariantInit(&attrval); + attrval.vt = VT_UNKNOWN; + hr = attributes_get_item(attributes, key, &attrval); + if (SUCCEEDED(hr)) + hr = IUnknown_QueryInterface(attrval.u.punkVal, riid, ppv); + PropVariantClear(&attrval); + return hr; }
static HRESULT attributes_set_item(struct attributes *attributes, REFGUID key, REFPROPVARIANT value) @@ -1023,9 +1033,14 @@ static HRESULT WINAPI mfattributes_SetBlob(IMFAttributes *iface, REFGUID key, co
static HRESULT WINAPI mfattributes_SetUnknown(IMFAttributes *iface, REFGUID key, IUnknown *unknown) { - FIXME("%p, %s, %p.\n", iface, debugstr_attr(key), unknown); + struct attributes *attributes = impl_from_IMFAttributes(iface); + PROPVARIANT attrval;
- return E_NOTIMPL; + TRACE("%p, %s, %p.\n", iface, debugstr_attr(key), unknown); + + attrval.vt = VT_UNKNOWN; + attrval.u.punkVal = unknown; + return attributes_set_item(attributes, key, &attrval); }
static HRESULT WINAPI mfattributes_LockStore(IMFAttributes *iface) diff --git a/dlls/mfplat/tests/mfplat.c b/dlls/mfplat/tests/mfplat.c index 3fda11d0c7..5579e02953 100644 --- a/dlls/mfplat/tests/mfplat.c +++ b/dlls/mfplat/tests/mfplat.c @@ -511,6 +511,7 @@ static void test_MFCreateAttributes(void) UINT32 value, string_length; IMFAttributes *attributes; double double_value; + IUnknown *unk_value; WCHAR bufferW[256]; UINT64 value64; WCHAR *string; @@ -689,6 +690,30 @@ static void test_MFCreateAttributes(void) ok(hr == MF_E_INVALIDTYPE, "Unexpected hr %#x.\n", hr); ok(string_length == 0xdeadbeef, "Unexpected length %u.\n", string_length);
+ /* VT_UNKNOWN */ + hr = IMFAttributes_SetUnknown(attributes, &DUMMY_GUID2, (IUnknown *)attributes); + ok(hr == S_OK, "Failed to set value, hr %#x.\n", hr); + CHECK_ATTR_COUNT(attributes, 4); + + hr = IMFAttributes_GetUnknown(attributes, &DUMMY_GUID2, &IID_IUnknown, (void **)&unk_value); + ok(hr == S_OK, "Failed to get value, hr %#x.\n", hr); + IUnknown_Release(unk_value); + + hr = IMFAttributes_GetUnknown(attributes, &DUMMY_GUID2, &IID_IMFAttributes, (void **)&unk_value); + ok(hr == S_OK, "Failed to get value, hr %#x.\n", hr); + IUnknown_Release(unk_value); + + hr = IMFAttributes_GetUnknown(attributes, &DUMMY_GUID2, &IID_IStream, (void **)&unk_value); + ok(hr == E_NOINTERFACE, "Unexpected hr %#x.\n", hr); + + hr = IMFAttributes_SetUnknown(attributes, &DUMMY_CLSID, NULL); + ok(hr == S_OK, "Failed to set value, hr %#x.\n", hr); + CHECK_ATTR_COUNT(attributes, 5); + + unk_value = NULL; + hr = IMFAttributes_GetUnknown(attributes, &DUMMY_CLSID, &IID_IUnknown, (void **)&unk_value); + ok(hr == MF_E_INVALIDTYPE, "Unexpected hr %#x.\n", hr); + IMFAttributes_Release(attributes); }
Hi,
While running your changed tests on Windows, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=49326
Your paranoid android.
=== w7pro64 (64 bit report) ===
mfplat: 0ad0:mfplat: unhandled exception c0000005 at 000007FEFA46733F
=== debian9 (32 bit report) ===
mfplat: mfplat.c:2035: Test failed: Unhandled exception: page fault on read access to 0x0000000e in 32-bit code (0x7e76d63a).
Report errors: mfplat:mfplat crashed (c0000005)
=== debian9 (64 bit WoW report) ===
mfplat: mfplat.c:2035: Test failed: Unexpected refcount 1. Unhandled exception: page fault on read access to 0x00000011 in 64-bit code (0x00007fc4e43b6995).
Report errors: mfplat:mfplat crashed (c0000005)
From: Jactry Zeng jzeng@codeweavers.com
Signed-off-by: Jactry Zeng jzeng@codeweavers.com Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/mfplat/main.c | 18 +++++++++++++++--- dlls/mfplat/tests/mfplat.c | 4 ++++ 2 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/dlls/mfplat/main.c b/dlls/mfplat/main.c index 31bed3340e..5a37ebab21 100644 --- a/dlls/mfplat/main.c +++ b/dlls/mfplat/main.c @@ -962,11 +962,23 @@ static HRESULT WINAPI mfattributes_DeleteItem(IMFAttributes *iface, REFGUID key)
static HRESULT WINAPI mfattributes_DeleteAllItems(IMFAttributes *iface) { - mfattributes *This = impl_from_IMFAttributes(iface); + struct attributes *attributes = impl_from_IMFAttributes(iface);
- FIXME("%p\n", This); + TRACE("%p.\n", iface);
- return E_NOTIMPL; + EnterCriticalSection(&attributes->cs); + + while (attributes->count) + { + PropVariantClear(&attributes->attributes[--attributes->count].value); + } + heap_free(attributes->attributes); + attributes->attributes = NULL; + attributes->capacity = 0; + + LeaveCriticalSection(&attributes->cs); + + return S_OK; }
static HRESULT WINAPI mfattributes_SetUINT32(IMFAttributes *iface, REFGUID key, UINT32 value) diff --git a/dlls/mfplat/tests/mfplat.c b/dlls/mfplat/tests/mfplat.c index 5579e02953..a999b9bbe9 100644 --- a/dlls/mfplat/tests/mfplat.c +++ b/dlls/mfplat/tests/mfplat.c @@ -714,6 +714,10 @@ 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); + ok(hr == S_OK, "Failed to delete items, hr %#x.\n", hr); + CHECK_ATTR_COUNT(attributes, 0); + IMFAttributes_Release(attributes); }
Hi,
While running your changed tests on Windows, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=49327
Your paranoid android.
=== debian9 (32 bit report) ===
mfplat: mfplat.c:2039: Test failed: Unexpected refcount 1.
=== debian9 (64 bit WoW report) ===
mfplat: mfplat.c:2039: Test failed: Unexpected refcount 1. Unhandled exception: page fault on read access to 0x00000010 in 64-bit code (0x00007f1f44330a15).
Report errors: mfplat:mfplat crashed (c0000005)