reactos/dll/win32/wdmaud.drv/wdmaud.c

229 lines
6.2 KiB
C
Raw Normal View History

/*
* PROJECT: ReactOS Sound System
* LICENSE: GPL - See COPYING in the top level directory
* FILE: dll/win32/wdmaud.drv/wdmaud.c
*
* PURPOSE: WDM Audio Driver (User-mode part)
* PROGRAMMERS: Andrew Greenwood (silverblade@reactos.org)
*
* NOTES: Looking for wodMessage & co? You won't find them here. Try
* the MME Buddy library, which is where these routines are
* actually implemented.
*
*/
#include "wdmaud.h"
#define NDEBUG
#include <debug.h>
#ifndef USE_MMIXER_LIB
#define FUNC_NAME(x) x##ByLegacy
#else
#define FUNC_NAME(x) x##ByMMixer
#endif
MMRESULT
QueryWdmWaveDeviceFormatSupport(
IN PSOUND_DEVICE Device,
IN PWAVEFORMATEX WaveFormat,
IN DWORD WaveFormatSize)
{
/* Whatever... */
return MMSYSERR_NOERROR;
}
MMRESULT
PopulateWdmDeviceList(
MMDEVICE_TYPE DeviceType)
{
MMRESULT Result;
DWORD DeviceCount = 0;
PSOUND_DEVICE SoundDevice = NULL;
MMFUNCTION_TABLE FuncTable;
DWORD i;
VALIDATE_MMSYS_PARAMETER( IS_VALID_SOUND_DEVICE_TYPE(DeviceType) );
Result = FUNC_NAME(WdmAudGetNumWdmDevs)(DeviceType, &DeviceCount);
if ( ! MMSUCCESS(Result) )
{
SND_ERR(L"Error %d while obtaining number of devices\n", Result);
return TranslateInternalMmResult(Result);
}
SND_TRACE(L"%d devices of type %d found\n", DeviceCount, DeviceType);
for ( i = 0; i < DeviceCount; ++ i )
{
Merge from amd64 branch: [SPIDER] 44002 Fix 64 bit build. (Samuel Serapión) [PAINT] 43858 Fix 64 bit warnings. (Samuel Serapión) [RAPPS] 43906 Fix 64 bit build. (Samuel Serapión) [SNDREC32] 44389 Fix 64 bit build. (Samuel Serapión) [TFTP] 41097 Fix pointer to DWORD cast. (Timo Kreuzer) [COMCTL32] 36172 Build as unicode. (Samuel Serapión) [USERMGR] 41098 Fix 2 POINTER<->DWORD casts. (Timo Kreuzer) [d3d9] 38149 Fix pointer<->ULONG cast. (Timo Kreuzer) 43839 Fix 64 bit Build. (Samuel Serapión) [DSOUND] 40753 Make DSDRIVERDESC.dnDevNode a DWORD_PTR and DSPROPERTY.InstanceId a ULONG_PTR. (Timo Kreuzer) [LSASRV] 44037 Fix 64 bit Build. (Samuel Serapión) [MMDRV] 40125 Fix 64bit build. (Samuel Serapión) [MSGINA] 40993 fix 64bit build (Timo Kreuzer) [NETSHELL] 41001 Don't cast the 1st parameter of InterlockedExchange to volatile void **, but to void ** (Timo Kreuzer) [OPENGL32] 36502 No need to assert an offset thats only used in i386 specific code. (Samuel Serapión) [POWRPROF] 41044 Don't cast NULL to DWORD. (Timo Kreuzer) 43860 Don't cast NULL to an integer type. (Samuel Serapión) [PSAPI] 38150 Fix a cast (Timo Kreuzer) [SHELL32] 38355 Use Get/SetWindowLongPtr (Samuel Serapión) 41047 Get rid of deprecated LargeInteger functions and use native int64 math instead. (Timo Kreuzer) 41048 DialogProc returns INT_PTR and not BOOL. Don't cast a pointer to LONG. Use INT_PTR instead of int for pointer math. (Timo Kreuzer) 41049 Change return type of OpenMRUListW and CreateMRUListW to HANDLE, add a comment that CREATEMRULISTW is already defined differently in explorer_new/undoc.h (Timo Kreuzer) 44601 Fix a prototype. Convert RtlLargeInteger to native int64. Fixes 64bit built. (Timo Kreuzer) [WDMAUD.DRV] 41101 Don't cast DWORD to PVOID, use UlongToPtr instead. (Timo Kreuzer) [WS2_32] 35777 fix ws2_32 spec file (Timo kreuzer) 44044 Fix ws2_32 64bit build (1 of 2) (Samuel Serapión) 44045 Fix ws2_32 64bit build (2 of 2) (Samuel Serapión) [WS2_32_NEW] 44389 Fix 64 bit built. (Samuel Serapión) svn path=/trunk/; revision=44602
2009-12-15 15:16:01 +00:00
Result = ListSoundDevice(DeviceType, UlongToPtr(i), &SoundDevice);
if ( ! MMSUCCESS(Result) )
{
SND_ERR(L"Failed to list sound device - error %d\n", Result);
return TranslateInternalMmResult(Result);
}
/* Set up our function table */
ZeroMemory(&FuncTable, sizeof(MMFUNCTION_TABLE));
FuncTable.GetCapabilities = FUNC_NAME(WdmAudGetCapabilities);
FuncTable.QueryWaveFormatSupport = QueryWdmWaveDeviceFormatSupport; //FIXME
FuncTable.Open = FUNC_NAME(WdmAudOpenSoundDevice);
FuncTable.Close = FUNC_NAME(WdmAudCloseSoundDevice);
FuncTable.GetDeviceInterfaceString = FUNC_NAME(WdmAudGetDeviceInterfaceString);
if (DeviceType == MIXER_DEVICE_TYPE)
{
FuncTable.SetWaveFormat = FUNC_NAME(WdmAudSetMixerDeviceFormat);
FuncTable.QueryMixerInfo = FUNC_NAME(WdmAudQueryMixerInfo);
}
else if (DeviceType == WAVE_IN_DEVICE_TYPE || DeviceType == WAVE_OUT_DEVICE_TYPE)
{
FuncTable.SetWaveFormat = FUNC_NAME(WdmAudSetWaveDeviceFormat);
FuncTable.SetState = FUNC_NAME(WdmAudSetWaveState);
FuncTable.ResetStream = FUNC_NAME(WdmAudResetStream);
FuncTable.GetPos = FUNC_NAME(WdmAudGetWavePosition);
#ifndef USERMODE_MIXER
FuncTable.CommitWaveBuffer = FUNC_NAME(WdmAudCommitWaveBuffer);
#else
FuncTable.CommitWaveBuffer = WriteFileEx_Remixer;
#endif
}
else if (DeviceType == MIDI_IN_DEVICE_TYPE || DeviceType == MIDI_OUT_DEVICE_TYPE)
{
FuncTable.SetWaveFormat = FUNC_NAME(WdmAudSetMixerDeviceFormat);
FuncTable.SetState = FUNC_NAME(WdmAudSetWaveState);
FuncTable.GetPos = FUNC_NAME(WdmAudGetWavePosition);
}
SetSoundDeviceFunctionTable(SoundDevice, &FuncTable);
}
return MMSYSERR_NOERROR;
}
LONG
APIENTRY
DriverProc(
DWORD DriverId,
HANDLE DriverHandle,
UINT Message,
LONG Parameter1,
LONG Parameter2)
{
switch ( Message )
{
case DRV_LOAD :
{
HANDLE Handle;
MMRESULT Result;
SND_TRACE(L"DRV_LOAD\n");
Result = InitEntrypointMutexes();
if ( ! MMSUCCESS(Result) )
return 0L;
Result = FUNC_NAME(WdmAudOpenSoundDevice)(NULL, &Handle);
if ( Result != MMSYSERR_NOERROR )
{
SND_ERR(L"Failed to open \\\\.\\wdmaud\n");
//UnlistAllSoundDevices();
return 0L;
}
/* Populate the device lists */
SND_TRACE(L"Populating device lists\n");
PopulateWdmDeviceList(WAVE_OUT_DEVICE_TYPE);
PopulateWdmDeviceList(WAVE_IN_DEVICE_TYPE);
PopulateWdmDeviceList(MIDI_OUT_DEVICE_TYPE);
PopulateWdmDeviceList(MIDI_IN_DEVICE_TYPE);
PopulateWdmDeviceList(AUX_DEVICE_TYPE);
PopulateWdmDeviceList(MIXER_DEVICE_TYPE);
SND_TRACE(L"Initialisation complete\n");
return 1L;
}
case DRV_FREE :
{
SND_TRACE(L"DRV_FREE\n");
FUNC_NAME(WdmAudCleanup)();
/* TODO: Clean up the path names! */
UnlistAllSoundDevices();
CleanupEntrypointMutexes();
SND_TRACE(L"Unfreed memory blocks: %d\n",
GetMemoryAllocationCount());
return 1L;
}
case DRV_ENABLE :
case DRV_DISABLE :
{
SND_TRACE(L"DRV_ENABLE / DRV_DISABLE\n");
return 1L;
}
case DRV_OPEN :
case DRV_CLOSE :
{
SND_TRACE(L"DRV_OPEN / DRV_CLOSE\n");
return 1L;
}
case DRV_QUERYCONFIGURE :
{
SND_TRACE(L"DRV_QUERYCONFIGURE\n");
return 0L;
}
case DRV_CONFIGURE :
return DRVCNF_OK;
default :
SND_TRACE(L"Unhandled message %d\n", Message);
return DefDriverProc(DriverId,
DriverHandle,
Message,
Parameter1,
Parameter2);
}
}
BOOL WINAPI DllMain(
HINSTANCE hinstDLL,
DWORD fdwReason,
LPVOID lpvReserved)
{
switch ( fdwReason )
{
case DLL_PROCESS_ATTACH :
SND_TRACE(L"WDMAUD.DRV - Process attached\n");
break;
case DLL_PROCESS_DETACH :
SND_TRACE(L"WDMAUD.DRV - Process detached\n");
break;
case DLL_THREAD_ATTACH :
SND_TRACE(L"WDMAUD.DRV - Thread attached\n");
break;
case DLL_THREAD_DETACH :
SND_TRACE(L"WDMAUD.DRV - Thread detached\n");
break;
}
return TRUE;
}