Author: silverblade Date: Sun Dec 28 04:53:31 2008 New Revision: 38412
URL: http://svn.reactos.org/svn/reactos?rev=38412&view=rev Log: Misc. code changes I forgot to commit previously. Just wanted to get this into the branch before I do more work on this.
Added: branches/silverblade-audio/lib/drivers/sound/mmebuddy/capabilities.c (with props) branches/silverblade-audio/lib/drivers/sound/mmebuddy/functiontable.c (with props) branches/silverblade-audio/lib/drivers/sound/mmebuddy/wave/format.c (with props) Modified: branches/silverblade-audio/include/reactos/libs/sound/mmebuddy.h branches/silverblade-audio/lib/drivers/sound/mmebuddy/auxiliary/auxMessage.c branches/silverblade-audio/lib/drivers/sound/mmebuddy/deviceinstance.c branches/silverblade-audio/lib/drivers/sound/mmebuddy/midi/midMessage.c branches/silverblade-audio/lib/drivers/sound/mmebuddy/midi/modMessage.c branches/silverblade-audio/lib/drivers/sound/mmebuddy/mixer/mxdMessage.c branches/silverblade-audio/lib/drivers/sound/mmebuddy/wave/widMessage.c branches/silverblade-audio/lib/drivers/sound/mmebuddy/wave/wodMessage.c
Modified: branches/silverblade-audio/include/reactos/libs/sound/mmebuddy.h URL: http://svn.reactos.org/svn/reactos/branches/silverblade-audio/include/reacto... ============================================================================== --- branches/silverblade-audio/include/reactos/libs/sound/mmebuddy.h [iso-8859-1] (original) +++ branches/silverblade-audio/include/reactos/libs/sound/mmebuddy.h [iso-8859-1] Sun Dec 28 04:53:31 2008 @@ -127,6 +127,7 @@
typedef UCHAR MMDEVICE_TYPE, *PMMDEVICE_TYPE; struct _SOUND_DEVICE; +struct _SOUND_DEVICE_INSTANCE;
#define DEFINE_GETCAPS_FUNCTYPE(func_typename, caps_type) \ @@ -144,32 +145,29 @@ DEFINE_GETCAPS_FUNCTYPE(MMGETMIDIOUTCAPS_FUNC, LPMIDIOUTCAPS); DEFINE_GETCAPS_FUNCTYPE(MMGETMIDIINCAPS_FUNC, LPMIDIINCAPS );
+typedef MMRESULT (*MMWAVEQUERYFORMATSUPPORT_FUNC)( + IN struct _SOUND_DEVICE* Device, + IN PWAVEFORMATEX WaveFormat, + IN DWORD WaveFormatSize); + +typedef MMRESULT (*MMWAVESETFORMAT_FUNC)( + IN struct _SOUND_DEVICE_INSTANCE* Instance, + IN PWAVEFORMATEX WaveFormat, + IN DWORD WaveFormatSize); + typedef struct _MMFUNCTION_TABLE { union { - MMGETCAPS_FUNC GetCapabilities; - MMGETWAVEOUTCAPS_FUNC GetWaveOutCapabilities; - MMGETWAVEINCAPS_FUNC GetWaveInCapabilities; - MMGETMIDIOUTCAPS_FUNC GetMidiOutCapabilities; - MMGETMIDIINCAPS_FUNC GetMidiInCapabilities; + MMGETCAPS_FUNC GetCapabilities; + MMGETWAVEOUTCAPS_FUNC GetWaveOutCapabilities; + MMGETWAVEINCAPS_FUNC GetWaveInCapabilities; + MMGETMIDIOUTCAPS_FUNC GetMidiOutCapabilities; + MMGETMIDIINCAPS_FUNC GetMidiInCapabilities; };
-/* - MMCREATEINSTANCE_FUNC Constructor; - MMDESTROYINSTANCE_FUNC Destructor; - MMGETCAPS_FUNC GetCapabilities; - - MMWAVEQUERYFORMAT_FUNC QueryWaveFormat; - MMWAVESETFORMAT_FUNC SetWaveFormat; - MMWAVEQUEUEBUFFER_FUNC QueueWaveBuffer; - - MMGETWAVESTATE_FUNC GetWaveDeviceState; - MMSETWAVESTATE_FUNC PauseWaveDevice; - MMSETWAVESTATE_FUNC RestartWaveDevice; - MMSETWAVESTATE_FUNC ResetWaveDevice; - MMSETWAVESTATE_FUNC BreakWaveDeviceLoop; -*/ + MMWAVEQUERYFORMATSUPPORT_FUNC QueryWaveFormatSupport; + MMWAVESETFORMAT_FUNC SetWaveFormat; } MMFUNCTION_TABLE, *PMMFUNCTION_TABLE;
typedef struct _SOUND_DEVICE @@ -299,6 +297,24 @@ IsValidSoundDeviceInstance( IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance);
+MMRESULT +CreateSoundDeviceInstance( + IN PSOUND_DEVICE SoundDevice, + OUT PSOUND_DEVICE_INSTANCE* SoundDeviceInstance); + +MMRESULT +DestroySoundDeviceInstance( + IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance); + +MMRESULT +DestroyAllSoundDeviceInstances( + IN PSOUND_DEVICE SoundDevice); + +MMRESULT +GetSoundDeviceFromInstance( + IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance, + OUT PSOUND_DEVICE* SoundDevice); +
/* nt4.c @@ -358,6 +374,35 @@ MMRESULT TranslateInternalMmResult( IN MMRESULT Result); + + +/* + wave/format.c +*/ + +MMRESULT +QueryWaveDeviceFormatSupport( + IN PSOUND_DEVICE SoundDevice, + IN LPWAVEFORMATEX Format, + IN DWORD FormatSize); + +MMRESULT +DefaultQueryWaveDeviceFormatSupport( + IN PSOUND_DEVICE SoundDevice, + IN LPWAVEFORMATEX Format, + IN DWORD FormatSize); + +MMRESULT +SetWaveDeviceFormat( + IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance, + IN LPWAVEFORMATEX Format, + IN DWORD FormatSize); + +MMRESULT +DefaultSetWaveDeviceFormat( + IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance, + IN LPWAVEFORMATEX Format, + IN DWORD FormatSize);
/*
Modified: branches/silverblade-audio/lib/drivers/sound/mmebuddy/auxiliary/auxMessage.c URL: http://svn.reactos.org/svn/reactos/branches/silverblade-audio/lib/drivers/so... ============================================================================== --- branches/silverblade-audio/lib/drivers/sound/mmebuddy/auxiliary/auxMessage.c [iso-8859-1] (original) +++ branches/silverblade-audio/lib/drivers/sound/mmebuddy/auxiliary/auxMessage.c [iso-8859-1] Sun Dec 28 04:53:31 2008 @@ -41,7 +41,18 @@ Result = GetSoundDeviceCount(AUX_DEVICE_TYPE); break; } + + case AUXDM_GETDEVCAPS : + { + Result = MmeGetSoundDeviceCapabilities(AUX_DEVICE_TYPE, + DeviceId, + (PVOID) Parameter1, + Parameter2); + break; + } } + + SND_TRACE(L"auxMessage returning MMRESULT %d\n", Result);
ReleaseEntrypointMutex(AUX_DEVICE_TYPE);
Added: branches/silverblade-audio/lib/drivers/sound/mmebuddy/capabilities.c URL: http://svn.reactos.org/svn/reactos/branches/silverblade-audio/lib/drivers/so... ============================================================================== --- branches/silverblade-audio/lib/drivers/sound/mmebuddy/capabilities.c (added) +++ branches/silverblade-audio/lib/drivers/sound/mmebuddy/capabilities.c [iso-8859-1] Sun Dec 28 04:53:31 2008 @@ -1,0 +1,207 @@ +/* + * PROJECT: ReactOS Sound System "MME Buddy" Library + * LICENSE: GPL - See COPYING in the top level directory + * FILE: lib/sound/mmebuddy/capabilities.c + * + * PURPOSE: Queries sound devices for their capabilities. + * + * PROGRAMMERS: Andrew Greenwood (silverblade@reactos.org) +*/ + +#include <windows.h> +#include <mmsystem.h> +#include <ntddk.h> +#include <ntddsnd.h> +#include <mmebuddy.h> + +/* + This is a helper function to alleviate some of the repetition involved with + implementing the various MME message functions. +*/ +MMRESULT +MmeGetSoundDeviceCapabilities( + IN MMDEVICE_TYPE DeviceType, + IN DWORD DeviceId, + IN PVOID Capabilities, + IN DWORD CapabilitiesSize) +{ + PSOUND_DEVICE SoundDevice; + MMRESULT Result; + + SND_TRACE(L"MME *_GETCAPS for device %d of type %d\n", DeviceId, DeviceType); + + /* Our parameter checks are done elsewhere */ + Result = GetSoundDevice(DeviceType, DeviceId, &SoundDevice); + + if ( Result != MMSYSERR_NOERROR ) + return Result; + + return GetSoundDeviceCapabilities(SoundDevice, + Capabilities, + CapabilitiesSize); +} + +/* + Obtains the capabilities of a sound device. This routine ensures that the + supplied CapabilitiesSize parameter at least meets the minimum size of the + relevant capabilities structure. + + Ultimately, it will call the GetCapabilities function specified in the + sound device's function table. Note that there are several of these, in a + union. This is simply to avoid manually typecasting when implementing the + functions. +*/ +MMRESULT +GetSoundDeviceCapabilities( + IN PSOUND_DEVICE SoundDevice, + OUT PVOID Capabilities, + IN DWORD CapabilitiesSize) +{ + MMDEVICE_TYPE DeviceType; + PMMFUNCTION_TABLE FunctionTable; + BOOLEAN GoodSize = FALSE; + MMRESULT Result; + + VALIDATE_MMSYS_PARAMETER( IsValidSoundDevice(SoundDevice) ); + VALIDATE_MMSYS_PARAMETER( Capabilities ); + VALIDATE_MMSYS_PARAMETER( CapabilitiesSize > 0 ); + + /* Obtain the device type */ + Result = GetSoundDeviceType(SoundDevice, &DeviceType); + SND_ASSERT( Result == MMSYSERR_NOERROR ); + + if ( Result != MMSYSERR_NOERROR ) + return TranslateInternalMmResult(Result); + + /* Obtain the function table */ + Result = GetSoundDeviceFunctionTable(SoundDevice, &FunctionTable); + SND_ASSERT( Result == MMSYSERR_NOERROR ); + + if ( Result != MMSYSERR_NOERROR ) + return TranslateInternalMmResult(Result); + + /* Check that the capabilities structure is of a valid size */ + switch ( DeviceType ) + { + case WAVE_OUT_DEVICE_TYPE : + { + GoodSize = CapabilitiesSize >= sizeof(WAVEOUTCAPS); + break; + } + case WAVE_IN_DEVICE_TYPE : + { + GoodSize = CapabilitiesSize >= sizeof(WAVEINCAPS); + break; + } + case MIDI_OUT_DEVICE_TYPE : + { + GoodSize = CapabilitiesSize >= sizeof(MIDIOUTCAPS); + break; + } + case MIDI_IN_DEVICE_TYPE : + { + GoodSize = CapabilitiesSize >= sizeof(MIDIINCAPS); + break; + } + /* TODO: Others... */ + default : + { + SND_ASSERT(FALSE); + } + }; + + if ( ! GoodSize ) + { + SND_ERR(L"Device capabilities structure too small\n"); + return MMSYSERR_INVALPARAM; + } + + /* Call the "get capabilities" function within the function table */ + SND_ASSERT( FunctionTable->GetCapabilities ); + + if ( ! FunctionTable->GetCapabilities ) + return MMSYSERR_NOTSUPPORTED; + + return FunctionTable->GetCapabilities(SoundDevice, + Capabilities, + CapabilitiesSize); +} + +/* + Provides a default implementation for the "get capabilities" request, + using the standard IOCTLs used by NT4 sound drivers. +*/ +MMRESULT +DefaultGetSoundDeviceCapabilities( + IN PSOUND_DEVICE SoundDevice, + OUT PVOID Capabilities, + IN DWORD CapabilitiesSize) +{ + MMRESULT Result; + MMDEVICE_TYPE DeviceType; + PWSTR DevicePath; + DWORD IoCtl; + DWORD BytesTransferred; + HANDLE DeviceHandle; + + /* If these are bad there's an internal error with MME-Buddy! */ + SND_ASSERT( SoundDevice ); + SND_ASSERT( Capabilities ); + SND_ASSERT( CapabilitiesSize > 0 ); + + SND_TRACE(L"Default get-capabilities routine called\n"); + + /* Get the device type */ + Result = GetSoundDeviceType(SoundDevice, &DeviceType); + SND_ASSERT( Result == MMSYSERR_NOERROR ); + + if ( Result != MMSYSERR_NOERROR ); + return TranslateInternalMmResult(Result); + + /* Get the device path */ + Result = GetSoundDevicePath(SoundDevice, &DevicePath); + SND_ASSERT( Result == MMSYSERR_NOERROR ); + + if ( Result != MMSYSERR_NOERROR ); + return TranslateInternalMmResult(Result); + + /* Choose the appropriate IOCTL */ + if ( IS_WAVE_DEVICE_TYPE(DeviceType) ) + { + IoCtl = IOCTL_WAVE_GET_CAPABILITIES; + } + else if ( IS_MIDI_DEVICE_TYPE(DeviceType) ) + { + IoCtl = IOCTL_MIDI_GET_CAPABILITIES; + } + else + { + /* TODO */ + SND_ASSERT( FALSE ); + } + + /* Get the capabilities information from the driver */ + Result = OpenKernelSoundDeviceByName(DevicePath, TRUE, &DeviceHandle); + + if ( Result != MMSYSERR_NOERROR ) + { + SND_ERR(L"Failed to open %wS\n", DevicePath); + return TranslateInternalMmResult(Result); + } + + Result = QueryDevice(DeviceHandle, + IoCtl, + Capabilities, + CapabilitiesSize, + &BytesTransferred, + NULL); + + CloseKernelSoundDevice(DeviceHandle); + + if ( Result != MMSYSERR_NOERROR ) + { + SND_ERR(L"Retrieval of capabilities information failed\n"); + } + + return Result; +}
Propchange: branches/silverblade-audio/lib/drivers/sound/mmebuddy/capabilities.c ------------------------------------------------------------------------------ svn:eol-style = native
Modified: branches/silverblade-audio/lib/drivers/sound/mmebuddy/deviceinstance.c URL: http://svn.reactos.org/svn/reactos/branches/silverblade-audio/lib/drivers/so... ============================================================================== --- branches/silverblade-audio/lib/drivers/sound/mmebuddy/deviceinstance.c [iso-8859-1] (original) +++ branches/silverblade-audio/lib/drivers/sound/mmebuddy/deviceinstance.c [iso-8859-1] Sun Dec 28 04:53:31 2008 @@ -9,12 +9,86 @@ */
#include <windows.h> +#include <mmsystem.h> #include <mmebuddy.h> + +MMRESULT +AllocateSoundDeviceInstance( + OUT PSOUND_DEVICE_INSTANCE* SoundDeviceInstance) +{ + PSOUND_DEVICE_INSTANCE NewInstance; + + VALIDATE_MMSYS_PARAMETER( SoundDeviceInstance ); + + /* Allocate memory for the new instance */ + NewInstance = AllocateStruct(SOUND_DEVICE_INSTANCE); + + if ( ! NewInstance ) + return MMSYSERR_NOMEM; + + /* Provide the caller with the new instance pointer */ + *SoundDeviceInstance = NewInstance; + + return MMSYSERR_NOERROR; +} + +VOID +FreeSoundDeviceInstance( + IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance) +{ + SND_ASSERT( SoundDeviceInstance ); + FreeMemory(SoundDeviceInstance); +}
BOOLEAN IsValidSoundDeviceInstance( IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance) { - /* TODO */ - return TRUE; + /* TODO - do this better */ + return ( SoundDeviceInstance != NULL ); } + +MMRESULT +ListSoundDeviceInstance( + IN PSOUND_DEVICE SoundDevice, + IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance) +{ + return MMSYSERR_NOTSUPPORTED; +} + +MMRESULT +UnlistSoundDeviceInstance( + IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance) +{ + return MMSYSERR_NOTSUPPORTED; +} + +MMRESULT +CreateSoundDeviceInstance( + IN PSOUND_DEVICE SoundDevice, + OUT PSOUND_DEVICE_INSTANCE* SoundDeviceInstance) +{ + return MMSYSERR_NOTSUPPORTED; +} + +MMRESULT +DestroySoundDeviceInstance( + IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance) +{ + return MMSYSERR_NOTSUPPORTED; +} + +MMRESULT +DestroyAllSoundDeviceInstances( + IN PSOUND_DEVICE SoundDevice) +{ + return MMSYSERR_NOTSUPPORTED; +} + +MMRESULT +GetSoundDeviceFromInstance( + IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance, + OUT PSOUND_DEVICE* SoundDevice) +{ + return MMSYSERR_NOTSUPPORTED; +}
Added: branches/silverblade-audio/lib/drivers/sound/mmebuddy/functiontable.c URL: http://svn.reactos.org/svn/reactos/branches/silverblade-audio/lib/drivers/so... ============================================================================== --- branches/silverblade-audio/lib/drivers/sound/mmebuddy/functiontable.c (added) +++ branches/silverblade-audio/lib/drivers/sound/mmebuddy/functiontable.c [iso-8859-1] Sun Dec 28 04:53:31 2008 @@ -1,0 +1,78 @@ +/* + * PROJECT: ReactOS Sound System "MME Buddy" Library + * LICENSE: GPL - See COPYING in the top level directory + * FILE: lib/sound/mmebuddy/functiontable.c + * + * PURPOSE: Routes function calls through a function table, calling + * implementation-defined routines or a default function, depending + * on configuration. + * + * PROGRAMMERS: Andrew Greenwood (silverblade@reactos.org) +*/ + +#include <windows.h> +#include <mmebuddy.h> + +/* + Attaches a function table to a sound device. Any NULL entries in this + table are automatically set to point to a default routine to handle + the appropriate function. If NULL is passed as the function table itself, + the entire function table will use only the default routines. +*/ +MMRESULT +SetSoundDeviceFunctionTable( + IN PSOUND_DEVICE SoundDevice, + IN PMMFUNCTION_TABLE FunctionTable OPTIONAL) +{ + VALIDATE_MMSYS_PARAMETER( IsValidSoundDevice(SoundDevice) ); + /*VALIDATE_MMSYS_PARAMETER( FunctionTable );*/ + + /* Zero out the existing function table (if present) */ + ZeroMemory(&SoundDevice->FunctionTable, sizeof(MMFUNCTION_TABLE)); + + /* Fill in the client-supplied functions, if provided */ + if ( FunctionTable ) + { + CopyMemory(&SoundDevice->FunctionTable, + FunctionTable, + sizeof(MMFUNCTION_TABLE)); + } + + /* Plug any gaps in the function table */ + if ( ! SoundDevice->FunctionTable.GetCapabilities ) + { + SoundDevice->FunctionTable.GetCapabilities = + DefaultGetSoundDeviceCapabilities; + } + + if ( ! SoundDevice->FunctionTable.QueryWaveFormatSupport ) + { + SoundDevice->FunctionTable.QueryWaveFormatSupport = + DefaultQueryWaveDeviceFormatSupport; + } + + if ( ! SoundDevice->FunctionTable.SetWaveFormat ) + { + SoundDevice->FunctionTable.SetWaveFormat = + DefaultSetWaveDeviceFormat; + } + + return MMSYSERR_NOERROR; +} + +/* + Retrieves the function table for a sound device, as previously set using + SetSoundDeviceFunctionTable. +*/ +MMRESULT +GetSoundDeviceFunctionTable( + IN PSOUND_DEVICE SoundDevice, + OUT PMMFUNCTION_TABLE* FunctionTable) +{ + VALIDATE_MMSYS_PARAMETER( IsValidSoundDevice(SoundDevice) ); + VALIDATE_MMSYS_PARAMETER( FunctionTable ); + + *FunctionTable = &SoundDevice->FunctionTable; + + return MMSYSERR_NOERROR; +}
Propchange: branches/silverblade-audio/lib/drivers/sound/mmebuddy/functiontable.c ------------------------------------------------------------------------------ svn:eol-style = native
Modified: branches/silverblade-audio/lib/drivers/sound/mmebuddy/midi/midMessage.c URL: http://svn.reactos.org/svn/reactos/branches/silverblade-audio/lib/drivers/so... ============================================================================== --- branches/silverblade-audio/lib/drivers/sound/mmebuddy/midi/midMessage.c [iso-8859-1] (original) +++ branches/silverblade-audio/lib/drivers/sound/mmebuddy/midi/midMessage.c [iso-8859-1] Sun Dec 28 04:53:31 2008 @@ -41,7 +41,18 @@ Result = GetSoundDeviceCount(MIDI_IN_DEVICE_TYPE); break; } + + case MIDM_GETDEVCAPS : + { + Result = MmeGetSoundDeviceCapabilities(MIDI_IN_DEVICE_TYPE, + DeviceId, + (PVOID) Parameter1, + Parameter2); + break; + } } + + SND_TRACE(L"midMessage returning MMRESULT %d\n", Result);
ReleaseEntrypointMutex(MIDI_IN_DEVICE_TYPE);
Modified: branches/silverblade-audio/lib/drivers/sound/mmebuddy/midi/modMessage.c URL: http://svn.reactos.org/svn/reactos/branches/silverblade-audio/lib/drivers/so... ============================================================================== --- branches/silverblade-audio/lib/drivers/sound/mmebuddy/midi/modMessage.c [iso-8859-1] (original) +++ branches/silverblade-audio/lib/drivers/sound/mmebuddy/midi/modMessage.c [iso-8859-1] Sun Dec 28 04:53:31 2008 @@ -41,7 +41,18 @@ Result = GetSoundDeviceCount(MIDI_OUT_DEVICE_TYPE); break; } + + case MODM_GETDEVCAPS : + { + Result = MmeGetSoundDeviceCapabilities(MIDI_OUT_DEVICE_TYPE, + DeviceId, + (PVOID) Parameter1, + Parameter2); + break; + } } + + SND_TRACE(L"modMessage returning MMRESULT %d\n", Result);
ReleaseEntrypointMutex(MIDI_OUT_DEVICE_TYPE);
Modified: branches/silverblade-audio/lib/drivers/sound/mmebuddy/mixer/mxdMessage.c URL: http://svn.reactos.org/svn/reactos/branches/silverblade-audio/lib/drivers/so... ============================================================================== --- branches/silverblade-audio/lib/drivers/sound/mmebuddy/mixer/mxdMessage.c [iso-8859-1] (original) +++ branches/silverblade-audio/lib/drivers/sound/mmebuddy/mixer/mxdMessage.c [iso-8859-1] Sun Dec 28 04:53:31 2008 @@ -41,7 +41,18 @@ Result = GetSoundDeviceCount(MIXER_DEVICE_TYPE); break; } + + case MXDM_GETDEVCAPS : + { + Result = MmeGetSoundDeviceCapabilities(MIXER_DEVICE_TYPE, + DeviceId, + (PVOID) Parameter1, + Parameter2); + break; + } } + + SND_TRACE(L"mxdMessage returning MMRESULT %d\n", Result);
ReleaseEntrypointMutex(MIXER_DEVICE_TYPE);
Added: branches/silverblade-audio/lib/drivers/sound/mmebuddy/wave/format.c URL: http://svn.reactos.org/svn/reactos/branches/silverblade-audio/lib/drivers/so... ============================================================================== --- branches/silverblade-audio/lib/drivers/sound/mmebuddy/wave/format.c (added) +++ branches/silverblade-audio/lib/drivers/sound/mmebuddy/wave/format.c [iso-8859-1] Sun Dec 28 04:53:31 2008 @@ -1,0 +1,59 @@ +/* + * PROJECT: ReactOS Sound System "MME Buddy" Library + * LICENSE: GPL - See COPYING in the top level directory + * FILE: lib/sound/mmebuddy/wave/format.c + * + * PURPOSE: Queries and sets wave device format (sample rate, etc.) + * + * PROGRAMMERS: Andrew Greenwood (silverblade@reactos.org) +*/ + +#include <windows.h> +#include <mmsystem.h> +#include <ntddk.h> +#include <ntddsnd.h> +#include <mmebuddy.h> + +MMRESULT +QueryWaveDeviceFormatSupport( + IN PSOUND_DEVICE SoundDevice, + IN LPWAVEFORMATEX Format, + IN DWORD FormatSize) +{ + MMRESULT Result; + MMDEVICE_TYPE DeviceType; + MMFUNCTION_TABLE FunctionTable; + + SND_TRACE(L"Querying wave format support\n"); + + VALIDATE_MMSYS_PARAMETER( IsValidSoundDevice(SoundDevice) ); + VALIDATE_MMSYS_PARAMETER( Format ); + VALIDATE_MMSYS_PARAMETER( FormatSize >= sizeof(WAVEFORMATEX) ); + + Result = GetSoundDeviceType(SoundDevice, &DeviceType); + SND_ASSERT( Result == MMSYSERR_NOERROR ); + + /* Ensure we have a wave device (TODO: check if wavein as well) */ + VALIDATE_MMSYS_PARAMETER( IS_WAVE_DEVICE_TYPE(DeviceType) ); + + /* Obtain the function table */ + Result = GetSoundDeviceFunctionTable(SoundDevice, &FunctionTable); + SND_ASSERT( Result == MMSYSERR_NOERROR ); + + if ( Result != MMSYSERR_NOERROR ) + return TranslateInternalMmResult(Result); + + SND_ASSERT( FunctionTable->QueryWaveFormatSupport ); + + return FunctionTable->QueryWaveFormatSupport(SoundDevice, Format, FormatSize); +} + +MMRESULT +SetWaveDeviceFormat( + IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance, + IN LPWAVEFORMATEX Format, + IN DWORD FormatSize) +{ + SND_TRACE(L"Setting wave format\n"); + return MMSYSERR_NOTSUPPORTED; +}
Propchange: branches/silverblade-audio/lib/drivers/sound/mmebuddy/wave/format.c ------------------------------------------------------------------------------ svn:eol-style = native
Modified: branches/silverblade-audio/lib/drivers/sound/mmebuddy/wave/widMessage.c URL: http://svn.reactos.org/svn/reactos/branches/silverblade-audio/lib/drivers/so... ============================================================================== --- branches/silverblade-audio/lib/drivers/sound/mmebuddy/wave/widMessage.c [iso-8859-1] (original) +++ branches/silverblade-audio/lib/drivers/sound/mmebuddy/wave/widMessage.c [iso-8859-1] Sun Dec 28 04:53:31 2008 @@ -53,6 +53,8 @@ } }
+ SND_TRACE(L"widMessage returning MMRESULT %d\n", Result); + ReleaseEntrypointMutex(WAVE_IN_DEVICE_TYPE);
return Result;
Modified: branches/silverblade-audio/lib/drivers/sound/mmebuddy/wave/wodMessage.c URL: http://svn.reactos.org/svn/reactos/branches/silverblade-audio/lib/drivers/so... ============================================================================== --- branches/silverblade-audio/lib/drivers/sound/mmebuddy/wave/wodMessage.c [iso-8859-1] (original) +++ branches/silverblade-audio/lib/drivers/sound/mmebuddy/wave/wodMessage.c [iso-8859-1] Sun Dec 28 04:53:31 2008 @@ -51,7 +51,71 @@ Parameter2); break; } + + case WODM_OPEN : + { + PSOUND_DEVICE SoundDevice; + PSOUND_DEVICE_INSTANCE SoundDeviceInstance; + LPWAVEOPENDESC OpenParameters = (LPWAVEOPENDESC) Parameter1; + + /* Obtain the sound device */ + Result = GetSoundDevice(WAVE_OUT_DEVICE_TYPE, DeviceId, &SoundDevice); + + if ( Result != MMSYSERR_NOERROR ); + break; + + /* See if the device supports this format */ + Result = QueryWaveDeviceFormatSupport(SoundDevice, + OpenParameters->lpFormat, + sizeof(WAVEFORMATEX)); + + if ( Parameter2 & WAVE_FORMAT_QUERY ) + { + /* Nothing more to be done - keep the result */ + break; + } + + /* The MME API should provide us with a place to store a handle */ + SND_ASSERT( PrivateHandle ); + if ( ! PrivateHandle ) + { + /* Not so much an invalid parameter as something messed up!! */ + SND_ERR(L"MME API supplied a NULL private handle pointer!\n"); + Result = MMSYSERR_ERROR; + break; + } + + /* Spawn an instance of the sound device */ + Result = CreateSoundDeviceInstance(SoundDevice, &SoundDeviceInstance); + + if ( Result != MMSYSERR_NOERROR ) + { + SND_ERR(L"Failed to create sound device instance\n"); + break; + } + + /* Set the sample rate, bits per sample, etc. */ + Result = SetWaveDeviceFormat(SoundDeviceInstance, + OpenParameters->lpFormat, + sizeof(WAVEFORMATEX)); + + if ( Result != MMSYSERR_NOERROR ) + { + SND_ERR(L"Failed to set wave device format\n"); + DestroySoundDeviceInstance(SoundDeviceInstance); + break; + } + + break; + } + + case WODM_CLOSE : + { + break; + } } + + SND_TRACE(L"wodMessage returning MMRESULT %d\n", Result);
ReleaseEntrypointMutex(WAVE_OUT_DEVICE_TYPE);