[PATCH 2/3] wmadmod: Introduce new DLL and tests.

Rémi Bernon rbernon at codeweavers.com
Fri Jan 28 02:59:25 CST 2022


Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=51931
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52391
Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
---
 configure.ac                   |   2 +
 dlls/wmadmod/Makefile.in       |   4 +
 dlls/wmadmod/main.c            |  35 +++++++
 dlls/wmadmod/tests/Makefile.in |   5 +
 dlls/wmadmod/tests/wmadmod.c   | 183 +++++++++++++++++++++++++++++++++
 dlls/wmadmod/wmadmod.spec      |   5 +
 6 files changed, 234 insertions(+)
 create mode 100644 dlls/wmadmod/Makefile.in
 create mode 100644 dlls/wmadmod/main.c
 create mode 100644 dlls/wmadmod/tests/Makefile.in
 create mode 100644 dlls/wmadmod/tests/wmadmod.c
 create mode 100644 dlls/wmadmod/wmadmod.spec

diff --git a/configure.ac b/configure.ac
index eb481554960..30cecd790cb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3422,6 +3422,8 @@ WINE_CONFIG_MAKEFILE(dlls/wlanapi/tests)
 WINE_CONFIG_MAKEFILE(dlls/wlanui)
 WINE_CONFIG_MAKEFILE(dlls/wldap32)
 WINE_CONFIG_MAKEFILE(dlls/wldap32/tests)
+WINE_CONFIG_MAKEFILE(dlls/wmadmod)
+WINE_CONFIG_MAKEFILE(dlls/wmadmod/tests)
 WINE_CONFIG_MAKEFILE(dlls/wmasf)
 WINE_CONFIG_MAKEFILE(dlls/wmi)
 WINE_CONFIG_MAKEFILE(dlls/wmiutils)
