2004-01-20 01:21:40 +01:00
|
|
|
/* DirectMusic Wave Main
|
|
|
|
*
|
|
|
|
* Copyright (C) 2003-2004 Rok Mandeljc
|
|
|
|
*
|
2007-05-30 12:54:07 +02:00
|
|
|
* 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.
|
2004-01-20 01:21:40 +01:00
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2007-05-30 12:54:07 +02:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
2004-01-20 01:21:40 +01:00
|
|
|
*
|
2007-05-30 12:54:07 +02:00
|
|
|
* 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
|
2004-01-20 01:21:40 +01:00
|
|
|
*/
|
|
|
|
|
2008-02-29 12:24:58 +01:00
|
|
|
|
2004-02-25 02:30:03 +01:00
|
|
|
#include <stdio.h>
|
2014-04-24 12:18:01 +02:00
|
|
|
#include <stdarg.h>
|
2004-02-25 02:30:03 +01:00
|
|
|
|
2014-04-24 12:18:01 +02:00
|
|
|
#define COBJMACROS
|
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winnt.h"
|
|
|
|
#include "wingdi.h"
|
|
|
|
#include "winuser.h"
|
|
|
|
#include "winreg.h"
|
|
|
|
#include "objbase.h"
|
2010-12-03 14:06:16 +01:00
|
|
|
#include "rpcproxy.h"
|
2014-04-24 12:18:01 +02:00
|
|
|
#include "initguid.h"
|
|
|
|
#include "dmusici.h"
|
|
|
|
|
|
|
|
#include "dswave_private.h"
|
2019-12-13 00:29:07 +01:00
|
|
|
#include "dmobject.h"
|
2004-01-20 01:21:40 +01:00
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(dswave);
|
|
|
|
|
2010-12-03 14:06:16 +01:00
|
|
|
static HINSTANCE instance;
|
2005-02-01 15:21:37 +01:00
|
|
|
LONG DSWAVE_refCount = 0;
|
|
|
|
|
2004-01-20 01:21:40 +01:00
|
|
|
typedef struct {
|
2011-07-28 10:18:37 +02:00
|
|
|
IClassFactory IClassFactory_iface;
|
2004-01-20 01:21:40 +01:00
|
|
|
} IClassFactoryImpl;
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* DirectMusicWave ClassFactory
|
|
|
|
*/
|
2011-07-28 10:23:01 +02:00
|
|
|
static HRESULT WINAPI WaveCF_QueryInterface(IClassFactory * iface, REFIID riid, void **ppv)
|
2011-07-28 10:18:37 +02:00
|
|
|
{
|
2011-07-28 10:23:01 +02:00
|
|
|
if (ppv == NULL)
|
|
|
|
return E_POINTER;
|
2005-02-01 15:21:37 +01:00
|
|
|
|
2011-07-28 10:23:01 +02:00
|
|
|
if (IsEqualGUID(&IID_IUnknown, riid))
|
|
|
|
TRACE("(%p)->(IID_IUnknown %p)\n", iface, ppv);
|
|
|
|
else if (IsEqualGUID(&IID_IClassFactory, riid))
|
|
|
|
TRACE("(%p)->(IID_IClassFactory %p)\n", iface, ppv);
|
|
|
|
else {
|
|
|
|
FIXME("(%p)->(%s %p)\n", iface, debugstr_guid(riid), ppv);
|
|
|
|
*ppv = NULL;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
*ppv = iface;
|
|
|
|
IUnknown_AddRef((IUnknown*)*ppv);
|
|
|
|
return S_OK;
|
2004-01-20 01:21:40 +01:00
|
|
|
}
|
|
|
|
|
2011-07-28 10:18:37 +02:00
|
|
|
static ULONG WINAPI WaveCF_AddRef(IClassFactory * iface)
|
|
|
|
{
|
2005-02-01 15:21:37 +01:00
|
|
|
DSWAVE_LockModule();
|
|
|
|
|
|
|
|
return 2; /* non-heap based object */
|
2004-01-20 01:21:40 +01:00
|
|
|
}
|
|
|
|
|
2011-07-28 10:18:37 +02:00
|
|
|
static ULONG WINAPI WaveCF_Release(IClassFactory * iface)
|
|
|
|
{
|
2005-02-01 15:21:37 +01:00
|
|
|
DSWAVE_UnlockModule();
|
|
|
|
|
|
|
|
return 1; /* non-heap based object */
|
2004-01-20 01:21:40 +01:00
|
|
|
}
|
|
|
|
|
2014-03-13 23:45:16 +01:00
|
|
|
static HRESULT WINAPI WaveCF_CreateInstance(IClassFactory * iface, IUnknown *outer_unk, REFIID riid,
|
|
|
|
void **ret_iface)
|
2011-07-28 10:18:37 +02:00
|
|
|
{
|
2014-03-13 23:45:16 +01:00
|
|
|
TRACE ("(%p, %s, %p)\n", outer_unk, debugstr_dmguid(riid), ret_iface);
|
2011-07-28 10:18:37 +02:00
|
|
|
|
2014-03-13 23:45:16 +01:00
|
|
|
if (outer_unk) {
|
|
|
|
*ret_iface = NULL;
|
|
|
|
return CLASS_E_NOAGGREGATION;
|
|
|
|
}
|
|
|
|
|
|
|
|
return create_dswave(riid, ret_iface);
|
2004-01-20 01:21:40 +01:00
|
|
|
}
|
|
|
|
|
2011-07-28 10:18:37 +02:00
|
|
|
static HRESULT WINAPI WaveCF_LockServer(IClassFactory * iface, BOOL dolock)
|
|
|
|
{
|
2005-02-01 15:21:37 +01:00
|
|
|
TRACE("(%d)\n", dolock);
|
|
|
|
|
|
|
|
if (dolock)
|
|
|
|
DSWAVE_LockModule();
|
|
|
|
else
|
|
|
|
DSWAVE_UnlockModule();
|
|
|
|
|
2004-01-20 01:21:40 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2006-12-14 15:47:14 +01:00
|
|
|
static const IClassFactoryVtbl WaveCF_Vtbl = {
|
2004-01-20 01:21:40 +01:00
|
|
|
WaveCF_QueryInterface,
|
|
|
|
WaveCF_AddRef,
|
|
|
|
WaveCF_Release,
|
|
|
|
WaveCF_CreateInstance,
|
|
|
|
WaveCF_LockServer
|
|
|
|
};
|
|
|
|
|
2011-07-28 10:18:37 +02:00
|
|
|
static IClassFactoryImpl Wave_CF = {{&WaveCF_Vtbl}};
|
2004-01-20 01:21:40 +01:00
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* DllMain
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
|
|
|
|
if (fdwReason == DLL_PROCESS_ATTACH) {
|
2010-12-03 14:06:16 +01:00
|
|
|
instance = hinstDLL;
|
2004-01-20 01:21:40 +01:00
|
|
|
DisableThreadLibraryCalls(hinstDLL);
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************
|
2005-08-10 16:45:58 +02:00
|
|
|
* DllCanUnloadNow (DSWAVE.@)
|
2004-01-20 01:21:40 +01:00
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
2005-08-08 19:35:28 +02:00
|
|
|
HRESULT WINAPI DllCanUnloadNow(void)
|
|
|
|
{
|
2005-02-01 15:21:37 +01:00
|
|
|
return DSWAVE_refCount != 0 ? S_FALSE : S_OK;
|
2004-01-20 01:21:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************
|
2005-08-10 11:53:47 +02:00
|
|
|
* DllGetClassObject (DSWAVE.@)
|
2004-01-20 01:21:40 +01:00
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
2005-08-08 19:35:28 +02:00
|
|
|
HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
|
|
|
|
{
|
2004-02-25 02:30:03 +01:00
|
|
|
TRACE("(%s, %s, %p)\n", debugstr_dmguid(rclsid), debugstr_dmguid(riid), ppv);
|
2004-01-20 01:21:40 +01:00
|
|
|
if (IsEqualCLSID (rclsid, &CLSID_DirectSoundWave) && IsEqualIID (riid, &IID_IClassFactory)) {
|
2009-01-14 09:52:15 +01:00
|
|
|
*ppv = &Wave_CF;
|
2004-01-20 01:21:40 +01:00
|
|
|
IClassFactory_AddRef((IClassFactory*)*ppv);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2004-02-25 02:30:03 +01:00
|
|
|
WARN("(%s, %s, %p): no interface found.\n", debugstr_dmguid(rclsid), debugstr_dmguid(riid), ppv);
|
2004-01-20 01:21:40 +01:00
|
|
|
return CLASS_E_CLASSNOTAVAILABLE;
|
|
|
|
}
|
2004-02-25 02:30:03 +01:00
|
|
|
|
2010-12-03 14:06:16 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* DllRegisterServer (DSWAVE.@)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI DllRegisterServer(void)
|
|
|
|
{
|
2011-08-02 15:51:55 +02:00
|
|
|
return __wine_register_resources( instance );
|
2010-12-03 14:06:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* DllUnregisterServer (DSWAVE.@)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI DllUnregisterServer(void)
|
|
|
|
{
|
2011-08-02 15:51:55 +02:00
|
|
|
return __wine_unregister_resources( instance );
|
2010-12-03 14:06:16 +01:00
|
|
|
}
|