20#ifndef ROS_AUDIO_MMEBUDDY_H
21#define ROS_AUDIO_MMEBUDDY_H
27#define AllocateStruct(thing) \
28 (thing*) AllocateMemory(sizeof(thing))
30#define StringLengthToBytes(chartype, string_length) \
31 ( ( string_length + 1 ) * sizeof(chartype) )
33#define AllocateWideString(string_length) \
34 (PWSTR) AllocateMemory(StringLengthToBytes(WCHAR, string_length))
36#define ZeroWideString(string) \
37 ZeroMemory(string, StringLengthToBytes(WCHAR, wcslen(string)))
39#define CopyWideString(dest, source) \
40 CopyMemory(dest, source, StringLengthToBytes(WCHAR, wcslen(source)))
47#define MinimumOf(value_a, value_b) \
48 ( value_a < value_b ? value_a : value_b )
50#define MaximumOf(value_a, value_b) \
51 ( value_a > value_b ? value_a : value_b )
58#define SOUND_DEVICE_TYPE_TO_INDEX(x) \
59 ( x - MIN_SOUND_DEVICE_TYPE )
61#define INDEX_TO_SOUND_DEVICE_TYPE(x) \
62 ( x + MIN_SOUND_DEVICE_TYPE )
69#define IsValidSoundDeviceType IS_VALID_SOUND_DEVICE_TYPE
71#define VALIDATE_MMSYS_PARAMETER(parameter_condition) \
73 if ( ! (parameter_condition) ) \
75 SND_ERR(L"FAILED parameter check: %hS at File %S Line %lu\n", #parameter_condition, __FILE__, __LINE__); \
76 return MMSYSERR_INVALPARAM; \
80#define MMSUCCESS(result) \
81 ( result == MMSYSERR_NOERROR )
93#define DEFINE_GETCAPS_FUNCTYPE(func_typename, caps_type) \
94 typedef MMRESULT (*func_typename)( \
95 IN struct _SOUND_DEVICE* SoundDevice, \
97 OUT caps_type Capabilities, \
98 IN DWORD CapabilitiesSize);
414#define MmePrepareWaveHeader(private_handle, header) \
415 PrepareWaveHeader((PSOUND_DEVICE_INSTANCE)private_handle, (PWAVEHDR)header)
417#define MmeUnprepareWaveHeader(private_handle, header) \
418 UnprepareWaveHeader((PSOUND_DEVICE_INSTANCE)private_handle, (PWAVEHDR)header)
420#define MmeWriteWaveHeader(private_handle, header) \
421 WriteWaveHeader((PSOUND_DEVICE_INSTANCE)private_handle, (PWAVEHDR)header)
648 IN DWORD dwNumberOfBytesTransferred,
static const WCHAR Message[]
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
_Must_inspect_result_ typedef _Out_ PHIDP_CAPS Capabilities
struct _WAVEHDR_EXTENSION * PWAVEHDR_EXTENSION
struct _MMFUNCTION_TABLE MMFUNCTION_TABLE
MMRESULT(* MMSETSTATE_FUNC)(IN struct _SOUND_DEVICE_INSTANCE *SoundDeviceInstance, IN BOOL bStart)
MMRESULT UnlistSoundDevice(IN MMDEVICE_TYPE DeviceType, IN PSOUND_DEVICE SoundDevice)
BOOLEAN IsValidSoundDevice(IN PSOUND_DEVICE SoundDevice)
MMRESULT DestroyAllSoundDeviceInstances(IN PSOUND_DEVICE SoundDevice)
MMRESULT ListSoundDevice(IN MMDEVICE_TYPE DeviceType, IN PVOID Identifier OPTIONAL, OUT PSOUND_DEVICE *SoundDevice OPTIONAL)
MMRESULT MmeOpenDevice(IN MMDEVICE_TYPE DeviceType, IN UINT DeviceId, IN LPWAVEOPENDESC OpenParameters, IN DWORD Flags, OUT DWORD_PTR *PrivateHandle)
MMRESULT WriteFileEx_Committer(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance, IN PVOID OffsetPtr, IN DWORD Length, IN PSOUND_OVERLAPPED Overlap, IN LPOVERLAPPED_COMPLETION_ROUTINE CompletionRoutine)
MMRESULT CreateSoundThread(OUT PSOUND_THREAD *Thread)
MMRESULT(* MMGETPOS_FUNC)(IN struct _SOUND_DEVICE_INSTANCE *SoundDeviceInstance, IN MMTIME *Time)
MMRESULT MmeCloseDevice(IN DWORD_PTR PrivateHandle)
struct _SOUND_DEVICE_INSTANCE * PSOUND_DEVICE_INSTANCE
MMRESULT(* MMOPEN_FUNC)(IN struct _SOUND_DEVICE *SoundDevice, OUT PVOID *Handle)
MMRESULT(* MMWAVESETFORMAT_FUNC)(IN struct _SOUND_DEVICE_INSTANCE *Instance, IN DWORD DeviceId, IN PWAVEFORMATEX WaveFormat, IN DWORD WaveFormatSize)
VOID DoWaveStreaming(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance)
struct _SOUND_OVERLAPPED * PSOUND_OVERLAPPED
MMRESULT(* MMCLOSE_FUNC)(IN struct _SOUND_DEVICE_INSTANCE *SoundDeviceInstance, IN PVOID Handle)
VOID AcquireEntrypointMutex(IN MMDEVICE_TYPE DeviceType)
MMRESULT(* MMSETVOLUME_FUNC)(_In_ struct _SOUND_DEVICE_INSTANCE *SoundDeviceInstance, _In_ DWORD DeviceId, _In_ DWORD dwVolume)
ULONG GetSoundDeviceCount(IN MMDEVICE_TYPE DeviceType)
MMRESULT OpenKernelSoundDeviceByName(IN PWSTR DevicePath, IN BOOLEAN ReadOnly, OUT PHANDLE Handle)
MMRESULT CallSoundThread(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance, IN SOUND_THREAD_REQUEST_HANDLER RequestHandler, IN PVOID Parameter OPTIONAL)
MMRESULT MmeGetDeviceInterfaceString(IN MMDEVICE_TYPE DeviceType, IN DWORD DeviceId, IN LPWSTR Interface, IN DWORD InterfaceLength, OUT DWORD *InterfaceSize)
MMRESULT SetSoundDeviceInstanceMmeData(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance, IN HDRVR MmeHandle, IN DWORD_PTR ClientCallback, IN DWORD_PTR ClientCallbackData, IN DWORD Flags)
MMRESULT EnqueueWaveHeader(PSOUND_DEVICE_INSTANCE SoundDeviceInstance, IN PVOID Parameter)
PVOID AllocateMemory(IN UINT Size)
MMRESULT MmeGetPosition(IN MMDEVICE_TYPE DeviceType, IN DWORD DeviceId, IN DWORD_PTR PrivateHandle, IN MMTIME *Time, IN DWORD Size)
VOID InitiateSoundStreaming(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance)
MMRESULT GetSoundDeviceCapabilities(IN PSOUND_DEVICE SoundDevice, IN DWORD DeviceId, OUT PVOID Capabilities, IN DWORD CapabilitiesSize)
MMRESULT GetSoundDeviceFunctionTable(IN PSOUND_DEVICE SoundDevice, OUT PMMFUNCTION_TABLE *FunctionTable)
MMRESULT MmeSetState(IN DWORD_PTR PrivateHandle, IN BOOL bStart)
MMRESULT(* WAVE_COMMIT_FUNC)(IN struct _SOUND_DEVICE_INSTANCE *SoundDeviceInstance, IN PVOID OffsetPtr, IN DWORD Bytes, IN PSOUND_OVERLAPPED Overlap, IN LPOVERLAPPED_COMPLETION_ROUTINE CompletionRoutine)
VOID NotifyMmeClient(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance, IN UINT Message, IN DWORD_PTR Parameter)
struct _SOUND_THREAD * PSOUND_THREAD
MMRESULT MmeResetWavePlayback(IN DWORD_PTR PrivateHandle)
MMRESULT SetWaveDeviceFormat(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance, IN DWORD DeviceId, IN LPWAVEFORMATEX Format, IN DWORD FormatSize)
struct _SOUND_DEVICE * PSOUND_DEVICE
MMRESULT StopStreaming(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance)
MMRESULT CommitWaveHeaderToKernelDevice(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance, IN PWAVEHDR Header, IN WAVE_COMMIT_FUNC CommitFunction)
MMRESULT MmeGetVolume(_In_ MMDEVICE_TYPE DeviceType, _In_ DWORD DeviceId, _In_ DWORD_PTR PrivateHandle, _Out_ DWORD_PTR pdwVolume)
MMRESULT SetSoundDeviceFunctionTable(IN PSOUND_DEVICE SoundDevice, IN PMMFUNCTION_TABLE FunctionTable)
MMRESULT(* MMQUERYDEVICEINTERFACESTRING_FUNC)(IN MMDEVICE_TYPE DeviceType, IN DWORD DeviceId, IN LPWSTR Interface, IN DWORD InterfaceLength, OUT DWORD *InterfaceSize)
MMRESULT UnlistSoundDevices(IN MMDEVICE_TYPE DeviceType)
MMRESULT WriteWaveHeader(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance, IN PWAVEHDR Header)
MMRESULT SyncOverlappedDeviceIoControl(IN HANDLE SoundDeviceInstance, IN DWORD IoControlCode, IN LPVOID InBuffer, IN DWORD InBufferSize, OUT LPVOID OutBuffer, IN DWORD OutBufferSize, OUT LPDWORD BytesTransferred OPTIONAL)
MMRESULT GetSoundDeviceFromInstance(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance, OUT PSOUND_DEVICE *SoundDevice)
MMRESULT CloseKernelSoundDevice(IN HANDLE Handle)
MMRESULT(* MMGETVOLUME_FUNC)(_In_ struct _SOUND_DEVICE_INSTANCE *SoundDeviceInstance, _In_ DWORD DeviceId, _Out_ PDWORD pdwVolume)
MMRESULT DestroySoundThread(IN PSOUND_THREAD Thread)
struct _MMFUNCTION_TABLE * PMMFUNCTION_TABLE
MMRESULT UnprepareWaveHeader(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance, IN PWAVEHDR Header)
struct _SOUND_DEVICE SOUND_DEVICE
MMRESULT PrepareWaveHeader(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance, IN PWAVEHDR Header)
MMRESULT(* MMBUFFER_FUNC)(IN struct _SOUND_DEVICE_INSTANCE *SoundDeviceInstance, IN PVOID Buffer, IN DWORD Length)
MMRESULT TranslateInternalMmResult(IN MMRESULT Result)
UINT GetDigitCount(IN UINT Number)
MMRESULT GetSoundDeviceInstanceHandle(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance, OUT PVOID *Handle)
MMRESULT GetSoundDeviceIdentifier(IN PSOUND_DEVICE SoundDevice, OUT PVOID *Identifier)
MMRESULT DestroySoundDeviceInstance(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance)
VOID FreeMemory(IN PVOID Pointer)
VOID CALLBACK CompleteIO(IN DWORD dwErrorCode, IN DWORD dwNumberOfBytesTransferred, IN LPOVERLAPPED lpOverlapped)
MMRESULT GetSoundDeviceType(IN PSOUND_DEVICE SoundDevice, OUT PMMDEVICE_TYPE DeviceType)
MMRESULT(* MMWAVEHEADER_FUNC)(IN struct _SOUND_DEVICE_INSTANCE *SoundDeviceInstance, IN PWAVEHDR WaveHeader)
#define DEFINE_GETCAPS_FUNCTYPE(func_typename, caps_type)
struct _SOUND_THREAD SOUND_THREAD
struct _SOUND_DEVICE_INSTANCE SOUND_DEVICE_INSTANCE
MMRESULT QueryWaveDeviceFormatSupport(IN PSOUND_DEVICE SoundDevice, IN LPWAVEFORMATEX Format, IN DWORD FormatSize)
MMRESULT(* SOUND_THREAD_REQUEST_HANDLER)(IN struct _SOUND_DEVICE_INSTANCE *SoundDeviceInstance, IN PVOID Parameter)
VOID CompleteWaveHeader(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance, IN PWAVEHDR Header)
BOOLEAN IsValidSoundDeviceInstance(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance)
MMRESULT OpenKernelSoundDevice(IN PSOUND_DEVICE SoundDevice, IN BOOLEAN ReadOnly, OUT PHANDLE Handle)
VOID ReleaseEntrypointMutex(IN MMDEVICE_TYPE DeviceType)
struct _SOUND_OVERLAPPED SOUND_OVERLAPPED
MMRESULT MmeGetSoundDeviceCapabilities(IN MMDEVICE_TYPE DeviceType, IN DWORD DeviceId, IN PVOID Capabilities, IN DWORD CapabilitiesSize)
MMRESULT(* MMMIXERQUERY_FUNC)(IN struct _SOUND_DEVICE_INSTANCE *SoundDeviceInstance, IN DWORD DeviceId, IN UINT uMsg, IN LPVOID Parameter, IN DWORD Flags)
MMRESULT(* MMWAVEQUERYFORMATSUPPORT_FUNC)(IN struct _SOUND_DEVICE *Device, IN PWAVEFORMATEX WaveFormat, IN DWORD WaveFormatSize)
MMRESULT(* MMRESETSTREAM_FUNC)(IN struct _SOUND_DEVICE_INSTANCE *SoundDeviceInstance, IN MMDEVICE_TYPE DeviceType, IN BOOLEAN bStartReset)
MMRESULT MmeSetVolume(_In_ MMDEVICE_TYPE DeviceType, _In_ DWORD DeviceId, _In_ DWORD_PTR PrivateHandle, _In_ DWORD_PTR dwVolume)
MMRESULT CreateSoundDeviceInstance(IN PSOUND_DEVICE SoundDevice, OUT PSOUND_DEVICE_INSTANCE *SoundDeviceInstance)
MMRESULT GetSoundDevice(IN MMDEVICE_TYPE DeviceType, IN DWORD DeviceIndex, OUT PSOUND_DEVICE *Device)
struct _WAVEHDR_EXTENSION WAVEHDR_EXTENSION
MMRESULT Win32ErrorToMmResult(IN UINT ErrorCode)
static PLARGE_INTEGER Time
_In_ HANDLE _In_ DWORD _In_ DWORD _Inout_opt_ LPOVERLAPPED lpOverlapped
_In_ NDIS_ERROR_CODE ErrorCode
_In_ ULONG _In_ ULONG _In_ ULONG Length
_In_opt_ PENTER_STATE_SYSTEM_HANDLER _In_opt_ PVOID _In_ LONG _In_opt_ LONG volatile * Number
VOID CleanupEntrypointMutexes()
MMRESULT InitEntrypointMutexes()
_In_ UCHAR _In_ ULONG _Out_ PUCHAR _Outptr_result_bytebuffer_ OutBufferLength PVOID * OutBuffer
VOID UnlistAllSoundDevices()
UINT GetMemoryAllocationCount()
PULONG MinorVersion OPTIONAL
MMGETMIDIINCAPS_FUNC GetMidiInCapabilities
MMGETVOLUME_FUNC GetVolume
MMGETMIDIOUTCAPS_FUNC GetMidiOutCapabilities
MMRESETSTREAM_FUNC ResetStream
MMGETCAPS_FUNC GetCapabilities
MMWAVEQUERYFORMATSUPPORT_FUNC QueryWaveFormatSupport
WAVE_COMMIT_FUNC CommitWaveBuffer
MMGETWAVEOUTCAPS_FUNC GetWaveOutCapabilities
MMWAVESETFORMAT_FUNC SetWaveFormat
MMMIXERQUERY_FUNC QueryMixerInfo
MMSETVOLUME_FUNC SetVolume
MMQUERYDEVICEINTERFACESTRING_FUNC GetDeviceInterfaceString
MMGETWAVEINCAPS_FUNC GetWaveInCapabilities
struct _SOUND_DEVICE_INSTANCE * Next
struct _SOUND_DEVICE_INSTANCE::@3470 WinMM
WAVEFORMATEX WaveFormatEx
DWORD_PTR ClientCallbackInstanceData
struct _SOUND_THREAD * Thread
struct _SOUND_DEVICE * Device
MMFUNCTION_TABLE FunctionTable
struct _SOUND_DEVICE_INSTANCE * HeadInstance
struct _SOUND_DEVICE * Next
struct _SOUND_DEVICE_INSTANCE * TailInstance
struct _SOUND_DEVICE_INSTANCE * SoundDeviceInstance
LPOVERLAPPED_COMPLETION_ROUTINE OriginalCompletionRoutine
struct _SOUND_DEVICE_INSTANCE * SoundDeviceInstance
SOUND_THREAD_REQUEST_HANDLER Handler
struct _SOUND_THREAD::@3468 Events
_Must_inspect_result_ _In_ WDFDEVICE Device
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID _Out_ PINTERFACE Interface
_In_ WDFREQUEST _In_ size_t _In_ size_t _In_ ULONG IoControlCode
_In_ WDFREQUEST _In_opt_ PFN_WDF_REQUEST_COMPLETION_ROUTINE CompletionRoutine
_Must_inspect_result_ _In_ WDFUSBDEVICE _In_opt_ WDFREQUEST _In_opt_ PWDF_REQUEST_SEND_OPTIONS _In_ PWDF_USB_CONTROL_SETUP_PACKET _In_opt_ PWDF_MEMORY_DESCRIPTOR _Out_opt_ PULONG BytesTransferred
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_WMI_INSTANCE_CONFIG _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_opt_ WDFWMIINSTANCE * Instance
void(CALLBACK * LPOVERLAPPED_COMPLETION_ROUTINE)(DWORD, DWORD, LPOVERLAPPED)
static WLX_DISPATCH_VERSION_1_4 FunctionTable
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
_Must_inspect_result_ _In_ ULONG Flags
_Inout_opt_ PVOID Parameter