[1/3] dpvoice: Add IDirectPlayVoiceClient Support

Alistair Leslie-Hughes leslie_alistair at hotmail.com
Mon Sep 22 23:41:49 CDT 2014


Hi,

Changelog:
        dpvoice: Add IDirectPlayVoiceClient Support


Best Regards
    Alistair Leslie-Hughes

-------------- next part --------------
>From 3dc2d45332c921689f420276ca21e3568c1eb8f6 Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
Date: Mon, 14 Apr 2014 14:53:58 +1000
Subject: [PATCH] Add IDirectPlayVoiceClient Support
To: wine-patches <wine-patches at winehq.org>

---
 dlls/dpvoice/Makefile.in      |   2 +
 dlls/dpvoice/client.c         | 234 ++++++++++++++++++++++++++++++++++++++++++
 dlls/dpvoice/dvoice_private.h |  25 +++++
 dlls/dpvoice/main.c           |  90 +++++++++++++++-
 4 files changed, 347 insertions(+), 4 deletions(-)
 create mode 100644 dlls/dpvoice/client.c
 create mode 100644 dlls/dpvoice/dvoice_private.h

diff --git a/dlls/dpvoice/Makefile.in b/dlls/dpvoice/Makefile.in
index e22b81f..186a44e 100644
--- a/dlls/dpvoice/Makefile.in
+++ b/dlls/dpvoice/Makefile.in
@@ -1,6 +1,8 @@
 MODULE    = dpvoice.dll
+IMPORTS   = dxguid uuid
 
 C_SRCS = \
+	client.c \
 	main.c
 
 RC_SRCS = version.rc
