2009-10-31 14:53:06 +00:00
|
|
|
/*
|
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
* PROJECT: ReactOS Configuration of network devices
|
|
|
|
* FILE: dll/directx/dsound_new/dsound.c
|
|
|
|
* PURPOSE: Handles DSound initialization
|
|
|
|
*
|
2013-09-15 13:06:05 +00:00
|
|
|
* PROGRAMMERS: Johannes Anderwald (johannes.anderwald@reactos.org)
|
2009-10-31 14:53:06 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "precomp.h"
|
|
|
|
|
|
|
|
HINSTANCE dsound_hInstance;
|
|
|
|
LPFILTERINFO RootInfo = NULL;
|
|
|
|
|
|
|
|
static INTERFACE_TABLE InterfaceTable[] =
|
|
|
|
{
|
|
|
|
{
|
|
|
|
&CLSID_DirectSoundPrivate,
|
|
|
|
NewKsPropertySet
|
|
|
|
},
|
2009-11-03 11:43:33 +00:00
|
|
|
{
|
|
|
|
&CLSID_DirectSoundCapture,
|
|
|
|
NewDirectSoundCapture
|
|
|
|
},
|
2009-11-03 19:20:59 +00:00
|
|
|
{
|
|
|
|
&CLSID_DirectSoundCapture8,
|
|
|
|
NewDirectSoundCapture
|
|
|
|
},
|
2009-11-03 18:54:52 +00:00
|
|
|
{
|
|
|
|
&CLSID_DirectSound,
|
|
|
|
NewDirectSound
|
|
|
|
},
|
2009-11-03 19:20:59 +00:00
|
|
|
{
|
|
|
|
&CLSID_DirectSound8,
|
|
|
|
NewDirectSound
|
|
|
|
},
|
2009-10-31 14:53:06 +00:00
|
|
|
{
|
|
|
|
NULL,
|
|
|
|
NULL
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
HRESULT
|
|
|
|
WINAPI
|
|
|
|
DllCanUnloadNow()
|
|
|
|
{
|
|
|
|
return S_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT
|
|
|
|
WINAPI
|
|
|
|
GetDeviceID(LPCGUID pGuidSrc, LPGUID pGuidDest)
|
|
|
|
{
|
|
|
|
ULONG DeviceID = ULONG_MAX, Flags;
|
|
|
|
MMRESULT Result;
|
|
|
|
LPFILTERINFO Filter;
|
|
|
|
|
|
|
|
if (!pGuidSrc || !pGuidDest)
|
|
|
|
{
|
|
|
|
/* invalid param */
|
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* sanity check */
|
|
|
|
ASSERT(!IsEqualGUID(pGuidSrc, &GUID_NULL));
|
|
|
|
|
|
|
|
if (IsEqualGUID(&DSDEVID_DefaultPlayback, pGuidSrc) ||
|
|
|
|
IsEqualGUID(&DSDEVID_DefaultVoicePlayback, pGuidSrc))
|
|
|
|
{
|
|
|
|
Result = waveOutMessage(UlongToHandle(WAVE_MAPPER), DRVM_MAPPER_PREFERRED_GET, (DWORD_PTR)&DeviceID, (DWORD_PTR)&Flags);
|
|
|
|
if (Result != MMSYSERR_NOERROR || DeviceID == ULONG_MAX)
|
|
|
|
{
|
|
|
|
/* hack */
|
|
|
|
DPRINT1("Failed to get DRVM_MAPPER_PREFERRED_GET, using device 0\n");
|
|
|
|
DeviceID = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!FindDeviceByMappedId(DeviceID, &Filter, TRUE))
|
|
|
|
{
|
|
|
|
/* device not found */
|
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* copy device guid */
|
|
|
|
RtlMoveMemory(pGuidDest, &Filter->DeviceGuid[1], sizeof(GUID));
|
|
|
|
return DS_OK;
|
|
|
|
}
|
|
|
|
else if (IsEqualGUID(&DSDEVID_DefaultCapture, pGuidSrc) ||
|
|
|
|
IsEqualGUID(&DSDEVID_DefaultVoiceCapture, pGuidSrc))
|
|
|
|
{
|
|
|
|
Result = waveInMessage(UlongToHandle(WAVE_MAPPER), DRVM_MAPPER_PREFERRED_GET, (DWORD_PTR)&DeviceID, (DWORD_PTR)&Flags);
|
|
|
|
if (Result != MMSYSERR_NOERROR || DeviceID == ULONG_MAX)
|
|
|
|
{
|
|
|
|
/* hack */
|
|
|
|
DPRINT1("Failed to get DRVM_MAPPER_PREFERRED_GET, for record using device 0\n");
|
|
|
|
DeviceID = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!FindDeviceByMappedId(DeviceID, &Filter, FALSE))
|
|
|
|
{
|
|
|
|
/* device not found */
|
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* copy device guid */
|
|
|
|
RtlMoveMemory(pGuidDest, &Filter->DeviceGuid[0], sizeof(GUID));
|
|
|
|
return DS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!FindDeviceByGuid(pGuidSrc, &Filter))
|
|
|
|
{
|
|
|
|
/* unknown guid */
|
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* done */
|
|
|
|
return DS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
HRESULT
|
|
|
|
WINAPI
|
|
|
|
DllGetClassObject(
|
|
|
|
REFCLSID rclsid,
|
|
|
|
REFIID riid,
|
2009-11-10 10:04:33 +00:00
|
|
|
LPVOID* ppv)
|
2009-10-31 14:53:06 +00:00
|
|
|
{
|
|
|
|
LPOLESTR pStr, pStr2;
|
|
|
|
UINT i;
|
|
|
|
HRESULT hres = E_OUTOFMEMORY;
|
2021-09-13 01:33:14 +00:00
|
|
|
IClassFactory * pcf = NULL;
|
2009-10-31 14:53:06 +00:00
|
|
|
|
|
|
|
if (!ppv)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
*ppv = NULL;
|
|
|
|
|
2021-09-13 01:33:14 +00:00
|
|
|
for (i = 0; InterfaceTable[i].riid; i++)
|
2009-10-31 14:53:06 +00:00
|
|
|
{
|
2021-09-13 01:33:14 +00:00
|
|
|
if (IsEqualIID(InterfaceTable[i].riid, rclsid))
|
2009-10-31 14:53:06 +00:00
|
|
|
{
|
|
|
|
pcf = IClassFactory_fnConstructor(InterfaceTable[i].lpfnCI, NULL, NULL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-13 01:33:14 +00:00
|
|
|
if (!pcf)
|
2009-10-31 14:53:06 +00:00
|
|
|
{
|
|
|
|
StringFromIID(rclsid, &pStr);
|
|
|
|
StringFromIID(riid, &pStr2);
|
|
|
|
DPRINT("No Class Available for %ws IID %ws\n", pStr, pStr2);
|
|
|
|
CoTaskMemFree(pStr);
|
|
|
|
CoTaskMemFree(pStr2);
|
2009-11-10 10:04:33 +00:00
|
|
|
//ASSERT(0);
|
2009-10-31 14:53:06 +00:00
|
|
|
return CLASS_E_CLASSNOTAVAILABLE;
|
|
|
|
}
|
|
|
|
|
|
|
|
hres = IClassFactory_QueryInterface(pcf, riid, ppv);
|
|
|
|
IClassFactory_Release(pcf);
|
|
|
|
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BOOL
|
|
|
|
WINAPI
|
|
|
|
DllMain(
|
|
|
|
HINSTANCE hInstDLL,
|
|
|
|
DWORD fdwReason,
|
|
|
|
LPVOID lpvReserved)
|
|
|
|
{
|
|
|
|
switch (fdwReason)
|
|
|
|
{
|
|
|
|
case DLL_PROCESS_ATTACH:
|
|
|
|
dsound_hInstance = hInstDLL;
|
2009-11-03 11:43:33 +00:00
|
|
|
#if 1
|
2009-10-31 14:53:06 +00:00
|
|
|
DPRINT("NumDevs %u\n", waveOutGetNumDevs());
|
|
|
|
if (EnumAudioDeviceInterfaces(&RootInfo) != S_OK)
|
|
|
|
{
|
|
|
|
DPRINT("EnumAudioDeviceInterfaces failed\n");
|
|
|
|
RootInfo = NULL;
|
|
|
|
}
|
|
|
|
DPRINT1("EnumAudioDeviceInterfaces %p %u\n", RootInfo, waveOutGetNumDevs());
|
|
|
|
#endif
|
|
|
|
DisableThreadLibraryCalls(dsound_hInstance);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|