Author: janderwald
Date: Sun Oct 31 13:20:11 2010
New Revision: 49374
URL:
http://svn.reactos.org/svn/reactos?rev=49374&view=rev
Log:
[MMEBUDDY]
- Getting device capabilities requires the unicode version of the structure
- Implement MIDM_OPEN, MIDM_CLOSE, MIDM_START, MIDM_STOP
- Implement MODM_OPEN, MODM_CLOSE
- Refactor MmeOpenWaveDevice into MmeOpenDevice add add support MIXER_DEVICE_TYPE,
MIDI_IN_DEVICE_TYPE, MIDI_OUT_DEVICE_TYPE
- Refactor MmeCloseWaveDeivce into MmeCloseDevice and add support MIXER_DEVICE_TYPE,
MIDI_IN_DEVICE_TYPE, MIDI_OUT_DEVICE_TYPE
Modified:
trunk/reactos/include/reactos/libs/sound/mmebuddy.h
trunk/reactos/lib/drivers/sound/mmebuddy/capabilities.c
trunk/reactos/lib/drivers/sound/mmebuddy/midi/midMessage.c
trunk/reactos/lib/drivers/sound/mmebuddy/midi/modMessage.c
trunk/reactos/lib/drivers/sound/mmebuddy/mixer/mxdMessage.c
trunk/reactos/lib/drivers/sound/mmebuddy/mmewrap.c
trunk/reactos/lib/drivers/sound/mmebuddy/wave/widMessage.c
trunk/reactos/lib/drivers/sound/mmebuddy/wave/wodMessage.c
Modified: trunk/reactos/include/reactos/libs/sound/mmebuddy.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/sound…
==============================================================================
--- trunk/reactos/include/reactos/libs/sound/mmebuddy.h [iso-8859-1] (original)
+++ trunk/reactos/include/reactos/libs/sound/mmebuddy.h [iso-8859-1] Sun Oct 31 13:20:11
2010
@@ -68,7 +68,7 @@
SND_TRACE(L"-- Current wave header list --\n"); \
while ( CurrDumpHdr ) \
{ \
- SND_TRACE(L"%x | %d bytes | flags: %x\n",
CurrDumpHdr->lpData, \
+ SND_TRACE(L"%x | %d bytes | flags: %x\n", CurrDumpHdr, \
CurrDumpHdr->dwBufferLength, \
CurrDumpHdr->dwFlags); \
CurrDumpHdr = CurrDumpHdr->lpNext; \
@@ -364,6 +364,8 @@
WAVEFORMATEX WaveFormatEx;
HANDLE hNotifyEvent;
HANDLE hStopEvent;
+ HANDLE hResetEvent;
+ BOOL ResetInProgress;
} SOUND_DEVICE_INSTANCE, *PSOUND_DEVICE_INSTANCE;
/* This lives in WAVEHDR.reserved */
@@ -411,7 +413,7 @@
IN DWORD CapabilitiesSize);
MMRESULT
-MmeOpenWaveDevice(
+MmeOpenDevice(
IN MMDEVICE_TYPE DeviceType,
IN UINT DeviceId,
IN LPWAVEOPENDESC OpenParameters,
Modified: trunk/reactos/lib/drivers/sound/mmebuddy/capabilities.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/sound/mmebuddy…
==============================================================================
--- trunk/reactos/lib/drivers/sound/mmebuddy/capabilities.c [iso-8859-1] (original)
+++ trunk/reactos/lib/drivers/sound/mmebuddy/capabilities.c [iso-8859-1] Sun Oct 31
13:20:11 2010
@@ -62,32 +62,32 @@
{
case WAVE_OUT_DEVICE_TYPE :
{
- GoodSize = CapabilitiesSize >= sizeof(WAVEOUTCAPS);
+ GoodSize = CapabilitiesSize >= sizeof(WAVEOUTCAPSW);
break;
}
case WAVE_IN_DEVICE_TYPE :
{
- GoodSize = CapabilitiesSize >= sizeof(WAVEINCAPS);
+ GoodSize = CapabilitiesSize >= sizeof(WAVEINCAPSW);
break;
}
case MIDI_OUT_DEVICE_TYPE :
{
- GoodSize = CapabilitiesSize >= sizeof(MIDIOUTCAPS);
+ GoodSize = CapabilitiesSize >= sizeof(MIDIOUTCAPSW);
break;
}
case MIDI_IN_DEVICE_TYPE :
{
- GoodSize = CapabilitiesSize >= sizeof(MIDIINCAPS);
+ GoodSize = CapabilitiesSize >= sizeof(MIDIINCAPSW);
break;
}
case AUX_DEVICE_TYPE :
{
- GoodSize = CapabilitiesSize >= sizeof(AUXCAPS);
+ GoodSize = CapabilitiesSize >= sizeof(AUXCAPSW);
break;
}
case MIXER_DEVICE_TYPE :
{
- GoodSize = CapabilitiesSize >= sizeof(MIXERCAPS);
+ GoodSize = CapabilitiesSize >= sizeof(MIXERCAPSW);
break;
}
};
Modified: trunk/reactos/lib/drivers/sound/mmebuddy/midi/midMessage.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/sound/mmebuddy…
==============================================================================
--- trunk/reactos/lib/drivers/sound/mmebuddy/midi/midMessage.c [iso-8859-1] (original)
+++ trunk/reactos/lib/drivers/sound/mmebuddy/midi/midMessage.c [iso-8859-1] Sun Oct 31
13:20:11 2010
@@ -65,6 +65,33 @@
break;
}
+ case MIDM_OPEN :
+ {
+ Result = MmeOpenDevice(MIDI_IN_DEVICE_TYPE,
+ DeviceId,
+ (LPWAVEOPENDESC) Parameter1,
+ Parameter2,
+ (DWORD_PTR*) PrivateHandle);
+ break;
+ }
+
+ case MIDM_CLOSE :
+ {
+ Result = MmeCloseDevice(PrivateHandle);
+ break;
+ }
+
+ case MIDM_START :
+ {
+ Result = MmeSetState(PrivateHandle, TRUE);
+ break;
+ }
+
+ case MIDM_STOP :
+ {
+ Result = MmeSetState(PrivateHandle, FALSE);
+ break;
+ }
}
SND_TRACE(L"midMessage returning MMRESULT %d\n", Result);
Modified: trunk/reactos/lib/drivers/sound/mmebuddy/midi/modMessage.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/sound/mmebuddy…
==============================================================================
--- trunk/reactos/lib/drivers/sound/mmebuddy/midi/modMessage.c [iso-8859-1] (original)
+++ trunk/reactos/lib/drivers/sound/mmebuddy/midi/modMessage.c [iso-8859-1] Sun Oct 31
13:20:11 2010
@@ -64,6 +64,24 @@
Result = MmeGetDeviceInterfaceString(MIDI_OUT_DEVICE_TYPE, DeviceId,
(LPWSTR)Parameter1, Parameter2, NULL); //FIXME DWORD_PTR
break;
}
+
+ case MODM_OPEN :
+ {
+ Result = MmeOpenDevice(MIDI_OUT_DEVICE_TYPE,
+ DeviceId,
+ (LPWAVEOPENDESC) Parameter1, /* unused */
+ Parameter2,
+ (DWORD_PTR*)PrivateHandle);
+ break;
+ }
+
+ case MODM_CLOSE :
+ {
+ Result = MmeCloseDevice(PrivateHandle);
+
+ break;
+ }
+
}
SND_TRACE(L"modMessage returning MMRESULT %d\n", Result);
Modified: trunk/reactos/lib/drivers/sound/mmebuddy/mixer/mxdMessage.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/sound/mmebuddy…
==============================================================================
--- trunk/reactos/lib/drivers/sound/mmebuddy/mixer/mxdMessage.c [iso-8859-1] (original)
+++ trunk/reactos/lib/drivers/sound/mmebuddy/mixer/mxdMessage.c [iso-8859-1] Sun Oct 31
13:20:11 2010
@@ -52,99 +52,6 @@
}
-MMRESULT
-MmeCloseMixerDevice(
- IN DWORD_PTR PrivateHandle)
-{
- MMRESULT Result;
- PSOUND_DEVICE_INSTANCE SoundDeviceInstance;
- PSOUND_DEVICE SoundDevice;
-
- SND_TRACE(L"Closing mixer device \n");
-
- VALIDATE_MMSYS_PARAMETER( PrivateHandle );
- SoundDeviceInstance = (PSOUND_DEVICE_INSTANCE) PrivateHandle;
-
- if ( ! IsValidSoundDeviceInstance(SoundDeviceInstance) )
- return MMSYSERR_INVALHANDLE;
-
- Result = GetSoundDeviceFromInstance(SoundDeviceInstance, &SoundDevice);
- if ( ! MMSUCCESS(Result) )
- return TranslateInternalMmResult(Result);
-
-
- Result = DestroySoundDeviceInstance(SoundDeviceInstance);
-
- return Result;
-}
-
-MMRESULT
-MmeOpenMixerDevice(
- IN MMDEVICE_TYPE DeviceType,
- IN DWORD DeviceId,
- IN LPMIXEROPENDESC OpenParameters,
- IN DWORD Flags,
- OUT DWORD* PrivateHandle)
-{
- MMRESULT Result;
- PMMFUNCTION_TABLE FunctionTable;
- PSOUND_DEVICE SoundDevice;
- PSOUND_DEVICE_INSTANCE SoundDeviceInstance;
-
- SND_TRACE(L"Opening mixer device");
-
- VALIDATE_MMSYS_PARAMETER( OpenParameters );
-
- Result = GetSoundDevice(DeviceType, DeviceId, &SoundDevice);
- if ( ! MMSUCCESS(Result) )
- return TranslateInternalMmResult(Result);
-
- /* Check that winmm gave us a private handle to fill */
- VALIDATE_MMSYS_PARAMETER( PrivateHandle );
-
- /* Create a sound device instance and open the sound device */
- Result = CreateSoundDeviceInstance(SoundDevice, &SoundDeviceInstance);
- if ( ! MMSUCCESS(Result) )
- return TranslateInternalMmResult(Result);
-
- Result = GetSoundDeviceFunctionTable(SoundDevice, &FunctionTable);
- if ( ! MMSUCCESS(Result) )
- return TranslateInternalMmResult(Result);
-
- if ( ! FunctionTable->SetWaveFormat )
- return MMSYSERR_NOTSUPPORTED;
-
- Result = FunctionTable->SetWaveFormat(SoundDeviceInstance, DeviceId, NULL, 0);
- if ( ! MMSUCCESS(Result) )
- {
- /* TODO: Destroy sound instance */
- return TranslateInternalMmResult(Result);
- }
-
- /* Store the device instance pointer in the private handle - is DWORD safe here? */
- *PrivateHandle = (DWORD_PTR) SoundDeviceInstance;
-
- /* Store the additional information we were given - FIXME: Need flags! */
- SetSoundDeviceInstanceMmeData(SoundDeviceInstance,
- (HDRVR)OpenParameters->hmx,
- OpenParameters->dwCallback,
- OpenParameters->dwInstance,
- Flags);
-
- /* Let the application know the device is open */
- ReleaseEntrypointMutex(DeviceType);
-#if 0
- NotifyMmeClient(SoundDeviceInstance,
- DeviceType == WAVE_OUT_DEVICE_TYPE ? WOM_OPEN : WIM_OPEN,
- 0);
-#endif
- AcquireEntrypointMutex(DeviceType);
-
- SND_TRACE(L"Mixer device now open\n");
-
- return MMSYSERR_NOERROR;
-}
-
/*
Standard MME driver entry-point for messages relating to mixers.
*/
@@ -188,18 +95,18 @@
case MXDM_OPEN :
{
- Result = MmeOpenMixerDevice(MIXER_DEVICE_TYPE,
- DeviceId,
- (LPMIXEROPENDESC) Parameter1,
- Parameter2,
- (DWORD*) PrivateHandle);
+ Result = MmeOpenDevice(MIXER_DEVICE_TYPE,
+ DeviceId,
+ (LPWAVEOPENDESC) Parameter1, /* unused */
+ Parameter2,
+ (DWORD*) PrivateHandle);
break;
}
case MXDM_CLOSE :
{
- Result = MmeCloseMixerDevice(PrivateHandle);
+ Result = MmeCloseDevice(PrivateHandle);
break;
}
Modified: trunk/reactos/lib/drivers/sound/mmebuddy/mmewrap.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/sound/mmebuddy…
==============================================================================
--- trunk/reactos/lib/drivers/sound/mmebuddy/mmewrap.c [iso-8859-1] (original)
+++ trunk/reactos/lib/drivers/sound/mmebuddy/mmewrap.c [iso-8859-1] Sun Oct 31 13:20:11
2010
@@ -119,7 +119,7 @@
}
MMRESULT
-MmeOpenWaveDevice(
+MmeOpenDevice(
IN MMDEVICE_TYPE DeviceType,
IN UINT DeviceId,
IN LPWAVEOPENDESC OpenParameters,
@@ -127,33 +127,36 @@
OUT DWORD_PTR* PrivateHandle)
{
MMRESULT Result;
-
+ UINT Message;
PSOUND_DEVICE SoundDevice;
PSOUND_DEVICE_INSTANCE SoundDeviceInstance;
LPWAVEFORMATEX Format;
- SND_TRACE(L"Opening wave device (WIDM_OPEN / WODM_OPEN)");
+ SND_TRACE(L"Opening device");
VALIDATE_MMSYS_PARAMETER( IS_WAVE_DEVICE_TYPE(DeviceType) ); /* FIXME? wave in
too? */
VALIDATE_MMSYS_PARAMETER( OpenParameters );
- Format = OpenParameters->lpFormat;
-
Result = GetSoundDevice(DeviceType, DeviceId, &SoundDevice);
if ( ! MMSUCCESS(Result) )
return TranslateInternalMmResult(Result);
- /* Does this device support the format? */
- Result = QueryWaveDeviceFormatSupport(SoundDevice, Format, sizeof(WAVEFORMATEX));
- if ( ! MMSUCCESS(Result) )
- {
- SND_ERR(L"Format not supported\n");
- return TranslateInternalMmResult(Result);
- }
-
- /* If the caller just wanted to know if a format is supported, end here */
- if ( Flags & WAVE_FORMAT_QUERY )
- return MMSYSERR_NOERROR;
+ if (DeviceType == WAVE_IN_DEVICE_TYPE || DeviceType == WAVE_OUT_DEVICE_TYPE)
+ {
+ Format = OpenParameters->lpFormat;
+
+ /* Does this device support the format? */
+ Result = QueryWaveDeviceFormatSupport(SoundDevice, Format,
sizeof(WAVEFORMATEX));
+ if ( ! MMSUCCESS(Result) )
+ {
+ SND_ERR(L"Format not supported\n");
+ return TranslateInternalMmResult(Result);
+ }
+
+ /* If the caller just wanted to know if a format is supported, end here */
+ if ( Flags & WAVE_FORMAT_QUERY )
+ return MMSYSERR_NOERROR;
+ }
/* Check that winmm gave us a private handle to fill */
VALIDATE_MMSYS_PARAMETER( PrivateHandle );
@@ -175,20 +178,35 @@
/* Store the additional information we were given - FIXME: Need flags! */
SetSoundDeviceInstanceMmeData(SoundDeviceInstance,
- (HDRVR)OpenParameters->hWave,
+ (HDRVR)OpenParameters->hWave, /* works because
LPMIXEROPENDESC/etc has also the handle as first member */
OpenParameters->dwCallback,
OpenParameters->dwInstance,
Flags);
- /* Let the application know the device is open */
- ReleaseEntrypointMutex(DeviceType);
- NotifyMmeClient(SoundDeviceInstance,
- DeviceType == WAVE_OUT_DEVICE_TYPE ? WOM_OPEN : WIM_OPEN,
- 0);
-
- AcquireEntrypointMutex(DeviceType);
-
- SND_TRACE(L"Wave device now open\n");
+ if (DeviceType == WAVE_OUT_DEVICE_TYPE || DeviceType == WAVE_IN_DEVICE_TYPE ||
+ DeviceType == MIDI_OUT_DEVICE_TYPE || DeviceType == MIDI_IN_DEVICE_TYPE)
+ {
+ /* Let the application know the device is open */
+
+ if (DeviceType == WAVE_OUT_DEVICE_TYPE)
+ Message = WOM_OPEN;
+ else if (DeviceType == WAVE_IN_DEVICE_TYPE)
+ Message = WIM_OPEN;
+ else if (DeviceType == MIDI_IN_DEVICE_TYPE)
+ Message = MIM_OPEN;
+ else
+ Message = MOM_OPEN;
+
+ ReleaseEntrypointMutex(DeviceType);
+
+ NotifyMmeClient(SoundDeviceInstance,
+ Message,
+ 0);
+
+ AcquireEntrypointMutex(DeviceType);
+ }
+
+ SND_TRACE(L"device now open\n");
return MMSYSERR_NOERROR;
}
@@ -201,6 +219,7 @@
PSOUND_DEVICE_INSTANCE SoundDeviceInstance;
PSOUND_DEVICE SoundDevice;
MMDEVICE_TYPE DeviceType;
+ UINT Message = 0;
SND_TRACE(L"Closing wave device (WIDM_CLOSE / WODM_CLOSE)\n");
@@ -221,12 +240,26 @@
/* TODO: Check device is stopped! */
- ReleaseEntrypointMutex(DeviceType);
- /* TODO: Work with MIDI devices too */
- NotifyMmeClient(SoundDeviceInstance,
- DeviceType == WAVE_OUT_DEVICE_TYPE ? WOM_CLOSE : WIM_CLOSE,
- 0);
- AcquireEntrypointMutex(DeviceType);
+
+ if (DeviceType != MIXER_DEVICE_TYPE)
+ {
+ ReleaseEntrypointMutex(DeviceType);
+
+ if (DeviceType == WAVE_OUT_DEVICE_TYPE)
+ Message = WOM_CLOSE;
+ else if (DeviceType == WAVE_IN_DEVICE_TYPE)
+ Message = WIM_CLOSE;
+ else if (DeviceType == MIDI_IN_DEVICE_TYPE)
+ Message = MIM_CLOSE;
+ else if (DeviceType == MIDI_OUT_DEVICE_TYPE)
+ Message = MOM_CLOSE;
+
+ /* TODO: Work with MIDI devices too */
+ NotifyMmeClient(SoundDeviceInstance,
+ Message,
+ 0);
+ AcquireEntrypointMutex(DeviceType);
+ }
Result = DestroySoundDeviceInstance(SoundDeviceInstance);
Modified: trunk/reactos/lib/drivers/sound/mmebuddy/wave/widMessage.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/sound/mmebuddy…
==============================================================================
--- trunk/reactos/lib/drivers/sound/mmebuddy/wave/widMessage.c [iso-8859-1] (original)
+++ trunk/reactos/lib/drivers/sound/mmebuddy/wave/widMessage.c [iso-8859-1] Sun Oct 31
13:20:11 2010
@@ -68,7 +68,7 @@
}
case WIDM_OPEN :
{
- Result = MmeOpenWaveDevice(WAVE_IN_DEVICE_TYPE,
+ Result = MmeOpenDevice(WAVE_IN_DEVICE_TYPE,
DeviceId,
(LPWAVEOPENDESC) Parameter1,
Parameter2,
Modified: trunk/reactos/lib/drivers/sound/mmebuddy/wave/wodMessage.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/sound/mmebuddy…
==============================================================================
--- trunk/reactos/lib/drivers/sound/mmebuddy/wave/wodMessage.c [iso-8859-1] (original)
+++ trunk/reactos/lib/drivers/sound/mmebuddy/wave/wodMessage.c [iso-8859-1] Sun Oct 31
13:20:11 2010
@@ -65,11 +65,11 @@
case WODM_OPEN :
{
- Result = MmeOpenWaveDevice(WAVE_OUT_DEVICE_TYPE,
- DeviceId,
- (LPWAVEOPENDESC) Parameter1,
- Parameter2,
- (DWORD_PTR*)PrivateHandle);
+ Result = MmeOpenDevice(WAVE_OUT_DEVICE_TYPE,
+ DeviceId,
+ (LPWAVEOPENDESC) Parameter1,
+ Parameter2,
+ (DWORD_PTR*)PrivateHandle);
break;
}