diff --git a/dlls/dpvoice/client.c b/dlls/dpvoice/client.c
new file mode 100644
index 0000000..813ca9e
--- /dev/null
+++ b/dlls/dpvoice/client.c
@@ -0,0 +1,234 @@
+ /*
+ * DirectPlay Voice Client Interface
+ *
+ * Copyright (C) 2014 Alistair Leslie-Hughes
+ *
+ * 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 "config.h"
+
+#include <stdarg.h>
+
+#define COBJMACROS
+#include "windef.h"
+#include "winbase.h"
+#include "wingdi.h"
+#include "winuser.h"
+#include "objbase.h"
+
+#include "wine/unicode.h"
+#include "wine/debug.h"
+
+#include "dvoice.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(dpvoice);
+
+typedef struct IDirectPlayVoiceClientImpl
+{
+    IDirectPlayVoiceClient IDirectPlayVoiceClient_iface;
+    LONG ref;
+} IDirectPlayVoiceClientImpl;
+
+static inline IDirectPlayVoiceClientImpl *impl_from_IDirectPlayVoiceClient(IDirectPlayVoiceClient *iface)
+{
+    return CONTAINING_RECORD(iface, IDirectPlayVoiceClientImpl, IDirectPlayVoiceClient_iface);
+}
+
+static HRESULT WINAPI dpvclient_QueryInterface(IDirectPlayVoiceClient *iface, REFIID riid, void **ppv)
+{
+    if (IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_IDirectPlayVoiceClient))
+    {
+        IUnknown_AddRef(iface);
+        *ppv = iface;
+        return S_OK;
+    }
+
+    WARN("(%p)->(%s,%p),not found\n", iface, debugstr_guid(riid), ppv);
+    return E_NOINTERFACE;
+}
+
+static ULONG WINAPI dpvclient_AddRef(IDirectPlayVoiceClient *iface)
+{
+    IDirectPlayVoiceClientImpl *This = impl_from_IDirectPlayVoiceClient(iface);
+    ULONG ref = InterlockedIncrement(&This->ref);
+
+    TRACE("(%p) ref=%u\n", This, ref);
+
+    return ref;
+}
+
+static ULONG WINAPI dpvclient_Release(IDirectPlayVoiceClient *iface)
+{
+    IDirectPlayVoiceClientImpl *This = impl_from_IDirectPlayVoiceClient(iface);
+    ULONG ref = InterlockedIncrement(&This->ref);
+
+    TRACE("(%p) ref=%u\n", This, ref);
+
+    if (!ref)
+    {
+        HeapFree(GetProcessHeap(), 0, This);
+    }
+    return ref;
+}
+
+static HRESULT WINAPI dpvclient_Initialize(IDirectPlayVoiceClient *iface,LPUNKNOWN pVoid, PDVMESSAGEHANDLER pMessageHandler,
+                                void *pUserContext, DWORD *pdwMessageMask, DWORD dwMessageMaskElements)
+{
+    IDirectPlayVoiceClientImpl *This = impl_from_IDirectPlayVoiceClient(iface);
+    FIXME("%p %p %p %p %p %d\n", This, pVoid, pMessageHandler, pUserContext,pdwMessageMask, dwMessageMaskElements);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI dpvclient_Connect(IDirectPlayVoiceClient *iface, PDVSOUNDDEVICECONFIG pSoundDeviceConfig,
+                                PDVCLIENTCONFIG pdvClientConfig, DWORD dwFlags)
+{
+    IDirectPlayVoiceClientImpl *This = impl_from_IDirectPlayVoiceClient(iface);
+    FIXME("%p %p %p %d\n", This, pSoundDeviceConfig, pdvClientConfig, dwFlags);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI dpvclient_Disconnect(IDirectPlayVoiceClient *iface, DWORD dwFlags)
+{
+    IDirectPlayVoiceClientImpl *This = impl_from_IDirectPlayVoiceClient(iface);
+    FIXME("%p %d\n", This, dwFlags);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI dpvclient_GetSessionDesc(IDirectPlayVoiceClient *iface, PDVSESSIONDESC pvSessionDesc)
+{
+    IDirectPlayVoiceClientImpl *This = impl_from_IDirectPlayVoiceClient(iface);
+    FIXME("%p %p\n", This, pvSessionDesc);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI dpvclient_GetClientConfig(IDirectPlayVoiceClient *iface, PDVCLIENTCONFIG pClientConfig)
+{
+    IDirectPlayVoiceClientImpl *This = impl_from_IDirectPlayVoiceClient(iface);
+    FIXME("%p %p\n", This, pClientConfig);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI dpvclient_SetClientConfig(IDirectPlayVoiceClient *iface, PDVCLIENTCONFIG pClientConfig)
+{
+    IDirectPlayVoiceClientImpl *This = impl_from_IDirectPlayVoiceClient(iface);
+    FIXME("%p %p\n", This, pClientConfig);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI dpvclient_GetCaps(IDirectPlayVoiceClient *iface, PDVCAPS pCaps)
+{
+    IDirectPlayVoiceClientImpl *This = impl_from_IDirectPlayVoiceClient(iface);
+    FIXME("%p %p\n", This, pCaps);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI dpvclient_GetCompressionTypes(IDirectPlayVoiceClient *iface, void *pData,
+                                DWORD *pdwDataSize, DWORD *pdwNumElements, DWORD dwFlags)
+{
+    IDirectPlayVoiceClientImpl *This = impl_from_IDirectPlayVoiceClient(iface);
+    FIXME("%p %p %p %p %d\n", This, pData, pdwDataSize, pdwNumElements, dwFlags);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI dpvclient_SetTransmitTargets(IDirectPlayVoiceClient *iface, PDVID pdvIDTargets,
+                                DWORD dwNumTargets, DWORD dwFlags)
+{
+    IDirectPlayVoiceClientImpl *This = impl_from_IDirectPlayVoiceClient(iface);
+    FIXME("%p %p %d %d\n", This, pdvIDTargets, dwNumTargets, dwFlags);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI dpvclient_GetTransmitTargets(IDirectPlayVoiceClient *iface, PDVID pdvIDTargets,
+                                DWORD *pdwNumTargets, DWORD dwFlags)
+{
+    IDirectPlayVoiceClientImpl *This = impl_from_IDirectPlayVoiceClient(iface);
+    FIXME("%p %p %d\n", This, pdwNumTargets, dwFlags);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI dpvclient_Create3DSoundBuffer(IDirectPlayVoiceClient *iface, DVID dvID,
+                                LPDIRECTSOUNDBUFFER lpdsSourceBuffer, DWORD dwPriority, DWORD dwFlags,
+                                LPDIRECTSOUND3DBUFFER *lpUserBuffer)
+{
+    IDirectPlayVoiceClientImpl *This = impl_from_IDirectPlayVoiceClient(iface);
+    FIXME("%p %d %p %d %d %p\n", This, dvID, lpdsSourceBuffer, dwPriority, dwFlags, lpUserBuffer);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI dpvclient_Delete3DSoundBuffer(IDirectPlayVoiceClient *iface, DVID dvID, LPDIRECTSOUND3DBUFFER *lpUserBuffer)
+{
+    IDirectPlayVoiceClientImpl *This = impl_from_IDirectPlayVoiceClient(iface);
+    FIXME("%p %d %p\n", This, dvID, lpUserBuffer);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI dpvclient_SetNotifyMask(IDirectPlayVoiceClient *iface, DWORD *pdwMessageMask, DWORD dwMessageMaskElements)
+{
+    IDirectPlayVoiceClientImpl *This = impl_from_IDirectPlayVoiceClient(iface);
+    FIXME("%p %p %d\n", This, pdwMessageMask, dwMessageMaskElements);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI dpvclient_GetSoundDeviceConfig(IDirectPlayVoiceClient *iface, PDVSOUNDDEVICECONFIG pSoundDeviceConfig,
+                                DWORD *pdwSize)
+{
+    IDirectPlayVoiceClientImpl *This = impl_from_IDirectPlayVoiceClient(iface);
+    FIXME("%p %p %p\n", This, pSoundDeviceConfig, pdwSize);
+    return E_NOTIMPL;
+}
+
+
+static const IDirectPlayVoiceClientVtbl DirectPlayVoiceClient_Vtbl =
+{
+    dpvclient_QueryInterface,
+    dpvclient_AddRef,
+    dpvclient_Release,
+    dpvclient_Initialize,
+    dpvclient_Connect,
+    dpvclient_Disconnect,
+    dpvclient_GetSessionDesc,
+    dpvclient_GetClientConfig,
+    dpvclient_SetClientConfig,
+    dpvclient_GetCaps,
+    dpvclient_GetCompressionTypes,
+    dpvclient_SetTransmitTargets,
+    dpvclient_GetTransmitTargets,
+    dpvclient_Create3DSoundBuffer,
+    dpvclient_Delete3DSoundBuffer,
+    dpvclient_SetNotifyMask,
+    dpvclient_GetSoundDeviceConfig
+};
+
+HRESULT DPVOICE_CreateDirectPlayVoiceClient(IClassFactory *iface, IUnknown *pUnkOuter, REFIID riid, void **ppobj)
+{
+    IDirectPlayVoiceClientImpl* client;
+    HRESULT ret;
+
+    TRACE("(%p, %s, %p)\n", pUnkOuter, debugstr_guid(riid), ppobj);
+
+    *ppobj = NULL;
+
+    client = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectPlayVoiceClientImpl));
+    if (!client)
+        return E_OUTOFMEMORY;
+
+    client->IDirectPlayVoiceClient_iface.lpVtbl = &DirectPlayVoiceClient_Vtbl;
+    client->ref = 1;
+
+    ret = IDirectPlayVoiceClient_QueryInterface(&client->IDirectPlayVoiceClient_iface, riid, ppobj);
+    IDirectPlayVoiceClient_Release(&client->IDirectPlayVoiceClient_iface);
+
+    return ret;
+}
\ No newline at end of file
diff --git a/dlls/dpvoice/dvoice_private.h b/dlls/dpvoice/dvoice_private.h
new file mode 100644
index 0000000..a008924
--- /dev/null
+++ b/dlls/dpvoice/dvoice_private.h
@@ -0,0 +1,25 @@
+/*
+ * DirectPlay Voice
+ *
+ * Copyright (C) 2014 Alistair Leslie-Hughes
+ *
+ * This program 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 program 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 program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+#ifndef __DVOICE_PRIVATE_H__
+#define __DVOICE_PRIVATE_H__
+
+extern HRESULT DPVOICE_CreateDirectPlayVoiceClient(IClassFactory *iface, IUnknown *pUnkOuter, REFIID riid, void **ppobj) DECLSPEC_HIDDEN;
+
+#endif
diff --git a/dlls/dpvoice/main.c b/dlls/dpvoice/main.c
index 00b70d9..84f739c 100644
--- a/dlls/dpvoice/main.c
+++ b/dlls/dpvoice/main.c
@@ -27,11 +27,78 @@
 #include "rpcproxy.h"
 #include "wine/debug.h"
 
+#include "initguid.h"
+#include "dvoice.h"
+#include "dvoice_private.h"
+
 WINE_DEFAULT_DEBUG_CHANNEL(dpvoice);
 
 static HINSTANCE DPVOICE_hInstance;
 
-HRESULT WINAPI DirectPlayVoiceCreate(LPCGUID pIID, PVOID *ppvInterface)
+typedef struct
+{
+    IClassFactory IClassFactory_iface;
+    LONG          ref;
+    REFCLSID      rclsid;
+    HRESULT       (*pfnCreateInstanceFactory)(IClassFactory *iface, IUnknown *punkOuter, REFIID riid, void **ppobj);
+} IClassFactoryImpl;
+
+static inline IClassFactoryImpl *impl_from_IClassFactory(IClassFactory *iface)
+{
+  return CONTAINING_RECORD(iface, IClassFactoryImpl, IClassFactory_iface);
+}
+
+static HRESULT WINAPI DICF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,void **ppobj)
+{
+    IClassFactoryImpl *This = impl_from_IClassFactory(iface);
+
+    FIXME("(%p)->(%s,%p),stub!\n",This,debugstr_guid(riid),ppobj);
+    return E_NOINTERFACE;
+}
+
+static ULONG WINAPI DICF_AddRef(LPCLASSFACTORY iface)
+{
+    IClassFactoryImpl *This = impl_from_IClassFactory(iface);
+    return InterlockedIncrement(&This->ref);
+}
+
+static ULONG WINAPI DICF_Release(LPCLASSFACTORY iface)
+{
+    IClassFactoryImpl *This = impl_from_IClassFactory(iface);
+    /* static class, won't be  freed */
+    return InterlockedDecrement(&This->ref);
+}
+
+static HRESULT WINAPI DICF_CreateInstance(IClassFactory *iface, IUnknown *pOuter, REFIID riid, void **ppobj)
+{
+    IClassFactoryImpl *This = impl_from_IClassFactory(iface);
+
+    TRACE("(%p)->(%p,%s,%p)\n",This,pOuter,debugstr_guid(riid),ppobj);
+    return This->pfnCreateInstanceFactory(iface, pOuter, riid, ppobj);
+}
+
+static HRESULT WINAPI DICF_LockServer(IClassFactory *iface,BOOL dolock)
+{
+    IClassFactoryImpl *This = impl_from_IClassFactory(iface);
+    FIXME("(%p)->(%d),stub!\n",This,dolock);
+    return S_OK;
+}
+
+static const IClassFactoryVtbl DICF_Vtbl = {
+    DICF_QueryInterface,
+    DICF_AddRef,
+    DICF_Release,
+    DICF_CreateInstance,
+    DICF_LockServer
+};
+
+static IClassFactoryImpl DPVOICE_CFS[] =
+{
+    { { &DICF_Vtbl }, 1, &CLSID_DirectPlayVoiceClient,  DPVOICE_CreateDirectPlayVoiceClient },
+    { { NULL }, 0, NULL, NULL }
+};
+
+HRESULT WINAPI DirectPlayVoiceCreate(LPCGUID pIID, void **ppvInterface)
 {
     FIXME("(%p, %p) stub\n", pIID, ppvInterface);
     return E_NOTIMPL;
@@ -57,10 +124,25 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
     return TRUE;
 }
 
-HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
+HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, void **ppv)
 {
-    FIXME(":stub\n");
-    return E_FAIL;
+    int i = 0;
+
+    TRACE("(%s,%s,%p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
+
+    while (NULL != DPVOICE_CFS[i].rclsid)
+    {
+        if (IsEqualGUID(rclsid, DPVOICE_CFS[i].rclsid))
+        {
+            DICF_AddRef(&DPVOICE_CFS[i].IClassFactory_iface);
+            *ppv = &DPVOICE_CFS[i];
+            return S_OK;
+        }
+        ++i;
+    }
+
+    FIXME("(%s,%s,%p): no interface found.\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
+    return CLASS_E_CLASSNOTAVAILABLE;
 }
 
 HRESULT WINAPI DllCanUnloadNow(void)
-- 
1.9.1




More information about the wine-patches mailing list