diff --git a/dlls/wmadmod/Makefile.in b/dlls/wmadmod/Makefile.in
new file mode 100644
index 00000000000..49fe2f92e08
--- /dev/null
+++ b/dlls/wmadmod/Makefile.in
@@ -0,0 +1,4 @@
+MODULE    = wmadmod.dll
+
+C_SRCS = \
+	main.c
diff --git a/dlls/wmadmod/main.c b/dlls/wmadmod/main.c
new file mode 100644
index 00000000000..2a13143eeae
--- /dev/null
+++ b/dlls/wmadmod/main.c
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2022 Rémi Bernon for CodeWeavers
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#include <stdarg.h>
+
+#include "windef.h"
+#include "winbase.h"
+
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(wmadmod);
+
+/*************************************************************************
+ *              DllGetClassObject (WMADMOD.@)
+ */
+HRESULT WINAPI DllGetClassObject( REFCLSID clsid, REFIID iid, void **obj )
+{
+    FIXME( "class %s not available\n", debugstr_guid( clsid ) );
+    return CLASS_E_CLASSNOTAVAILABLE;
+}
diff --git a/dlls/wmadmod/tests/Makefile.in b/dlls/wmadmod/tests/Makefile.in
new file mode 100644
index 00000000000..254d9322b2b
--- /dev/null
+++ b/dlls/wmadmod/tests/Makefile.in
@@ -0,0 +1,5 @@
+TESTDLL = wmadmod.dll
+IMPORTS = dmoguids msdmo ole32 strmiids uuid mfuuid wmcodecdspuuid
+
+C_SRCS = \
+	wmadmod.c
diff --git a/dlls/wmadmod/tests/wmadmod.c b/dlls/wmadmod/tests/wmadmod.c
new file mode 100644
index 00000000000..820f38ebbbd
--- /dev/null
+++ b/dlls/wmadmod/tests/wmadmod.c
@@ -0,0 +1,183 @@
+/*
+ * Copyright 2022 Rémi Bernon for CodeWeavers
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#include <stdarg.h>
+
+#include "windef.h"
+#include "winbase.h"
+
+#define COBJMACROS
+#include "dmo.h"
+#include "uuids.h"
+#include "control.h"
+#include "wmcodecdsp.h"
+#include "mftransform.h"
+
+#include "wine/test.h"
+
+static void test_DMOGetTypes(void)
+{
+    DMO_PARTIAL_MEDIATYPE expect_output[2] =
+    {
+        {.type = MEDIATYPE_Audio, .subtype = MEDIASUBTYPE_PCM},
+        {.type = MEDIATYPE_Audio, .subtype = MEDIASUBTYPE_IEEE_FLOAT},
+    };
+    DMO_PARTIAL_MEDIATYPE expect_input[4] =
+    {
+        {.type = MEDIATYPE_Audio, .subtype = MEDIASUBTYPE_MSAUDIO1},
+        {.type = MEDIATYPE_Audio, .subtype = MEDIASUBTYPE_WMAUDIO2},
+        {.type = MEDIATYPE_Audio, .subtype = MEDIASUBTYPE_WMAUDIO3},
+        {.type = MEDIATYPE_Audio, .subtype = MEDIASUBTYPE_WMAUDIO_LOSSLESS},
+    };
+
+    ULONG i, input_count = 0, output_count = 0;
+    DMO_PARTIAL_MEDIATYPE output[16] = {0};
+    DMO_PARTIAL_MEDIATYPE input[16] = {0};
+    HRESULT hr;
+
+    hr = DMOGetTypes( &CLSID_CWMADecMediaObject, ARRAY_SIZE(input), &input_count, input,
+                      ARRAY_SIZE(output), &output_count, output );
+    todo_wine
+    ok( hr == S_OK, "DMOGetTypes returned %#x\n", hr );
+    todo_wine
+    ok( input_count == ARRAY_SIZE(expect_input), "got input_count %u\n", input_count );
+    todo_wine
+    ok( output_count == ARRAY_SIZE(expect_output), "got output_count %u\n", output_count );
+
+    for (i = 0; i < input_count; ++i)
+    {
+        winetest_push_context( "in %u", i );
+        ok( IsEqualGUID( &input[i].type, &expect_input[i].type ),
+            "got type %s\n", debugstr_guid( &input[i].type ) );
+        ok( IsEqualGUID( &input[i].subtype, &expect_input[i].subtype ),
+            "got subtype %s\n", debugstr_guid( &input[i].subtype ) );
+        winetest_pop_context();
+    }
+
+    for (i = 0; i < output_count; ++i)
+    {
+        winetest_push_context( "out %u", i );
+        ok( IsEqualGUID( &output[i].type, &expect_output[i].type ),
+            "got type %s\n", debugstr_guid( &output[i].type ) );
+        ok( IsEqualGUID( &output[i].subtype, &expect_output[i].subtype ),
+            "got subtype %s\n", debugstr_guid( &output[i].subtype ) );
+        winetest_pop_context();
+    }
+}
+
+static HRESULT WINAPI outer_QueryInterface( IUnknown *iface, REFIID iid, void **obj )
+{
+    if (IsEqualGUID( iid, &IID_IUnknown ))
+    {
+        *obj = (IUnknown *)iface;
+        return S_OK;
+    }
+
+    ok( 0, "unexpected call %s\n", debugstr_guid( iid ) );
+    return E_NOINTERFACE;
+}
+
+static ULONG WINAPI outer_AddRef( IUnknown *iface )
+{
+    return 2;
+}
+
+static ULONG WINAPI outer_Release( IUnknown *iface )
+{
+    return 1;
+}
+
+static IUnknownVtbl outer_vtbl =
+{
+    outer_QueryInterface,
+    outer_AddRef,
+    outer_Release,
+};
+
+static IUnknown outer = {&outer_vtbl};
+
+#define check_interface(a, b, c) check_interface_(__LINE__, a, b, c)
+static void check_interface_(unsigned int line, void *iface, REFIID iid, BOOL supported)
+{
+    HRESULT hr, expected_hr;
+    IUnknown *tmp;
+
+    expected_hr = supported ? S_OK : E_NOINTERFACE;
+
+    hr = IUnknown_QueryInterface( (IUnknown *)iface, iid, (void **)&tmp );
+    ok_(__FILE__, line)(hr == expected_hr, "Got hr %#x, expected %#x.\n", hr, expected_hr);
+    if (SUCCEEDED(hr)) IUnknown_Release( tmp );
+}
+
+static void test_interfaces(void)
+{
+    IUnknown *unknown, *tmp_unknown;
+    IMediaObject *media_object;
+    IPropertyBag *property_bag;
+    IMFTransform *transform;
+    HRESULT hr;
+    ULONG ref;
+
+    hr = CoCreateInstance( &CLSID_CWMADecMediaObject, &outer, CLSCTX_INPROC_SERVER, &IID_IUnknown,
+                           (void **)&unknown );
+    todo_wine
+    ok( hr == S_OK, "CoCreateInstance returned %#x\n", hr );
+    if (FAILED(hr)) return;
+    hr = IUnknown_QueryInterface( unknown, &IID_IMFTransform, (void **)&transform );
+    ok( hr == S_OK, "QueryInterface returned %#x\n", hr );
+    hr = IUnknown_QueryInterface( unknown, &IID_IMediaObject, (void **)&media_object );
+    ok( hr == S_OK, "QueryInterface returned %#x\n", hr );
+    hr = IUnknown_QueryInterface( unknown, &IID_IPropertyBag, (void **)&property_bag );
+    ok( hr == S_OK, "QueryInterface returned %#x\n", hr );
+    hr = IUnknown_QueryInterface( media_object, &IID_IUnknown, (void **)&tmp_unknown );
+    ok( hr == S_OK, "QueryInterface returned %#x\n", hr );
+
+    ok( unknown != &outer, "got outer IUnknown\n" );
+    ok( transform != (void *)unknown, "got IUnknown == IMFTransform\n" );
+    ok( media_object != (void *)unknown, "got IUnknown == IMediaObject\n" );
+    ok( property_bag != (void *)unknown, "got IUnknown == IPropertyBag\n" );
+    ok( tmp_unknown != unknown, "got inner IUnknown\n" );
+
+    check_interface( unknown, &IID_IPersistPropertyBag, FALSE );
+    check_interface( unknown, &IID_IAMFilterMiscFlags, FALSE );
+    check_interface( unknown, &IID_IMediaSeeking, FALSE );
+    check_interface( unknown, &IID_IMediaPosition, FALSE );
+    check_interface( unknown, &IID_IReferenceClock, FALSE );
+    check_interface( unknown, &IID_IBasicAudio, FALSE );
+
+    ref = IUnknown_Release( tmp_unknown );
+    ok( ref == 1, "Release returned %u\n", ref );
+    ref = IPropertyBag_Release( property_bag );
+    ok( ref == 1, "Release returned %u\n", ref );
+    ref = IMediaObject_Release( media_object );
+    ok( ref == 1, "Release returned %u\n", ref );
+    ref = IMFTransform_Release( transform );
+    ok( ref == 1, "Release returned %u\n", ref );
+    ref = IUnknown_Release( unknown );
+    ok( ref == 0, "Release returned %u\n", ref );
+}
+
+START_TEST( wmadmod )
+{
+    CoInitialize( NULL );
+
+    test_DMOGetTypes();
+    test_interfaces();
+
+    CoUninitialize();
+}
diff --git a/dlls/wmadmod/wmadmod.spec b/dlls/wmadmod/wmadmod.spec
new file mode 100644
index 00000000000..25104058c7d
--- /dev/null
+++ b/dlls/wmadmod/wmadmod.spec
@@ -0,0 +1,5 @@
+@ stub CreateInstance
+@ stdcall -private DllCanUnloadNow()
+@ stdcall -private DllGetClassObject(ptr ptr ptr)
+@ stdcall -private DllRegisterServer()
+@ stdcall -private DllUnregisterServer()
-- 
2.34.1




More information about the wine-devel mailing list