From 5dd7b0178c4e293563d3cd90abef91fe820da9b5 Mon Sep 17 00:00:00 2001 From: Johannes Anderwald Date: Sun, 31 Oct 2010 13:20:11 +0000 Subject: [PATCH] [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 svn path=/trunk/; revision=49374 --- reactos/include/reactos/libs/sound/mmebuddy.h | 6 +- .../lib/drivers/sound/mmebuddy/capabilities.c | 12 +- .../drivers/sound/mmebuddy/midi/midMessage.c | 27 +++++ .../drivers/sound/mmebuddy/midi/modMessage.c | 18 +++ .../drivers/sound/mmebuddy/mixer/mxdMessage.c | 105 +----------------- reactos/lib/drivers/sound/mmebuddy/mmewrap.c | 89 ++++++++++----- .../drivers/sound/mmebuddy/wave/widMessage.c | 2 +- .../drivers/sound/mmebuddy/wave/wodMessage.c | 10 +- 8 files changed, 128 insertions(+), 141 deletions(-) diff --git a/reactos/include/reactos/libs/sound/mmebuddy.h b/reactos/include/reactos/libs/sound/mmebuddy.h index cae6f3f1489..1a2a5431242 100644 --- a/reactos/include/reactos/libs/sound/mmebuddy.h +++ b/reactos/include/reactos/libs/sound/mmebuddy.h @@ -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 @@ typedef struct _SOUND_DEVICE_INSTANCE 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 @@ MmeGetSoundDeviceCapabilities( IN DWORD CapabilitiesSize); MMRESULT -MmeOpenWaveDevice( +MmeOpenDevice( IN MMDEVICE_TYPE DeviceType, IN UINT DeviceId, IN LPWAVEOPENDESC OpenParameters, diff --git a/reactos/lib/drivers/sound/mmebuddy/capabilities.c b/reactos/lib/drivers/sound/mmebuddy/capabilities.c index c8ff6586a74..edf75990783 100644 --- a/reactos/lib/drivers/sound/mmebuddy/capabilities.c +++ b/reactos/lib/drivers/sound/mmebuddy/capabilities.c @@ -62,32 +62,32 @@ GetSoundDeviceCapabilities( { 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; } }; diff --git a/reactos/lib/drivers/sound/mmebuddy/midi/midMessage.c b/reactos/lib/drivers/sound/mmebuddy/midi/midMessage.c index 9e1a0ec24f6..95738d78d89 100644 --- a/reactos/lib/drivers/sound/mmebuddy/midi/midMessage.c +++ b/reactos/lib/drivers/sound/mmebuddy/midi/midMessage.c @@ -65,6 +65,33 @@ midMessage( 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); diff --git a/reactos/lib/drivers/sound/mmebuddy/midi/modMessage.c b/reactos/lib/drivers/sound/mmebuddy/midi/modMessage.c index febfca516b5..d189b03fd1b 100644 --- a/reactos/lib/drivers/sound/mmebuddy/midi/modMessage.c +++ b/reactos/lib/drivers/sound/mmebuddy/midi/modMessage.c @@ -64,6 +64,24 @@ modMessage( 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); diff --git a/reactos/lib/drivers/sound/mmebuddy/mixer/mxdMessage.c b/reactos/lib/drivers/sound/mmebuddy/mixer/mxdMessage.c index cf870540ba1..08815ba8eee 100644 --- a/reactos/lib/drivers/sound/mmebuddy/mixer/mxdMessage.c +++ b/reactos/lib/drivers/sound/mmebuddy/mixer/mxdMessage.c @@ -52,99 +52,6 @@ MmeGetLineInfo( } -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 @@ mxdMessage( 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; } diff --git a/reactos/lib/drivers/sound/mmebuddy/mmewrap.c b/reactos/lib/drivers/sound/mmebuddy/mmewrap.c index 960c4839a50..583d198ca87 100644 --- a/reactos/lib/drivers/sound/mmebuddy/mmewrap.c +++ b/reactos/lib/drivers/sound/mmebuddy/mmewrap.c @@ -119,7 +119,7 @@ MmeGetSoundDeviceCapabilities( } MMRESULT -MmeOpenWaveDevice( +MmeOpenDevice( IN MMDEVICE_TYPE DeviceType, IN UINT DeviceId, IN LPWAVEOPENDESC OpenParameters, @@ -127,33 +127,36 @@ MmeOpenWaveDevice( 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) ) + if (DeviceType == WAVE_IN_DEVICE_TYPE || DeviceType == WAVE_OUT_DEVICE_TYPE) { - SND_ERR(L"Format not supported\n"); - return TranslateInternalMmResult(Result); - } + Format = OpenParameters->lpFormat; - /* If the caller just wanted to know if a format is supported, end here */ - if ( Flags & WAVE_FORMAT_QUERY ) - return MMSYSERR_NOERROR; + /* 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 @@ MmeOpenWaveDevice( /* 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); + 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 */ - AcquireEntrypointMutex(DeviceType); + 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; - SND_TRACE(L"Wave device now open\n"); + ReleaseEntrypointMutex(DeviceType); + + NotifyMmeClient(SoundDeviceInstance, + Message, + 0); + + AcquireEntrypointMutex(DeviceType); + } + + SND_TRACE(L"device now open\n"); return MMSYSERR_NOERROR; } @@ -201,6 +219,7 @@ MmeCloseDevice( 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 @@ MmeCloseDevice( /* 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); diff --git a/reactos/lib/drivers/sound/mmebuddy/wave/widMessage.c b/reactos/lib/drivers/sound/mmebuddy/wave/widMessage.c index 47825aeccd9..6584d3d7bac 100644 --- a/reactos/lib/drivers/sound/mmebuddy/wave/widMessage.c +++ b/reactos/lib/drivers/sound/mmebuddy/wave/widMessage.c @@ -68,7 +68,7 @@ widMessage( } case WIDM_OPEN : { - Result = MmeOpenWaveDevice(WAVE_IN_DEVICE_TYPE, + Result = MmeOpenDevice(WAVE_IN_DEVICE_TYPE, DeviceId, (LPWAVEOPENDESC) Parameter1, Parameter2, diff --git a/reactos/lib/drivers/sound/mmebuddy/wave/wodMessage.c b/reactos/lib/drivers/sound/mmebuddy/wave/wodMessage.c index 70bd6b70d05..330c5f2aab6 100644 --- a/reactos/lib/drivers/sound/mmebuddy/wave/wodMessage.c +++ b/reactos/lib/drivers/sound/mmebuddy/wave/wodMessage.c @@ -65,11 +65,11 @@ wodMessage( 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; }