2008-05-25 09:34:14 +00:00
|
|
|
/*
|
2009-02-18 19:10:02 +00:00
|
|
|
* PROJECT: ReactOS Sound System
|
|
|
|
* LICENSE: GPL - See COPYING in the top level directory
|
|
|
|
* FILE: dll/win32/wdmaud.drv/wdmaud.c
|
2008-05-25 09:34:14 +00:00
|
|
|
*
|
2009-02-18 19:10:02 +00:00
|
|
|
* 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.
|
2008-05-25 09:34:14 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2009-12-13 15:36:19 +00:00
|
|
|
#include "wdmaud.h"
|
2008-05-25 10:41:08 +00:00
|
|
|
|
2014-01-01 18:50:14 +00:00
|
|
|
#define NDEBUG
|
|
|
|
#include <debug.h>
|
2010-01-04 18:07:27 +00:00
|
|
|
|
2010-02-03 12:48:27 +00:00
|
|
|
#ifndef USE_MMIXER_LIB
|
|
|
|
#define FUNC_NAME(x) x##ByLegacy
|
2010-01-04 18:07:27 +00:00
|
|
|
#else
|
2010-02-03 12:48:27 +00:00
|
|
|
#define FUNC_NAME(x) x##ByMMixer
|
2010-01-04 18:07:27 +00:00
|
|
|
#endif
|
2009-02-22 21:14:54 +00:00
|
|
|
|
|
|
|
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) );
|
|
|
|
|
2010-02-03 12:48:27 +00:00
|
|
|
Result = FUNC_NAME(WdmAudGetNumWdmDevs)(DeviceType, &DeviceCount);
|
2009-02-22 21:14:54 +00:00
|
|
|
|
|
|
|
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 )
|
|
|
|
{
|
2009-12-15 15:16:01 +00:00
|
|
|
Result = ListSoundDevice(DeviceType, UlongToPtr(i), &SoundDevice);
|
2009-02-22 21:14:54 +00:00
|
|
|
|
|
|
|
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));
|
2010-02-03 12:48:27 +00:00
|
|
|
FuncTable.GetCapabilities = FUNC_NAME(WdmAudGetCapabilities);
|
|
|
|
FuncTable.QueryWaveFormatSupport = QueryWdmWaveDeviceFormatSupport; //FIXME
|
|
|
|
FuncTable.Open = FUNC_NAME(WdmAudOpenSoundDevice);
|
|
|
|
FuncTable.Close = FUNC_NAME(WdmAudCloseSoundDevice);
|
|
|
|
FuncTable.GetDeviceInterfaceString = FUNC_NAME(WdmAudGetDeviceInterfaceString);
|
|
|
|
|
2009-09-24 18:11:22 +00:00
|
|
|
if (DeviceType == MIXER_DEVICE_TYPE)
|
|
|
|
{
|
2010-02-03 12:48:27 +00:00
|
|
|
FuncTable.SetWaveFormat = FUNC_NAME(WdmAudSetMixerDeviceFormat);
|
|
|
|
FuncTable.QueryMixerInfo = FUNC_NAME(WdmAudQueryMixerInfo);
|
2009-09-24 18:11:22 +00:00
|
|
|
}
|
2010-02-03 12:48:27 +00:00
|
|
|
else if (DeviceType == WAVE_IN_DEVICE_TYPE || DeviceType == WAVE_OUT_DEVICE_TYPE)
|
2009-10-26 00:15:22 +00:00
|
|
|
{
|
2010-02-03 12:48:27 +00:00
|
|
|
FuncTable.SetWaveFormat = FUNC_NAME(WdmAudSetWaveDeviceFormat);
|
|
|
|
FuncTable.SetState = FUNC_NAME(WdmAudSetWaveState);
|
|
|
|
FuncTable.ResetStream = FUNC_NAME(WdmAudResetStream);
|
|
|
|
FuncTable.GetPos = FUNC_NAME(WdmAudGetWavePosition);
|
2009-10-26 00:15:22 +00:00
|
|
|
|
2010-01-04 18:07:27 +00:00
|
|
|
#ifndef USERMODE_MIXER
|
2010-02-03 12:48:27 +00:00
|
|
|
FuncTable.CommitWaveBuffer = FUNC_NAME(WdmAudCommitWaveBuffer);
|
2009-08-17 13:49:19 +00:00
|
|
|
#else
|
2010-02-03 12:48:27 +00:00
|
|
|
FuncTable.CommitWaveBuffer = WriteFileEx_Remixer;
|
2009-08-17 13:49:19 +00:00
|
|
|
#endif
|
2010-02-03 12:48:27 +00:00
|
|
|
}
|
2010-10-31 14:34:41 +00:00
|
|
|
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);
|
|
|
|
}
|
2009-02-22 21:14:54 +00:00
|
|
|
|
|
|
|
SetSoundDeviceFunctionTable(SoundDevice, &FuncTable);
|
|
|
|
}
|
|
|
|
|
|
|
|
return MMSYSERR_NOERROR;
|
|
|
|
}
|
|
|
|
|
2010-01-04 18:07:27 +00:00
|
|
|
|
|
|
|
|
2009-08-07 21:27:45 +00:00
|
|
|
LONG
|
|
|
|
APIENTRY
|
2009-02-18 19:10:02 +00:00
|
|
|
DriverProc(
|
|
|
|
DWORD DriverId,
|
|
|
|
HANDLE DriverHandle,
|
|
|
|
UINT Message,
|
|
|
|
LONG Parameter1,
|
|
|
|
LONG Parameter2)
|
2008-05-25 09:34:14 +00:00
|
|
|
{
|
2009-02-18 19:10:02 +00:00
|
|
|
switch ( Message )
|
2008-05-25 10:41:08 +00:00
|
|
|
{
|
2009-02-18 19:10:02 +00:00
|
|
|
case DRV_LOAD :
|
|
|
|
{
|
2010-01-04 18:07:27 +00:00
|
|
|
HANDLE Handle;
|
2010-02-03 12:48:27 +00:00
|
|
|
MMRESULT Result;
|
2009-02-18 19:10:02 +00:00
|
|
|
SND_TRACE(L"DRV_LOAD\n");
|
|
|
|
|
|
|
|
Result = InitEntrypointMutexes();
|
|
|
|
|
|
|
|
if ( ! MMSUCCESS(Result) )
|
|
|
|
return 0L;
|
|
|
|
|
2010-02-03 12:48:27 +00:00
|
|
|
Result = FUNC_NAME(WdmAudOpenSoundDevice)(NULL, &Handle);
|
2010-01-04 18:07:27 +00:00
|
|
|
|
2010-02-03 12:48:27 +00:00
|
|
|
if ( Result != MMSYSERR_NOERROR )
|
2009-02-18 19:10:02 +00:00
|
|
|
{
|
2009-12-23 10:43:17 +00:00
|
|
|
SND_ERR(L"Failed to open \\\\.\\wdmaud\n");
|
2009-02-22 21:14:54 +00:00
|
|
|
//UnlistAllSoundDevices();
|
2009-02-18 19:10:02 +00:00
|
|
|
|
|
|
|
return 0L;
|
|
|
|
}
|
|
|
|
|
2009-02-22 21:14:54 +00:00
|
|
|
/* Populate the device lists */
|
|
|
|
SND_TRACE(L"Populating device lists\n");
|
2010-02-03 12:48:27 +00:00
|
|
|
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);
|
2009-02-22 21:14:54 +00:00
|
|
|
|
2009-02-18 19:10:02 +00:00
|
|
|
SND_TRACE(L"Initialisation complete\n");
|
|
|
|
|
|
|
|
return 1L;
|
|
|
|
}
|
|
|
|
|
|
|
|
case DRV_FREE :
|
|
|
|
{
|
|
|
|
SND_TRACE(L"DRV_FREE\n");
|
|
|
|
|
2010-02-03 12:48:27 +00:00
|
|
|
FUNC_NAME(WdmAudCleanup)();
|
2009-02-18 19:10:02 +00:00
|
|
|
|
|
|
|
/* 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 :
|
|
|
|
{
|
2009-02-22 14:07:18 +00:00
|
|
|
SND_TRACE(L"DRV_QUERYCONFIGURE\n");
|
2009-02-18 19:10:02 +00:00
|
|
|
return 0L;
|
|
|
|
}
|
|
|
|
case DRV_CONFIGURE :
|
|
|
|
return DRVCNF_OK;
|
|
|
|
|
|
|
|
default :
|
|
|
|
SND_TRACE(L"Unhandled message %d\n", Message);
|
|
|
|
return DefDriverProc(DriverId,
|
|
|
|
DriverHandle,
|
|
|
|
Message,
|
|
|
|
Parameter1,
|
|
|
|
Parameter2);
|
2008-05-25 10:41:08 +00:00
|
|
|
}
|
2008-05-25 09:34:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-02-18 19:10:02 +00:00
|
|
|
BOOL WINAPI DllMain(
|
|
|
|
HINSTANCE hinstDLL,
|
|
|
|
DWORD fdwReason,
|
|
|
|
LPVOID lpvReserved)
|
2008-05-25 09:34:14 +00:00
|
|
|
{
|
2009-02-18 19:10:02 +00:00
|
|
|
switch ( fdwReason )
|
2008-05-25 09:34:14 +00:00
|
|
|
{
|
2009-02-18 19:10:02 +00:00
|
|
|
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");
|
2008-05-25 09:34:14 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|