ReactOS 0.4.16-dev-338-g34e76ad
mmebuddy.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _SOUND_OVERLAPPED
 
struct  _MMFUNCTION_TABLE
 
struct  _SOUND_THREAD
 
struct  _SOUND_DEVICE
 
struct  _SOUND_DEVICE_INSTANCE
 
struct  _WAVEHDR_EXTENSION
 

Macros

#define AllocateStruct(thing)    (thing*) AllocateMemory(sizeof(thing))
 
#define StringLengthToBytes(chartype, string_length)    ( ( string_length + 1 ) * sizeof(chartype) )
 
#define AllocateWideString(string_length)    (PWSTR) AllocateMemory(StringLengthToBytes(WCHAR, string_length))
 
#define ZeroWideString(string)    ZeroMemory(string, StringLengthToBytes(WCHAR, wcslen(string)))
 
#define CopyWideString(dest, source)    CopyMemory(dest, source, StringLengthToBytes(WCHAR, wcslen(source)))
 
#define MinimumOf(value_a, value_b)    ( value_a < value_b ? value_a : value_b )
 
#define MaximumOf(value_a, value_b)    ( value_a > value_b ? value_a : value_b )
 
#define SOUND_DEVICE_TYPE_TO_INDEX(x)    ( x - MIN_SOUND_DEVICE_TYPE )
 
#define INDEX_TO_SOUND_DEVICE_TYPE(x)    ( x + MIN_SOUND_DEVICE_TYPE )
 
#define IsValidSoundDeviceType   IS_VALID_SOUND_DEVICE_TYPE
 
#define VALIDATE_MMSYS_PARAMETER(parameter_condition)
 
#define MMSUCCESS(result)    ( result == MMSYSERR_NOERROR )
 
#define DEFINE_GETCAPS_FUNCTYPE(func_typename, caps_type)
 
#define MmePrepareWaveHeader(private_handle, header)    PrepareWaveHeader((PSOUND_DEVICE_INSTANCE)private_handle, (PWAVEHDR)header)
 
#define MmeUnprepareWaveHeader(private_handle, header)    UnprepareWaveHeader((PSOUND_DEVICE_INSTANCE)private_handle, (PWAVEHDR)header)
 
#define MmeWriteWaveHeader(private_handle, header)    WriteWaveHeader((PSOUND_DEVICE_INSTANCE)private_handle, (PWAVEHDR)header)
 

Typedefs

typedef UCHAR MMDEVICE_TYPE
 
typedef UCHARPMMDEVICE_TYPE
 
typedef struct _SOUND_OVERLAPPED SOUND_OVERLAPPED
 
typedef struct _SOUND_OVERLAPPEDPSOUND_OVERLAPPED
 
typedef 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)
 
typedef MMRESULT(* MMMIXERQUERY_FUNC) (IN struct _SOUND_DEVICE_INSTANCE *SoundDeviceInstance, IN DWORD DeviceId, IN UINT uMsg, IN LPVOID Parameter, IN DWORD Flags)
 
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 DWORD DeviceId, IN PWAVEFORMATEX WaveFormat, IN DWORD WaveFormatSize)
 
typedef MMRESULT(* MMOPEN_FUNC) (IN struct _SOUND_DEVICE *SoundDevice, OUT PVOID *Handle)
 
typedef MMRESULT(* MMCLOSE_FUNC) (IN struct _SOUND_DEVICE_INSTANCE *SoundDeviceInstance, IN PVOID Handle)
 
typedef MMRESULT(* MMWAVEHEADER_FUNC) (IN struct _SOUND_DEVICE_INSTANCE *SoundDeviceInstance, IN PWAVEHDR WaveHeader)
 
typedef MMRESULT(* MMBUFFER_FUNC) (IN struct _SOUND_DEVICE_INSTANCE *SoundDeviceInstance, IN PVOID Buffer, IN DWORD Length)
 
typedef MMRESULT(* MMGETPOS_FUNC) (IN struct _SOUND_DEVICE_INSTANCE *SoundDeviceInstance, IN MMTIME *Time)
 
typedef MMRESULT(* MMSETSTATE_FUNC) (IN struct _SOUND_DEVICE_INSTANCE *SoundDeviceInstance, IN BOOL bStart)
 
typedef MMRESULT(* MMQUERYDEVICEINTERFACESTRING_FUNC) (IN MMDEVICE_TYPE DeviceType, IN DWORD DeviceId, IN LPWSTR Interface, IN DWORD InterfaceLength, OUT DWORD *InterfaceSize)
 
typedef MMRESULT(* MMRESETSTREAM_FUNC) (IN struct _SOUND_DEVICE_INSTANCE *SoundDeviceInstance, IN MMDEVICE_TYPE DeviceType, IN BOOLEAN bStartReset)
 
typedef MMRESULT(* MMGETVOLUME_FUNC) (_In_ struct _SOUND_DEVICE_INSTANCE *SoundDeviceInstance, _In_ DWORD DeviceId, _Out_ PDWORD pdwVolume)
 
typedef MMRESULT(* MMSETVOLUME_FUNC) (_In_ struct _SOUND_DEVICE_INSTANCE *SoundDeviceInstance, _In_ DWORD DeviceId, _In_ DWORD dwVolume)
 
typedef struct _MMFUNCTION_TABLE MMFUNCTION_TABLE
 
typedef struct _MMFUNCTION_TABLEPMMFUNCTION_TABLE
 
typedef MMRESULT(* SOUND_THREAD_REQUEST_HANDLER) (IN struct _SOUND_DEVICE_INSTANCE *SoundDeviceInstance, IN PVOID Parameter)
 
typedef struct _SOUND_THREAD SOUND_THREAD
 
typedef struct _SOUND_THREADPSOUND_THREAD
 
typedef struct _SOUND_DEVICE SOUND_DEVICE
 
typedef struct _SOUND_DEVICEPSOUND_DEVICE
 
typedef struct _SOUND_DEVICE_INSTANCE SOUND_DEVICE_INSTANCE
 
typedef struct _SOUND_DEVICE_INSTANCEPSOUND_DEVICE_INSTANCE
 
typedef struct _WAVEHDR_EXTENSION WAVEHDR_EXTENSION
 
typedef struct _WAVEHDR_EXTENSIONPWAVEHDR_EXTENSION
 

Functions

 DEFINE_GETCAPS_FUNCTYPE (MMGETCAPS_FUNC, PVOID)
 
 DEFINE_GETCAPS_FUNCTYPE (MMGETWAVEOUTCAPS_FUNC, LPWAVEOUTCAPS)
 
 DEFINE_GETCAPS_FUNCTYPE (MMGETWAVEINCAPS_FUNC, LPWAVEINCAPS)
 
 DEFINE_GETCAPS_FUNCTYPE (MMGETMIDIOUTCAPS_FUNC, LPMIDIOUTCAPS)
 
 DEFINE_GETCAPS_FUNCTYPE (MMGETMIDIINCAPS_FUNC, LPMIDIINCAPS)
 
MMRESULT InitEntrypointMutexes (VOID)
 
VOID CleanupEntrypointMutexes (VOID)
 
VOID AcquireEntrypointMutex (IN MMDEVICE_TYPE DeviceType)
 
VOID ReleaseEntrypointMutex (IN MMDEVICE_TYPE DeviceType)
 
VOID NotifyMmeClient (IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance, IN UINT Message, IN DWORD_PTR Parameter)
 
MMRESULT MmeGetSoundDeviceCapabilities (IN MMDEVICE_TYPE DeviceType, IN DWORD DeviceId, IN PVOID Capabilities, IN DWORD CapabilitiesSize)
 
MMRESULT MmeOpenDevice (IN MMDEVICE_TYPE DeviceType, IN UINT DeviceId, IN LPWAVEOPENDESC OpenParameters, IN DWORD Flags, OUT DWORD_PTR *PrivateHandle)
 
MMRESULT MmeCloseDevice (IN DWORD_PTR PrivateHandle)
 
MMRESULT MmeGetPosition (IN MMDEVICE_TYPE DeviceType, IN DWORD DeviceId, IN DWORD_PTR PrivateHandle, IN MMTIME *Time, IN DWORD Size)
 
MMRESULT MmeGetVolume (_In_ MMDEVICE_TYPE DeviceType, _In_ DWORD DeviceId, _In_ DWORD_PTR PrivateHandle, _Out_ DWORD_PTR pdwVolume)
 
MMRESULT MmeSetVolume (_In_ MMDEVICE_TYPE DeviceType, _In_ DWORD DeviceId, _In_ DWORD_PTR PrivateHandle, _In_ DWORD_PTR dwVolume)
 
MMRESULT MmeGetDeviceInterfaceString (IN MMDEVICE_TYPE DeviceType, IN DWORD DeviceId, IN LPWSTR Interface, IN DWORD InterfaceLength, OUT DWORD *InterfaceSize)
 
MMRESULT MmeSetState (IN DWORD_PTR PrivateHandle, IN BOOL bStart)
 
MMRESULT MmeResetWavePlayback (IN DWORD_PTR PrivateHandle)
 
MMRESULT GetSoundDeviceCapabilities (IN PSOUND_DEVICE SoundDevice, IN DWORD DeviceId, OUT PVOID Capabilities, IN DWORD CapabilitiesSize)
 
ULONG GetSoundDeviceCount (IN MMDEVICE_TYPE DeviceType)
 
BOOLEAN IsValidSoundDevice (IN PSOUND_DEVICE SoundDevice)
 
MMRESULT ListSoundDevice (IN MMDEVICE_TYPE DeviceType, IN PVOID Identifier OPTIONAL, OUT PSOUND_DEVICE *SoundDevice OPTIONAL)
 
MMRESULT UnlistSoundDevice (IN MMDEVICE_TYPE DeviceType, IN PSOUND_DEVICE SoundDevice)
 
MMRESULT UnlistSoundDevices (IN MMDEVICE_TYPE DeviceType)
 
VOID UnlistAllSoundDevices (VOID)
 
MMRESULT GetSoundDevice (IN MMDEVICE_TYPE DeviceType, IN DWORD DeviceIndex, OUT PSOUND_DEVICE *Device)
 
MMRESULT GetSoundDeviceIdentifier (IN PSOUND_DEVICE SoundDevice, OUT PVOID *Identifier)
 
MMRESULT GetSoundDeviceType (IN PSOUND_DEVICE SoundDevice, OUT PMMDEVICE_TYPE DeviceType)
 
MMRESULT SetSoundDeviceFunctionTable (IN PSOUND_DEVICE SoundDevice, IN PMMFUNCTION_TABLE FunctionTable)
 
MMRESULT GetSoundDeviceFunctionTable (IN PSOUND_DEVICE SoundDevice, OUT PMMFUNCTION_TABLE *FunctionTable)
 
BOOLEAN 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)
 
MMRESULT GetSoundDeviceInstanceHandle (IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance, OUT PVOID *Handle)
 
MMRESULT SetSoundDeviceInstanceMmeData (IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance, IN HDRVR MmeHandle, IN DWORD_PTR ClientCallback, IN DWORD_PTR ClientCallbackData, IN DWORD Flags)
 
MMRESULT CreateSoundThread (OUT PSOUND_THREAD *Thread)
 
MMRESULT DestroySoundThread (IN PSOUND_THREAD Thread)
 
MMRESULT CallSoundThread (IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance, IN SOUND_THREAD_REQUEST_HANDLER RequestHandler, IN PVOID Parameter OPTIONAL)
 
PVOID AllocateMemory (IN UINT Size)
 
VOID FreeMemory (IN PVOID Pointer)
 
UINT GetMemoryAllocationCount (VOID)
 
UINT GetDigitCount (IN UINT Number)
 
MMRESULT Win32ErrorToMmResult (IN UINT ErrorCode)
 
MMRESULT TranslateInternalMmResult (IN MMRESULT Result)
 
MMRESULT QueryWaveDeviceFormatSupport (IN PSOUND_DEVICE SoundDevice, IN LPWAVEFORMATEX Format, IN DWORD FormatSize)
 
MMRESULT SetWaveDeviceFormat (IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance, IN DWORD DeviceId, IN LPWAVEFORMATEX Format, IN DWORD FormatSize)
 
MMRESULT EnqueueWaveHeader (PSOUND_DEVICE_INSTANCE SoundDeviceInstance, IN PVOID Parameter)
 
VOID CompleteWaveHeader (IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance, IN PWAVEHDR Header)
 
MMRESULT PrepareWaveHeader (IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance, IN PWAVEHDR Header)
 
MMRESULT UnprepareWaveHeader (IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance, IN PWAVEHDR Header)
 
MMRESULT WriteWaveHeader (IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance, IN PWAVEHDR Header)
 
VOID DoWaveStreaming (IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance)
 
VOID CALLBACK CompleteIO (IN DWORD dwErrorCode, IN DWORD dwNumberOfBytesTransferred, IN LPOVERLAPPED lpOverlapped)
 
MMRESULT CommitWaveHeaderToKernelDevice (IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance, IN PWAVEHDR Header, IN WAVE_COMMIT_FUNC CommitFunction)
 
MMRESULT WriteFileEx_Committer (IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance, IN PVOID OffsetPtr, IN DWORD Length, IN PSOUND_OVERLAPPED Overlap, IN LPOVERLAPPED_COMPLETION_ROUTINE CompletionRoutine)
 
MMRESULT StopStreaming (IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance)
 
VOID InitiateSoundStreaming (IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance)
 
MMRESULT OpenKernelSoundDeviceByName (IN PWSTR DevicePath, IN BOOLEAN ReadOnly, OUT PHANDLE Handle)
 
MMRESULT OpenKernelSoundDevice (IN PSOUND_DEVICE SoundDevice, IN BOOLEAN ReadOnly, OUT PHANDLE Handle)
 
MMRESULT CloseKernelSoundDevice (IN HANDLE Handle)
 
MMRESULT SyncOverlappedDeviceIoControl (IN HANDLE SoundDeviceInstance, IN DWORD IoControlCode, IN LPVOID InBuffer, IN DWORD InBufferSize, OUT LPVOID OutBuffer, IN DWORD OutBufferSize, OUT LPDWORD BytesTransferred OPTIONAL)
 

Macro Definition Documentation

◆ AllocateStruct

#define AllocateStruct (   thing)     (thing*) AllocateMemory(sizeof(thing))

Definition at line 27 of file mmebuddy.h.

◆ AllocateWideString

#define AllocateWideString (   string_length)     (PWSTR) AllocateMemory(StringLengthToBytes(WCHAR, string_length))

Definition at line 33 of file mmebuddy.h.

◆ CopyWideString

#define CopyWideString (   dest,
  source 
)     CopyMemory(dest, source, StringLengthToBytes(WCHAR, wcslen(source)))

Definition at line 39 of file mmebuddy.h.

◆ DEFINE_GETCAPS_FUNCTYPE

#define DEFINE_GETCAPS_FUNCTYPE (   func_typename,
  caps_type 
)
Value:
typedef MMRESULT (*func_typename)( \
IN struct _SOUND_DEVICE* SoundDevice, \
IN DWORD DeviceId, \
OUT caps_type Capabilities, \
IN DWORD CapabilitiesSize);
unsigned long DWORD
Definition: ntddk_ex.h:95
_Must_inspect_result_ typedef _Out_ PHIDP_CAPS Capabilities
Definition: hidclass.h:103
UINT MMRESULT
Definition: mmsystem.h:962
#define IN
Definition: typedefs.h:39
#define OUT
Definition: typedefs.h:40

Definition at line 93 of file mmebuddy.h.

◆ INDEX_TO_SOUND_DEVICE_TYPE

#define INDEX_TO_SOUND_DEVICE_TYPE (   x)     ( x + MIN_SOUND_DEVICE_TYPE )

Definition at line 61 of file mmebuddy.h.

◆ IsValidSoundDeviceType

#define IsValidSoundDeviceType   IS_VALID_SOUND_DEVICE_TYPE

Definition at line 69 of file mmebuddy.h.

◆ MaximumOf

#define MaximumOf (   value_a,
  value_b 
)     ( value_a > value_b ? value_a : value_b )

Definition at line 50 of file mmebuddy.h.

◆ MinimumOf

#define MinimumOf (   value_a,
  value_b 
)     ( value_a < value_b ? value_a : value_b )

Definition at line 47 of file mmebuddy.h.

◆ MmePrepareWaveHeader

#define MmePrepareWaveHeader (   private_handle,
  header 
)     PrepareWaveHeader((PSOUND_DEVICE_INSTANCE)private_handle, (PWAVEHDR)header)

Definition at line 414 of file mmebuddy.h.

◆ MmeUnprepareWaveHeader

#define MmeUnprepareWaveHeader (   private_handle,
  header 
)     UnprepareWaveHeader((PSOUND_DEVICE_INSTANCE)private_handle, (PWAVEHDR)header)

Definition at line 417 of file mmebuddy.h.

◆ MmeWriteWaveHeader

#define MmeWriteWaveHeader (   private_handle,
  header 
)     WriteWaveHeader((PSOUND_DEVICE_INSTANCE)private_handle, (PWAVEHDR)header)

Definition at line 420 of file mmebuddy.h.

◆ MMSUCCESS

#define MMSUCCESS (   result)     ( result == MMSYSERR_NOERROR )

Definition at line 80 of file mmebuddy.h.

◆ SOUND_DEVICE_TYPE_TO_INDEX

#define SOUND_DEVICE_TYPE_TO_INDEX (   x)     ( x - MIN_SOUND_DEVICE_TYPE )

Definition at line 58 of file mmebuddy.h.

◆ StringLengthToBytes

#define StringLengthToBytes (   chartype,
  string_length 
)     ( ( string_length + 1 ) * sizeof(chartype) )

Definition at line 30 of file mmebuddy.h.

◆ VALIDATE_MMSYS_PARAMETER

#define VALIDATE_MMSYS_PARAMETER (   parameter_condition)
Value:
{ \
if ( ! (parameter_condition) ) \
{ \
SND_ERR(L"FAILED parameter check: %hS at File %S Line %lu\n", #parameter_condition, __FILE__, __LINE__); \
} \
}
#define MMSYSERR_INVALPARAM
Definition: mmsystem.h:107
#define L(x)
Definition: ntvdm.h:50

Definition at line 71 of file mmebuddy.h.

◆ ZeroWideString

#define ZeroWideString (   string)     ZeroMemory(string, StringLengthToBytes(WCHAR, wcslen(string)))

Definition at line 36 of file mmebuddy.h.

Typedef Documentation

◆ MMBUFFER_FUNC

typedef MMRESULT(* MMBUFFER_FUNC) (IN struct _SOUND_DEVICE_INSTANCE *SoundDeviceInstance, IN PVOID Buffer, IN DWORD Length)

Definition at line 166 of file mmebuddy.h.

◆ MMCLOSE_FUNC

typedef MMRESULT(* MMCLOSE_FUNC) (IN struct _SOUND_DEVICE_INSTANCE *SoundDeviceInstance, IN PVOID Handle)

Definition at line 158 of file mmebuddy.h.

◆ MMDEVICE_TYPE

Definition at line 88 of file mmebuddy.h.

◆ MMFUNCTION_TABLE

◆ MMGETPOS_FUNC

typedef MMRESULT(* MMGETPOS_FUNC) (IN struct _SOUND_DEVICE_INSTANCE *SoundDeviceInstance, IN MMTIME *Time)

Definition at line 171 of file mmebuddy.h.

◆ MMGETVOLUME_FUNC

typedef MMRESULT(* MMGETVOLUME_FUNC) (_In_ struct _SOUND_DEVICE_INSTANCE *SoundDeviceInstance, _In_ DWORD DeviceId, _Out_ PDWORD pdwVolume)

Definition at line 193 of file mmebuddy.h.

◆ MMMIXERQUERY_FUNC

typedef MMRESULT(* MMMIXERQUERY_FUNC) (IN struct _SOUND_DEVICE_INSTANCE *SoundDeviceInstance, IN DWORD DeviceId, IN UINT uMsg, IN LPVOID Parameter, IN DWORD Flags)

Definition at line 136 of file mmebuddy.h.

◆ MMOPEN_FUNC

typedef MMRESULT(* MMOPEN_FUNC) (IN struct _SOUND_DEVICE *SoundDevice, OUT PVOID *Handle)

Definition at line 154 of file mmebuddy.h.

◆ MMQUERYDEVICEINTERFACESTRING_FUNC

typedef MMRESULT(* MMQUERYDEVICEINTERFACESTRING_FUNC) (IN MMDEVICE_TYPE DeviceType, IN DWORD DeviceId, IN LPWSTR Interface, IN DWORD InterfaceLength, OUT DWORD *InterfaceSize)

Definition at line 181 of file mmebuddy.h.

◆ MMRESETSTREAM_FUNC

typedef MMRESULT(* MMRESETSTREAM_FUNC) (IN struct _SOUND_DEVICE_INSTANCE *SoundDeviceInstance, IN MMDEVICE_TYPE DeviceType, IN BOOLEAN bStartReset)

Definition at line 188 of file mmebuddy.h.

◆ MMSETSTATE_FUNC

typedef MMRESULT(* MMSETSTATE_FUNC) (IN struct _SOUND_DEVICE_INSTANCE *SoundDeviceInstance, IN BOOL bStart)

Definition at line 176 of file mmebuddy.h.

◆ MMSETVOLUME_FUNC

typedef MMRESULT(* MMSETVOLUME_FUNC) (_In_ struct _SOUND_DEVICE_INSTANCE *SoundDeviceInstance, _In_ DWORD DeviceId, _In_ DWORD dwVolume)

Definition at line 198 of file mmebuddy.h.

◆ MMWAVEHEADER_FUNC

typedef MMRESULT(* MMWAVEHEADER_FUNC) (IN struct _SOUND_DEVICE_INSTANCE *SoundDeviceInstance, IN PWAVEHDR WaveHeader)

Definition at line 162 of file mmebuddy.h.

◆ MMWAVEQUERYFORMATSUPPORT_FUNC

typedef MMRESULT(* MMWAVEQUERYFORMATSUPPORT_FUNC) (IN struct _SOUND_DEVICE *Device, IN PWAVEFORMATEX WaveFormat, IN DWORD WaveFormatSize)

Definition at line 143 of file mmebuddy.h.

◆ MMWAVESETFORMAT_FUNC

typedef MMRESULT(* MMWAVESETFORMAT_FUNC) (IN struct _SOUND_DEVICE_INSTANCE *Instance, IN DWORD DeviceId, IN PWAVEFORMATEX WaveFormat, IN DWORD WaveFormatSize)

Definition at line 148 of file mmebuddy.h.

◆ PMMDEVICE_TYPE

typedef UCHAR * PMMDEVICE_TYPE

Definition at line 88 of file mmebuddy.h.

◆ PMMFUNCTION_TABLE

◆ PSOUND_DEVICE

◆ PSOUND_DEVICE_INSTANCE

◆ PSOUND_OVERLAPPED

◆ PSOUND_THREAD

◆ PWAVEHDR_EXTENSION

◆ SOUND_DEVICE

◆ SOUND_DEVICE_INSTANCE

◆ SOUND_OVERLAPPED

◆ SOUND_THREAD

◆ SOUND_THREAD_REQUEST_HANDLER

typedef MMRESULT(* SOUND_THREAD_REQUEST_HANDLER) (IN struct _SOUND_DEVICE_INSTANCE *SoundDeviceInstance, IN PVOID Parameter)

Definition at line 243 of file mmebuddy.h.

◆ WAVE_COMMIT_FUNC

typedef 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)

Definition at line 129 of file mmebuddy.h.

◆ WAVEHDR_EXTENSION

Function Documentation

◆ AcquireEntrypointMutex()

VOID AcquireEntrypointMutex ( IN MMDEVICE_TYPE  DeviceType)

Definition at line 75 of file reentrancy.c.

77{
78 UCHAR i;
79
82
84
86}
#define INFINITE
Definition: serial.h:102
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
DeviceType
Definition: mmdrv.h:42
#define SOUND_DEVICE_TYPE_TO_INDEX(x)
Definition: mmebuddy.h:58
#define SND_ASSERT(condition)
HANDLE EntrypointMutexes[SOUND_DEVICE_TYPES]
Definition: reentrancy.c:13
#define IS_VALID_SOUND_DEVICE_TYPE(x)
Definition: sndtypes.h:43
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
unsigned char UCHAR
Definition: xmlstorage.h:181

Referenced by auxMessage(), midMessage(), MmeCloseDevice(), MmeOpenDevice(), modMessage(), mxdMessage(), widMessage(), and wodMessage().

◆ AllocateMemory()

PVOID AllocateMemory ( IN UINT  Size)

Definition at line 20 of file utility.c.

22{
23 PVOID Pointer = NULL;
24
25 if ( ! ProcessHeapHandle )
27
29
30 if ( ! Pointer )
31 return NULL;
32
34
35 return Pointer;
36}
#define NULL
Definition: types.h:112
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
static HANDLE ProcessHeapHandle
Definition: utility.c:13
static UINT CurrentAllocations
Definition: utility.c:14
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533

◆ CallSoundThread()

MMRESULT CallSoundThread ( IN PSOUND_DEVICE_INSTANCE  SoundDeviceInstance,
IN SOUND_THREAD_REQUEST_HANDLER  RequestHandler,
IN PVOID Parameter  OPTIONAL 
)

Definition at line 71 of file thread.c.

75{
77
80
81 Thread = SoundDeviceInstance->Thread;
82
83 SND_TRACE(L"Waiting for READY event\n");
84 WaitForSingleObject(Thread->Events.Ready, INFINITE);
85
86 Thread->Request.Result = MMSYSERR_NOTSUPPORTED;
87 Thread->Request.Handler = RequestHandler;
88 Thread->Request.SoundDeviceInstance = SoundDeviceInstance;
89 Thread->Request.Parameter = Parameter;
90
91 /* Notify the thread it has work to do */
92 SND_TRACE(L"Setting REQUEST event\n");
93 SetEvent(Thread->Events.Request);
94
95 /* Wait for the work to be done */
96 SND_TRACE(L"Waiting for DONE event\n");
97 WaitForSingleObject(Thread->Events.Done, INFINITE);
98
99 return Thread->Request.Result;
100}
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
#define VALIDATE_MMSYS_PARAMETER(parameter_condition)
Definition: mmebuddy.h:71
BOOLEAN IsValidSoundDeviceInstance(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance)
#define SND_TRACE(...)
#define MMSYSERR_NOTSUPPORTED
Definition: mmsystem.h:104
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:733
_Inout_opt_ PVOID Parameter
Definition: rtltypes.h:336

Referenced by StopStreaming(), WaveActivateSoundStreaming(), WaveHeaderOperation(), and WriteWaveHeader().

◆ CleanupEntrypointMutexes()

VOID CleanupEntrypointMutexes ( VOID  )

◆ CloseKernelSoundDevice()

MMRESULT CloseKernelSoundDevice ( IN HANDLE  Handle)

Definition at line 58 of file kernel.c.

60{
62
64
65 return MMSYSERR_NOERROR;
66}
#define CloseHandle
Definition: compat.h:739
ULONG Handle
Definition: gdb_input.c:15
#define MMSYSERR_NOERROR
Definition: mmsystem.h:96

Referenced by CloseNt4SoundDevice(), GetNt4SoundDeviceCapabilities(), and QueryNt4WaveDeviceFormatSupport().

◆ CommitWaveHeaderToKernelDevice()

MMRESULT CommitWaveHeaderToKernelDevice ( IN PSOUND_DEVICE_INSTANCE  SoundDeviceInstance,
IN PWAVEHDR  Header,
IN WAVE_COMMIT_FUNC  CommitFunction 
)

◆ CompleteIO()

VOID CALLBACK CompleteIO ( IN DWORD  dwErrorCode,
IN DWORD  dwNumberOfBytesTransferred,
IN LPOVERLAPPED  lpOverlapped 
)

Definition at line 168 of file streaming.c.

172{
174 PSOUND_DEVICE SoundDevice;
175 PSOUND_DEVICE_INSTANCE SoundDeviceInstance;
177 PWAVEHDR WaveHdr;
178 PWAVEHDR_EXTENSION HdrExtension;
180 DWORD Bytes;
181
182 WaveHdr = (PWAVEHDR) SoundOverlapped->Header;
183 SND_ASSERT( WaveHdr );
184
185 HdrExtension = (PWAVEHDR_EXTENSION) WaveHdr->reserved;
186 SND_ASSERT( HdrExtension );
187
188 SoundDeviceInstance = SoundOverlapped->SoundDeviceInstance;
189
190 Result = GetSoundDeviceFromInstance(SoundDeviceInstance, &SoundDevice);
192
193 Result = GetSoundDeviceType(SoundDevice, &DeviceType);
195
196 do
197 {
198
199 /* We have an available buffer now */
200 -- SoundDeviceInstance->OutstandingBuffers;
201
202 /* Did we finish a WAVEHDR and aren't looping? */
203 if (HdrExtension->BytesCompleted + dwNumberOfBytesTransferred >= WaveHdr->dwBufferLength &&
204 SoundDeviceInstance->LoopsRemaining == 0)
205 {
206 /* Wave buffer fully completed */
207 Bytes = WaveHdr->dwBufferLength - HdrExtension->BytesCompleted;
208
209 HdrExtension->BytesCompleted += Bytes;
210 dwNumberOfBytesTransferred -= Bytes;
211
212 CompleteWaveHeader(SoundDeviceInstance, WaveHdr);
213 SND_TRACE(L"%d/%d bytes of wavehdr completed\n", HdrExtension->BytesCompleted, WaveHdr->dwBufferLength);
214 }
215 else
216 {
217 /* Do we loop a header? */
218 if (HdrExtension->BytesCommitted == WaveHdr->dwBufferLength &&
219 SoundDeviceInstance->LoopsRemaining != 0)
220 {
221 /* Reset amount of bytes and decrement loop count, to play next iteration */
222 HdrExtension->BytesCommitted = 0;
223
224 if (SoundDeviceInstance->LoopsRemaining != INFINITE)
225 --SoundDeviceInstance->LoopsRemaining;
226 SND_TRACE(L"Looping the header, remaining loops %u\n", SoundDeviceInstance->LoopsRemaining);
227 }
228 else
229 {
230 /* Partially completed */
231 HdrExtension->BytesCompleted += dwNumberOfBytesTransferred;
232 SND_TRACE(L"%u/%u bytes of wavehdr completed\n", HdrExtension->BytesCompleted, WaveHdr->dwBufferLength);
233 }
234
235 break;
236 }
237
238 /* Move to next wave header */
239 WaveHdr = WaveHdr->lpNext;
240
241 if (!WaveHdr)
242 {
243 /* No following WaveHdr */
244 SND_ASSERT(dwNumberOfBytesTransferred == 0);
245 break;
246 }
247
248 HdrExtension = (PWAVEHDR_EXTENSION) WaveHdr->reserved;
249 SND_ASSERT( HdrExtension );
250
251
252 }while(dwNumberOfBytesTransferred);
253
254 // AUDIO-BRANCH DIFF
255 // completion callback is performed in a thread
256 DoWaveStreaming(SoundDeviceInstance);
257
258 //CompleteWavePortion(SoundDeviceInstance, dwNumberOfBytesTransferred);
259
261}
static VOID FreeMemory(PCREATE_DATA Data)
Definition: create.c:134
_In_ UINT Bytes
Definition: mmcopy.h:9
struct _WAVEHDR_EXTENSION * PWAVEHDR_EXTENSION
struct _SOUND_OVERLAPPED * PSOUND_OVERLAPPED
UCHAR MMDEVICE_TYPE
Definition: mmebuddy.h:88
MMRESULT GetSoundDeviceFromInstance(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance, OUT PSOUND_DEVICE *SoundDevice)
MMRESULT GetSoundDeviceType(IN PSOUND_DEVICE SoundDevice, OUT PMMDEVICE_TYPE DeviceType)
Definition: devicelist.c:346
VOID CompleteWaveHeader(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance, IN PWAVEHDR Header)
Definition: header.c:274
#define MMSUCCESS(result)
Definition: mmebuddy.h:80
struct wavehdr_tag * PWAVEHDR
_In_ HANDLE _In_ DWORD _In_ DWORD _Inout_opt_ LPOVERLAPPED lpOverlapped
Definition: mswsock.h:93
VOID DoWaveStreaming(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance)
Definition: streaming.c:19
PWAVEHDR Header
Definition: mmebuddy.h:122
struct _SOUND_DEVICE_INSTANCE * SoundDeviceInstance
Definition: mmebuddy.h:121
DWORD BytesCommitted
Definition: mmebuddy.h:324
DWORD BytesCompleted
Definition: mmebuddy.h:325
DWORD dwBufferLength
Definition: mmsystem.h:1015
DWORD_PTR reserved
Definition: mmsystem.h:1021
struct wavehdr_tag * lpNext
Definition: mmsystem.h:1020
_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
Definition: wsk.h:409

Referenced by DoWaveStreaming().

◆ CompleteWaveHeader()

VOID CompleteWaveHeader ( IN PSOUND_DEVICE_INSTANCE  SoundDeviceInstance,
IN PWAVEHDR  Header 
)

Definition at line 274 of file header.c.

277{
278 PWAVEHDR PrevHdr = NULL, CurrHdr = NULL;
280 PSOUND_DEVICE SoundDevice;
283
284 SND_TRACE(L"BUFFER COMPLETE :)\n");
285
286 // TODO: Set header flags?
287 // TODO: Call client
288 // TODO: Streaming
289
290 //DoWaveStreaming(SoundDeviceInstance);
291
292 Result = GetSoundDeviceFromInstance(SoundDeviceInstance, &SoundDevice);
294 Result = GetSoundDeviceType(SoundDevice, &DeviceType);
296
299
300 /* Remove the header from the queue, like so */
301 if ( SoundDeviceInstance->HeadWaveHeader == Header )
302 {
303 SoundDeviceInstance->HeadWaveHeader = Header->lpNext;
304
305 SND_TRACE(L"Dropping head node\n");
306
307 /* If nothing after the head, then there is no tail */
308 if ( Header->lpNext == NULL )
309 {
310 SND_TRACE(L"Dropping tail node\n");
311 SoundDeviceInstance->TailWaveHeader = NULL;
312 }
313 }
314 else
315 {
316 PrevHdr = NULL;
317 CurrHdr = SoundDeviceInstance->HeadWaveHeader;
318
319 SND_TRACE(L"Relinking nodes\n");
320
321 while ( CurrHdr != Header )
322 {
323 PrevHdr = CurrHdr;
324 CurrHdr = CurrHdr->lpNext;
325 SND_ASSERT( CurrHdr );
326 }
327
328 SND_ASSERT( PrevHdr );
329
330 PrevHdr->lpNext = CurrHdr->lpNext;
331
332 /* If this is the tail node, update the tail */
333 if ( Header->lpNext == NULL )
334 {
335 SND_TRACE(L"Updating tail node\n");
336 SoundDeviceInstance->TailWaveHeader = PrevHdr;
337 }
338 }
339
340 /* Make sure we're not using this as the current buffer any more, either! */
341/*
342 if ( SoundDeviceInstance->CurrentWaveHeader == Header )
343 {
344 SoundDeviceInstance->CurrentWaveHeader = Header->lpNext;
345 }
346*/
347
348 DUMP_WAVEHDR_QUEUE(SoundDeviceInstance);
349
350 SND_TRACE(L"Returning buffer to client...\n");
351
352 /* Update the header */
353 Header->dwFlags &= ~WHDR_INQUEUE;
354 Header->dwFlags |= WHDR_DONE;
355
357 {
358 // FIXME: We won't be called on incomplete buffer!
359 Header->dwBytesRecorded = Extension->BytesCompleted;
360 }
361
362 /* Safe to do this without thread protection, as we're done with the header */
363 NotifyMmeClient(SoundDeviceInstance,
366}
Definition: Header.h:9
_Inout_opt_ PUNICODE_STRING Extension
Definition: fltkernel.h:1092
VOID NotifyMmeClient(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance, IN UINT Message, IN DWORD_PTR Parameter)
Definition: mmewrap.c:75
#define DUMP_WAVEHDR_QUEUE(sound_device_instance)
#define WOM_DONE
Definition: mmsystem.h:183
#define WIM_DATA
Definition: mmsystem.h:186
#define WHDR_DONE
Definition: mmsystem.h:193
@ WAVE_IN_DEVICE_TYPE
Definition: sndtypes.h:28
@ WAVE_OUT_DEVICE_TYPE
Definition: sndtypes.h:29
uint32_t DWORD_PTR
Definition: typedefs.h:65

Referenced by CompleteIO(), and StopStreamingInSoundThread().

◆ CreateSoundDeviceInstance()

MMRESULT CreateSoundDeviceInstance ( IN PSOUND_DEVICE  SoundDevice,
OUT PSOUND_DEVICE_INSTANCE SoundDeviceInstance 
)

Definition at line 162 of file deviceinstance.c.

165{
168
169 SND_TRACE(L"Creating a sound device instance\n");
170
172 VALIDATE_MMSYS_PARAMETER( SoundDeviceInstance != NULL );
173
174 Result = AllocateSoundDeviceInstance(SoundDeviceInstance);
175
176 if ( ! MMSUCCESS(Result) )
178
179 /* Get the "open" routine from the function table, and validate it */
181 if ( ! MMSUCCESS(Result) )
182 {
183 FreeSoundDeviceInstance(*SoundDeviceInstance);
185 }
186
187 if ( FunctionTable->Open == NULL )
188 {
189 FreeSoundDeviceInstance(*SoundDeviceInstance);
191 }
192
193 /* Set up the members of the structure */
194 (*SoundDeviceInstance)->Next = NULL;
195 (*SoundDeviceInstance)->Device = SoundDevice;
196 (*SoundDeviceInstance)->Handle = NULL;
197 (*SoundDeviceInstance)->Thread = NULL;
198
199 (*SoundDeviceInstance)->WinMM.Handle = INVALID_HANDLE_VALUE;
200 (*SoundDeviceInstance)->WinMM.ClientCallback = 0;
201 (*SoundDeviceInstance)->WinMM.ClientCallbackInstanceData = 0;
202 (*SoundDeviceInstance)->WinMM.Flags = 0;
203
204 /* Initialise the members of the struct used by the sound thread */
205 (*SoundDeviceInstance)->HeadWaveHeader = NULL;
206 (*SoundDeviceInstance)->TailWaveHeader = NULL;
207
208 (*SoundDeviceInstance)->OutstandingBuffers = 0;
209
210 (*SoundDeviceInstance)->LoopsRemaining = 0;
211
212 /* Create the streaming thread (TODO - is this for wave only?) */
213 Result = CreateSoundThread(&(*SoundDeviceInstance)->Thread);
214 if ( ! MMSUCCESS(Result) )
215 {
216 FreeSoundDeviceInstance(*SoundDeviceInstance);
218 }
219
220 /* Add the instance to the list */
221 Result = ListSoundDeviceInstance(SoundDevice, *SoundDeviceInstance);
222 if ( ! MMSUCCESS(Result) )
223 {
224 FreeSoundDeviceInstance(*SoundDeviceInstance);
226 }
227
228 /* Try and open the device */
229 Result = FunctionTable->Open(SoundDevice, (&(*SoundDeviceInstance)->Handle));
230 if ( ! MMSUCCESS(Result) )
231 {
232 UnlistSoundDeviceInstance(*SoundDeviceInstance);
233 FreeSoundDeviceInstance(*SoundDeviceInstance);
235 }
236
237 return MMSYSERR_NOERROR;
238}
VOID FreeSoundDeviceInstance(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance)
MMRESULT AllocateSoundDeviceInstance(OUT PSOUND_DEVICE_INSTANCE *SoundDeviceInstance)
MMRESULT UnlistSoundDeviceInstance(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance)
MMRESULT ListSoundDeviceInstance(IN PSOUND_DEVICE SoundDevice, IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance)
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
BOOLEAN IsValidSoundDevice(IN PSOUND_DEVICE SoundDevice)
Definition: devicelist.c:87
MMRESULT CreateSoundThread(OUT PSOUND_THREAD *Thread)
Definition: thread.c:209
MMRESULT GetSoundDeviceFunctionTable(IN PSOUND_DEVICE SoundDevice, OUT PMMFUNCTION_TABLE *FunctionTable)
Definition: functiontable.c:47
MMRESULT TranslateInternalMmResult(IN MMRESULT Result)
Definition: utility.c:132
static WLX_DISPATCH_VERSION_1_4 FunctionTable
Definition: wlx.c:722

Referenced by MmeOpenDevice().

◆ CreateSoundThread()

MMRESULT CreateSoundThread ( OUT PSOUND_THREAD Thread)

Definition at line 209 of file thread.c.

211{
213 PSOUND_THREAD NewThread;
214
216
217 NewThread = AllocateStruct(SOUND_THREAD);
218 if ( ! NewThread )
219 return MMSYSERR_NOMEM;
220
221 /* Prepare the events we'll be using to sync. everything */
222 Result = CreateSoundThreadEvents(&NewThread->Events.Ready,
223 &NewThread->Events.Request,
224 &NewThread->Events.Done);
225
226 if ( ! MMSUCCESS(Result) )
227 {
228 FreeMemory(NewThread);
230 }
231
232 SND_TRACE(L"Creating a sound thread\n");
233 NewThread->Handle = CreateThread(NULL,
234 0,
236 (LPVOID) NewThread,
238 NULL);
239
240 /* Something went wrong, bail out! */
241 if ( NewThread->Handle == INVALID_HANDLE_VALUE )
242 {
243 SND_ERR(L"Sound thread creation failed!\n");
244 DestroySoundThreadEvents(NewThread->Events.Ready,
245 NewThread->Events.Request,
246 NewThread->Events.Done);
247
248 FreeMemory(NewThread);
249
251 }
252
253 /* Wake the thread up */
254 if ( ResumeThread(NewThread->Handle) == -1 )
255 {
256 SND_ERR(L"Failed to resume thread!\n");
257 CloseHandle(NewThread->Handle);
258 DestroySoundThreadEvents(NewThread->Events.Ready,
259 NewThread->Events.Request,
260 NewThread->Events.Done);
261
262 FreeMemory(NewThread);
264 }
265
266 /* If all is well we can now give the thread to the caller */
267 *Thread = NewThread;
268 return MMSYSERR_NOERROR;
269}
DWORD WINAPI ResumeThread(IN HANDLE hThread)
Definition: thread.c:567
HANDLE WINAPI DECLSPEC_HOTPATCH CreateThread(IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
Definition: thread.c:137
#define AllocateStruct(thing)
Definition: mmebuddy.h:27
MMRESULT Win32ErrorToMmResult(IN UINT ErrorCode)
Definition: utility.c:87
#define SND_ERR(...)
#define MMSYSERR_NOMEM
Definition: mmsystem.h:103
DWORD WINAPI SoundThreadMain(IN LPVOID lpParameter OPTIONAL)
Definition: thread.c:14
MMRESULT DestroySoundThreadEvents(IN HANDLE ReadyEvent, IN HANDLE RequestEvent, IN HANDLE DoneEvent)
Definition: thread.c:190
MMRESULT CreateSoundThreadEvents(OUT HANDLE *ReadyEvent, OUT HANDLE *RequestEvent, OUT HANDLE *DoneEvent)
Definition: thread.c:151
struct _SOUND_THREAD::@3473 Events
HANDLE Handle
Definition: mmebuddy.h:249
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define CREATE_SUSPENDED
Definition: winbase.h:181

Referenced by CreateSoundDeviceInstance().

◆ DEFINE_GETCAPS_FUNCTYPE() [1/5]

DEFINE_GETCAPS_FUNCTYPE ( MMGETCAPS_FUNC  ,
PVOID   
)

◆ DEFINE_GETCAPS_FUNCTYPE() [2/5]

DEFINE_GETCAPS_FUNCTYPE ( MMGETMIDIINCAPS_FUNC  ,
LPMIDIINCAPS   
)

◆ DEFINE_GETCAPS_FUNCTYPE() [3/5]

DEFINE_GETCAPS_FUNCTYPE ( MMGETMIDIOUTCAPS_FUNC  ,
LPMIDIOUTCAPS   
)

◆ DEFINE_GETCAPS_FUNCTYPE() [4/5]

DEFINE_GETCAPS_FUNCTYPE ( MMGETWAVEINCAPS_FUNC  ,
LPWAVEINCAPS   
)

◆ DEFINE_GETCAPS_FUNCTYPE() [5/5]

DEFINE_GETCAPS_FUNCTYPE ( MMGETWAVEOUTCAPS_FUNC  ,
LPWAVEOUTCAPS   
)

◆ DestroyAllSoundDeviceInstances()

MMRESULT DestroyAllSoundDeviceInstances ( IN PSOUND_DEVICE  SoundDevice)

Definition at line 305 of file deviceinstance.c.

307{
309 PSOUND_DEVICE_INSTANCE SoundDeviceInstance, NextDeviceInstance;
310
311 SoundDeviceInstance = SoundDevice->HeadInstance;
312
313 while ( SoundDeviceInstance )
314 {
315 NextDeviceInstance = SoundDeviceInstance->Next;
316 Result = DestroySoundDeviceInstance(SoundDeviceInstance);
318 SoundDeviceInstance = NextDeviceInstance;
319 }
320
321 return MMSYSERR_NOERROR;
322}
MMRESULT DestroySoundDeviceInstance(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance)
struct _SOUND_DEVICE_INSTANCE * Next
Definition: mmebuddy.h:281

◆ DestroySoundDeviceInstance()

MMRESULT DestroySoundDeviceInstance ( IN PSOUND_DEVICE_INSTANCE  SoundDeviceInstance)

Definition at line 241 of file deviceinstance.c.

243{
246 PSOUND_DEVICE SoundDevice;
248
249 SND_TRACE(L"Destroying a sound device instance\n");
250
252
253 Result = GetSoundDeviceFromInstance(SoundDeviceInstance, &SoundDevice);
254 if ( ! MMSUCCESS(Result) )
256
257 Result = GetSoundDeviceInstanceHandle(SoundDeviceInstance, &Handle);
258 if ( ! MMSUCCESS(Result) )
260
261 /* Get the "close" routine from the function table, and validate it */
263 if ( ! MMSUCCESS(Result) )
265
266 SND_ASSERT( FunctionTable->Close );
267 if ( FunctionTable->Close == NULL )
268 {
269 /* This indicates bad practice, really! If you can open, why not close?! */
271 }
272
273 /* Stop the streaming thread */
274 if ( SoundDeviceInstance->Thread )
275 {
276 Result = DestroySoundThread(SoundDeviceInstance->Thread);
277 SND_ASSERT( MMSUCCESS(Result) ); /* It should succeed! */
278 if ( ! MMSUCCESS(Result ) )
279 {
281 }
282 }
283
284 /* Blank this out here */
285 SoundDeviceInstance->Thread = NULL;
286
287 /* Try and close the device */
288 Result = FunctionTable->Close(SoundDeviceInstance, Handle);
289 SND_ASSERT( MMSUCCESS(Result) ); /* It should succeed! */
290 if ( ! MMSUCCESS(Result) )
292
293 /* Drop it from the list */
294 Result = UnlistSoundDeviceInstance(SoundDeviceInstance);
295 SND_ASSERT( MMSUCCESS(Result) ); /* It should succeed! */
296 if ( ! MMSUCCESS(Result) )
298
299 FreeSoundDeviceInstance(SoundDeviceInstance);
300
301 return MMSYSERR_NOERROR;
302}
MMRESULT GetSoundDeviceFromInstance(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance, OUT PSOUND_DEVICE *SoundDevice)
MMRESULT GetSoundDeviceInstanceHandle(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance, OUT PVOID *Handle)
BOOLEAN IsValidSoundDeviceInstance(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance)
MMRESULT DestroySoundThread(IN PSOUND_THREAD Thread)
Definition: thread.c:272

Referenced by DestroyAllSoundDeviceInstances(), and MmeCloseDevice().

◆ DestroySoundThread()

MMRESULT DestroySoundThread ( IN PSOUND_THREAD  Thread)

Definition at line 272 of file thread.c.

274{
277
278 SND_TRACE(L"Terminating sound thread\n");
279
280 /* Tell the thread to terminate itself */
282
283 SND_TRACE(L"Sound thread terminated, performing cleanup of thread resources\n");
284
285 CloseHandle(Thread->Handle); /* Is this needed? */
287
288 DestroySoundThreadEvents(Thread->Events.Ready,
289 Thread->Events.Request,
290 Thread->Events.Done);
291
292 /* Wipe and free the memory used for the thread */
295
296 SND_TRACE(L"Finished thread cleanup\n");
297
298 return MMSYSERR_NOERROR;
299}
MMRESULT TerminateSoundThread(IN PSOUND_THREAD Thread)
Definition: thread.c:119
#define ZeroMemory
Definition: winbase.h:1737

Referenced by DestroySoundDeviceInstance().

◆ DoWaveStreaming()

VOID DoWaveStreaming ( IN PSOUND_DEVICE_INSTANCE  SoundDeviceInstance)

Definition at line 19 of file streaming.c.

21{
24 PSOUND_DEVICE SoundDevice;
27 PWAVEHDR_EXTENSION HeaderExtension;
28
29 Result = GetSoundDeviceFromInstance(SoundDeviceInstance, &SoundDevice);
31
32 Result = GetSoundDeviceType(SoundDevice, &DeviceType);
34
38 SND_ASSERT( FunctionTable->CommitWaveBuffer );
39
40 /* No point in doing anything if no resources available to use */
41 if ( SoundDeviceInstance->OutstandingBuffers >= SoundDeviceInstance->BufferCount )
42 {
43 SND_TRACE(L"DoWaveStreaming: No available buffers to stream with - doing nothing\n");
44 return;
45 }
46
47 /* Is there any work to do? */
48 Header = SoundDeviceInstance->HeadWaveHeader;
49
50 if ( ! Header )
51 {
52 SND_TRACE(L"DoWaveStreaming: No work to do - doing nothing\n");
53 return;
54 }
55
56 /* Do we need to loop a header? */
58 {
59 if ((Header->dwFlags & WHDR_ENDLOOP))
60 {
61 /* Get loop count */
62 SoundDeviceInstance->LoopsRemaining = Header->dwLoops;
63 }
64 else
65 {
66 /* Report and help notice such a case */
67 SND_WARN(L"Looping multiple headers is UNIMPLEMENTED. Will play once only\n");
69 }
70 }
71
72 while ( ( SoundDeviceInstance->OutstandingBuffers < SoundDeviceInstance->BufferCount ) &&
73 ( Header ) && SoundDeviceInstance->ResetInProgress == FALSE)
74 {
75 HeaderExtension = (PWAVEHDR_EXTENSION) Header->reserved;
76 SND_ASSERT( HeaderExtension );
77
78 /* Saniy checks */
80 SND_ASSERT(Header->dwFlags & WHDR_INQUEUE);
81
82 /* Can never be *above* the length */
83 SND_ASSERT( HeaderExtension->BytesCommitted <= Header->dwBufferLength );
84
85 /* Is this header entirely committed? */
86 if ( HeaderExtension->BytesCommitted == Header->dwBufferLength )
87 {
88 {
89 /* Move on to the next header */
90 SND_ASSERT(Header != Header->lpNext);
91 Header = Header->lpNext;
92 }
93 }
94 else
95 {
96 PSOUND_OVERLAPPED Overlap;
97 LPVOID OffsetPtr;
98 DWORD BytesRemaining, BytesToCommit;
99 BOOL OK;
100
101 /* Where within the header buffer to stream from */
102 OffsetPtr = Header->lpData + HeaderExtension->BytesCommitted;
103
104 /* How much of this header has not been committed */
105 BytesRemaining = Header->dwBufferLength - HeaderExtension->BytesCommitted;
106
107 /* We can commit anything up to the buffer size limit */
108 BytesToCommit = BytesRemaining > SoundDeviceInstance->FrameSize ?
109 SoundDeviceInstance->FrameSize :
110 BytesRemaining;
111
112 /* Should always have something to commit by this point */
113 SND_ASSERT( BytesToCommit > 0 );
114
115 /* We need a new overlapped info structure for each buffer */
117
118 if ( Overlap )
119 {
120 ZeroMemory(Overlap, sizeof(SOUND_OVERLAPPED));
121 Overlap->SoundDeviceInstance = SoundDeviceInstance;
122 Overlap->Header = Header;
123
124 /* Adjust the commit-related counters */
125 HeaderExtension->BytesCommitted += BytesToCommit;
126 ++ SoundDeviceInstance->OutstandingBuffers;
127
128 OK = MMSUCCESS(FunctionTable->CommitWaveBuffer(SoundDeviceInstance,
129 OffsetPtr,
130 BytesToCommit,
131 Overlap,
132 CompleteIO));
133
134 if ( ! OK )
135 {
136 /* Clean-up and try again on the next iteration (is this OK?) */
137 SND_WARN(L"FAILED\n");
138
139 FreeMemory(Overlap);
140 HeaderExtension->BytesCommitted -= BytesToCommit;
141 -- SoundDeviceInstance->OutstandingBuffers;
142 }
143 }
144 }
145 }
146}
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define SND_WARN(...)
#define WHDR_ENDLOOP
Definition: mmsystem.h:196
#define WHDR_INQUEUE
Definition: mmsystem.h:197
#define WHDR_BEGINLOOP
Definition: mmsystem.h:195
#define WHDR_PREPARED
Definition: mmsystem.h:194
VOID CALLBACK CompleteIO(IN DWORD dwErrorCode, IN DWORD dwNumberOfBytesTransferred, IN LPOVERLAPPED lpOverlapped)
Definition: streaming.c:168
#define OK(condition, fail_message,...)

Referenced by CompleteIO(), EnqueueWaveHeader(), and PerformWaveStreaming().

◆ EnqueueWaveHeader()

MMRESULT EnqueueWaveHeader ( PSOUND_DEVICE_INSTANCE  SoundDeviceInstance,
IN PVOID  Parameter 
)

Definition at line 218 of file header.c.

221{
222 PWAVEHDR WaveHeader = (PWAVEHDR) Parameter;
223
224 VALIDATE_MMSYS_PARAMETER( SoundDeviceInstance );
226
227 /* Initialise */
228 WaveHeader->lpNext = NULL;
229
230 /* Set the "in queue" flag */
231 WaveHeader->dwFlags |= WHDR_INQUEUE;
232
233 if ( ! SoundDeviceInstance->HeadWaveHeader )
234 {
235 /* This is the first header in the queue */
236 SND_TRACE(L"Enqueued first wave header\n");
237 SoundDeviceInstance->HeadWaveHeader = WaveHeader;
238 SoundDeviceInstance->TailWaveHeader = WaveHeader;
239
240 /* Only do wave streaming when the stream has not been paused */
241 if (SoundDeviceInstance->bPaused == FALSE)
242 {
243 DoWaveStreaming(SoundDeviceInstance);
244 }
245 }
246 else
247 {
248 /* There are already queued headers - make this one the tail */
249 SND_TRACE(L"Enqueued next wave header\n");
250
251 /* FIXME - Make sure that the buffer has not already been added to the list */
252 if ( SoundDeviceInstance->TailWaveHeader != WaveHeader )
253 {
254 SND_ASSERT(SoundDeviceInstance->TailWaveHeader != WaveHeader);
255
256 SoundDeviceInstance->TailWaveHeader->lpNext = WaveHeader;
257 SoundDeviceInstance->TailWaveHeader = WaveHeader;
258 DUMP_WAVEHDR_QUEUE(SoundDeviceInstance);
259
260 /* Only do wave streaming when the stream has not been paused */
261 if ( SoundDeviceInstance->bPaused == FALSE )
262 {
263 DoWaveStreaming(SoundDeviceInstance);
264 }
265 }
266 }
267
268 DUMP_WAVEHDR_QUEUE(SoundDeviceInstance);
269
270 return MMSYSERR_NOERROR;
271}
VOID DoWaveStreaming(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance)
Definition: streaming.c:19
PWAVEHDR TailWaveHeader
Definition: mmebuddy.h:304
PWAVEHDR HeadWaveHeader
Definition: mmebuddy.h:299
DWORD dwFlags
Definition: mmsystem.h:1018

Referenced by WriteWaveHeader().

◆ FreeMemory()

VOID FreeMemory ( IN PVOID  Pointer)

Definition at line 42 of file utility.c.

44{
46 SND_ASSERT( Pointer );
47
48 HeapFree(ProcessHeapHandle, 0, Pointer);
49
51}
#define HeapFree(x, y, z)
Definition: compat.h:735

◆ GetDigitCount()

UINT GetDigitCount ( IN UINT  Number)

Definition at line 68 of file utility.c.

70{
72 ULONG Digits = 1;
73
74 while ( Value > 9 )
75 {
76 Value /= 10;
77 ++ Digits;
78 }
79
80 return Digits;
81}
unsigned int UINT
Definition: ndis.h:50
_In_opt_ PENTER_STATE_SYSTEM_HANDLER _In_opt_ PVOID _In_ LONG _In_opt_ LONG volatile * Number
Definition: ntpoapi.h:207
uint32_t ULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413

Referenced by DetectNt4SoundDevices(), and OpenSoundDeviceRegKey().

◆ GetMemoryAllocationCount()

UINT GetMemoryAllocationCount ( VOID  )

◆ GetSoundDevice()

MMRESULT GetSoundDevice ( IN MMDEVICE_TYPE  DeviceType,
IN DWORD  DeviceIndex,
OUT PSOUND_DEVICE Device 
)

Definition at line 289 of file devicelist.c.

293{
295 DWORD CurrentIndex = 0;
296 PSOUND_DEVICE CurrentDevice;
297
299
300 if ( DeviceIndex >= SoundDeviceCounts[TypeIndex] )
301 {
302 SND_ERR(L"Invalid device ID %d for type %d\n", DeviceIndex, DeviceType);
304 }
305
306 CurrentDevice = SoundDeviceListHeads[TypeIndex];
307
308 /* Following the earlier checks, the index should be valid here. */
309 for ( CurrentIndex = 0; CurrentIndex != DeviceIndex; ++ CurrentIndex )
310 {
311 SND_ASSERT( CurrentDevice );
312 CurrentDevice = CurrentDevice->Next;
313 }
314
315 SND_TRACE(L"Returning sound device %x\n", CurrentDevice);
316
317 *SoundDevice = CurrentDevice;
318
319 return MMSYSERR_NOERROR;
320}
#define IsValidSoundDeviceType
Definition: mmebuddy.h:69
#define MMSYSERR_BADDEVICEID
Definition: mmsystem.h:98
ULONG SoundDeviceCounts[SOUND_DEVICE_TYPES]
Definition: devicelist.c:13
PSOUND_DEVICE SoundDeviceListHeads[SOUND_DEVICE_TYPES]
Definition: devicelist.c:14
struct _SOUND_DEVICE * Next
Definition: mmebuddy.h:270

Referenced by MmeGetDeviceInterfaceString(), MmeGetLineInfo(), MmeGetSoundDeviceCapabilities(), and MmeOpenDevice().

◆ GetSoundDeviceCapabilities()

MMRESULT GetSoundDeviceCapabilities ( IN PSOUND_DEVICE  SoundDevice,
IN DWORD  DeviceId,
OUT PVOID  Capabilities,
IN DWORD  CapabilitiesSize 
)

Definition at line 24 of file capabilities.c.

29{
32 BOOLEAN GoodSize = FALSE;
34
37 VALIDATE_MMSYS_PARAMETER( CapabilitiesSize > 0 );
38
39 /* Obtain the device type */
40 Result = GetSoundDeviceType(SoundDevice, &DeviceType);
42
43 if ( ! MMSUCCESS(Result) )
45
46 /* Obtain the function table */
49
50 if ( ! MMSUCCESS(Result) )
52
54
55 /* Check that the capabilities structure is of a valid size */
56 switch ( DeviceType )
57 {
59 {
60 GoodSize = CapabilitiesSize >= sizeof(WAVEOUTCAPSW);
61 break;
62 }
64 {
65 GoodSize = CapabilitiesSize >= sizeof(WAVEINCAPSW);
66 break;
67 }
69 {
70 GoodSize = CapabilitiesSize >= sizeof(MIDIOUTCAPSW);
71 break;
72 }
74 {
75 GoodSize = CapabilitiesSize >= sizeof(MIDIINCAPSW);
76 break;
77 }
78 case AUX_DEVICE_TYPE :
79 {
80 GoodSize = CapabilitiesSize >= sizeof(AUXCAPSW);
81 break;
82 }
84 {
85 GoodSize = CapabilitiesSize >= sizeof(MIXERCAPSW);
86 break;
87 }
88 };
89
90 if ( ! GoodSize )
91 {
92 SND_ERR(L"Device capabilities structure too small\n");
94 }
95
96 /* Call the "get capabilities" function within the function table */
97 SND_ASSERT( FunctionTable->GetCapabilities );
98
99 if ( ! FunctionTable->GetCapabilities )
101
102 return FunctionTable->GetCapabilities(SoundDevice,
103 DeviceId,
105 CapabilitiesSize);
106}
unsigned char BOOLEAN
struct tagMIDIINCAPSW MIDIINCAPSW
struct tagAUXCAPSW AUXCAPSW
struct tagMIDIOUTCAPSW MIDIOUTCAPSW
struct tagWAVEINCAPSW WAVEINCAPSW
struct tagMIXERCAPSW MIXERCAPSW
struct tagWAVEOUTCAPSW WAVEOUTCAPSW
@ MIXER_DEVICE_TYPE
Definition: sndtypes.h:33
@ MIDI_OUT_DEVICE_TYPE
Definition: sndtypes.h:31
@ AUX_DEVICE_TYPE
Definition: sndtypes.h:32
@ MIDI_IN_DEVICE_TYPE
Definition: sndtypes.h:30

Referenced by MmeGetSoundDeviceCapabilities().

◆ GetSoundDeviceCount()

ULONG GetSoundDeviceCount ( IN MMDEVICE_TYPE  DeviceType)

Definition at line 67 of file devicelist.c.

69{
71
73 {
74 return 0;
75 }
76
77 SND_TRACE(L"Returning a count of %d devices\n", SoundDeviceCounts[Index]);
79}
_In_ WDFCOLLECTION _In_ ULONG Index

Referenced by auxMessage(), midMessage(), modMessage(), mxdMessage(), widMessage(), and wodMessage().

◆ GetSoundDeviceFromInstance()

◆ GetSoundDeviceFunctionTable()

◆ GetSoundDeviceIdentifier()

MMRESULT GetSoundDeviceIdentifier ( IN PSOUND_DEVICE  SoundDevice,
OUT PVOID Identifier 
)

Definition at line 328 of file devicelist.c.

331{
332 VALIDATE_MMSYS_PARAMETER( SoundDevice );
334
335 /* The caller should not modify this! */
336 *Identifier = SoundDevice->Identifier;
337
338 return MMSYSERR_NOERROR;
339}
@ Identifier
Definition: asmpp.cpp:95

Referenced by OpenNt4KernelSoundDevice(), and WdmAudSetWaveDeviceFormatByLegacy().

◆ GetSoundDeviceInstanceHandle()

◆ GetSoundDeviceType()

◆ InitEntrypointMutexes()

MMRESULT InitEntrypointMutexes ( VOID  )

◆ InitiateSoundStreaming()

VOID InitiateSoundStreaming ( IN PSOUND_DEVICE_INSTANCE  SoundDeviceInstance)

Definition at line 409 of file streaming.c.

411{
413
414 hThread = CreateThread(NULL, 0, WaveActivateSoundStreaming, (PVOID)SoundDeviceInstance, 0, NULL);
415
416 if (hThread != NULL)
418}
HANDLE hThread
Definition: wizard.c:28
DWORD WINAPI WaveActivateSoundStreaming(IN PVOID lpParameter)
Definition: streaming.c:398

Referenced by MmeSetState().

◆ IsValidSoundDevice()

BOOLEAN IsValidSoundDevice ( IN PSOUND_DEVICE  SoundDevice)

Definition at line 87 of file devicelist.c.

89{
90 UCHAR TypeIndex;
91 PSOUND_DEVICE CurrentDevice;
92
93 if ( ! SoundDevice )
94 return FALSE;
95
96 /* Go through all the device lists */
97 for ( TypeIndex = 0; TypeIndex < SOUND_DEVICE_TYPES; ++ TypeIndex )
98 {
99 CurrentDevice = SoundDeviceListHeads[TypeIndex];
100
101 while ( CurrentDevice )
102 {
103 if ( CurrentDevice == SoundDevice )
104 {
105 /* Found the device */
106 return TRUE;
107 }
108
109 CurrentDevice = CurrentDevice->Next;
110 }
111 }
112
113 /* If we get here, nothing was found */
114 return FALSE;
115}
#define TRUE
Definition: types.h:120
@ SOUND_DEVICE_TYPES
Definition: sndtypes.h:40

Referenced by CreateSoundDeviceInstance(), GetSoundDeviceCapabilities(), GetSoundDeviceFunctionTable(), ListSoundDeviceInstance(), OpenNt4KernelSoundDevice(), OpenNt4SoundDevice(), QueryNt4WaveDeviceFormatSupport(), QueryWaveDeviceFormatSupport(), SetSoundDeviceFunctionTable(), and UnlistSoundDevice().

◆ IsValidSoundDeviceInstance()

BOOLEAN IsValidSoundDeviceInstance ( IN PSOUND_DEVICE_INSTANCE  SoundDeviceInstance)

Definition at line 60 of file deviceinstance.c.

62{
63 PSOUND_DEVICE SoundDevice;
64 PSOUND_DEVICE_INSTANCE CurrentInstance;
65
66 if ( ! SoundDeviceInstance )
67 return FALSE;
68
69 /* GetSoundDeviceFromInstance would send us into a recursive loop... */
70 SoundDevice = SoundDeviceInstance->Device;
71 SND_ASSERT(SoundDevice);
72
73 CurrentInstance = SoundDevice->HeadInstance;
74
75 while ( CurrentInstance )
76 {
77 if ( CurrentInstance == SoundDeviceInstance )
78 return TRUE;
79
80 CurrentInstance = CurrentInstance->Next;
81 }
82
83 return FALSE;
84}
struct _SOUND_DEVICE_INSTANCE * HeadInstance
Definition: mmebuddy.h:271

Referenced by CallSoundThread(), CloseNt4SoundDevice(), DestroySoundDeviceInstance(), GetSoundDeviceFromInstance(), GetSoundDeviceInstanceHandle(), MmeCloseDevice(), MmeGetPosition(), MmeGetVolume(), MmeSetState(), MmeSetVolume(), PrepareWaveHeader(), SetNt4WaveDeviceFormat(), SetSoundDeviceInstanceMmeData(), SetWaveDeviceFormat(), StopStreaming(), UnlistSoundDeviceInstance(), UnprepareWaveHeader(), and WriteWaveHeader().

◆ ListSoundDevice()

MMRESULT ListSoundDevice ( IN MMDEVICE_TYPE  DeviceType,
IN PVOID Identifier  OPTIONAL,
OUT PSOUND_DEVICE *SoundDevice  OPTIONAL 
)

Definition at line 131 of file devicelist.c.

135{
137 PSOUND_DEVICE NewDevice;
139
141
143
144 if ( ! MMSUCCESS(Result) )
145 {
146 SND_ERR(L"Failed to allocate SOUND_DEVICE structure\n");
147 return Result;
148 }
149
150 if ( ! SoundDeviceListHeads[TypeIndex] )
151 {
152 SND_TRACE(L"Putting first entry into device list %d\n", DeviceType);
153 SoundDeviceListHeads[TypeIndex] = NewDevice;
154 SoundDeviceListTails[TypeIndex] = NewDevice;
155 }
156 else
157 {
158 SND_TRACE(L"Putting another entry into device list %d\n", DeviceType);
159 SoundDeviceListTails[TypeIndex]->Next = NewDevice;
160 SoundDeviceListTails[TypeIndex] = NewDevice;
161 }
162
163 /* Add to the count */
164 ++ SoundDeviceCounts[TypeIndex];
165
166 /* Set up the default function table */
168
169 /* Set up other members of the structure */
170 NewDevice->Identifier = Identifier;
171 NewDevice->HeadInstance = NULL;
172 NewDevice->TailInstance = NULL;
173
174 /* Fill in the caller's PSOUND_DEVICE */
175 if ( SoundDevice )
176 {
177 *SoundDevice = NewDevice;
178 }
179
180 return MMSYSERR_NOERROR;
181}
MMRESULT SetSoundDeviceFunctionTable(IN PSOUND_DEVICE SoundDevice, IN PMMFUNCTION_TABLE FunctionTable)
Definition: functiontable.c:21
PSOUND_DEVICE SoundDeviceListTails[SOUND_DEVICE_TYPES]
Definition: devicelist.c:15
MMRESULT AllocateSoundDevice(IN MMDEVICE_TYPE DeviceType, OUT PSOUND_DEVICE *SoundDevice)
Definition: devicelist.c:21
PVOID Identifier
Definition: mmebuddy.h:274
struct _SOUND_DEVICE_INSTANCE * TailInstance
Definition: mmebuddy.h:272

Referenced by FoundDevice(), and PopulateWdmDeviceList().

◆ MmeCloseDevice()

MMRESULT MmeCloseDevice ( IN DWORD_PTR  PrivateHandle)

Definition at line 225 of file mmewrap.c.

227{
229 PSOUND_DEVICE_INSTANCE SoundDeviceInstance;
230 PSOUND_DEVICE SoundDevice;
232 UINT Message = 0;
233
234 SND_TRACE(L"Closing wave device (WIDM_CLOSE / WODM_CLOSE)\n");
235
236 VALIDATE_MMSYS_PARAMETER( PrivateHandle );
237 SoundDeviceInstance = (PSOUND_DEVICE_INSTANCE) PrivateHandle;
238
239 if ( ! IsValidSoundDeviceInstance(SoundDeviceInstance) )
241
242 Result = GetSoundDeviceFromInstance(SoundDeviceInstance, &SoundDevice);
243 if ( ! MMSUCCESS(Result) )
245
246 Result = GetSoundDeviceType(SoundDevice, &DeviceType);
247 if ( ! MMSUCCESS(Result) )
249
250
251 /* TODO: Check device is stopped! */
252
253
255 {
257
266
267 /* TODO: Work with MIDI devices too */
268 NotifyMmeClient(SoundDeviceInstance,
269 Message,
270 0);
272 }
273
274 Result = DestroySoundDeviceInstance(SoundDeviceInstance);
275
276 return Result;
277}
static const WCHAR Message[]
Definition: register.c:74
struct _SOUND_DEVICE_INSTANCE * PSOUND_DEVICE_INSTANCE
VOID AcquireEntrypointMutex(IN MMDEVICE_TYPE DeviceType)
Definition: reentrancy.c:75
MMRESULT DestroySoundDeviceInstance(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance)
VOID ReleaseEntrypointMutex(IN MMDEVICE_TYPE DeviceType)
Definition: reentrancy.c:92
VOID NotifyMmeClient(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance, IN UINT Message, IN DWORD_PTR Parameter)
Definition: mmewrap.c:75
#define MIM_CLOSE
Definition: mmsystem.h:242
#define WOM_CLOSE
Definition: mmsystem.h:182
#define WIM_CLOSE
Definition: mmsystem.h:185
#define MOM_CLOSE
Definition: mmsystem.h:248
#define MMSYSERR_INVALHANDLE
Definition: mmsystem.h:101

Referenced by midMessage(), modMessage(), mxdMessage(), widMessage(), and wodMessage().

◆ MmeGetDeviceInterfaceString()

MMRESULT MmeGetDeviceInterfaceString ( IN MMDEVICE_TYPE  DeviceType,
IN DWORD  DeviceId,
IN LPWSTR  Interface,
IN DWORD  InterfaceLength,
OUT DWORD InterfaceSize 
)

Definition at line 294 of file mmewrap.c.

300{
302 PSOUND_DEVICE SoundDevice;
304
305 Result = GetSoundDevice(DeviceType, DeviceId, &SoundDevice);
306 if ( ! MMSUCCESS(Result) )
308
310 if ( ! MMSUCCESS(Result) )
312
313 if ( FunctionTable->GetDeviceInterfaceString == NULL )
314 {
315 /* querying device interface string / size not supported */
317 }
318
319 /* Call the driver */
320 Result = FunctionTable->GetDeviceInterfaceString(DeviceType, DeviceId, Interface, InterfaceLength, InterfaceSize);
321
322 return Result;
323}
MMRESULT GetSoundDevice(IN MMDEVICE_TYPE DeviceType, IN DWORD DeviceIndex, OUT PSOUND_DEVICE *Device)
Definition: devicelist.c:289
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID _Out_ PINTERFACE Interface
Definition: wdffdo.h:465

Referenced by midMessage(), modMessage(), mxdMessage(), widMessage(), and wodMessage().

◆ MmeGetPosition()

MMRESULT MmeGetPosition ( IN MMDEVICE_TYPE  DeviceType,
IN DWORD  DeviceId,
IN DWORD_PTR  PrivateHandle,
IN MMTIME Time,
IN DWORD  Size 
)

Definition at line 327 of file mmewrap.c.

333{
335 PSOUND_DEVICE_INSTANCE SoundDeviceInstance;
336 PSOUND_DEVICE SoundDevice;
338
339 VALIDATE_MMSYS_PARAMETER( PrivateHandle );
340 SoundDeviceInstance = (PSOUND_DEVICE_INSTANCE) PrivateHandle;
341
342 if ( ! IsValidSoundDeviceInstance(SoundDeviceInstance) )
344
345 Result = GetSoundDeviceFromInstance(SoundDeviceInstance, &SoundDevice);
346 if ( ! MMSUCCESS(Result) )
348
349 if ( Size != sizeof(MMTIME) )
350 return MMSYSERR_INVALPARAM;
351
353 if ( ! MMSUCCESS(Result) )
355
356 if ( FunctionTable->GetPos == NULL )
357 {
358 /* This indicates bad practice, really! If you can open, why not close?! */
360 }
361
362 /* Call the driver */
363 Result = FunctionTable->GetPos(SoundDeviceInstance, Time);
364
365 return Result;
366}
static PLARGE_INTEGER Time
Definition: time.c:105

Referenced by wodMessage().

◆ MmeGetSoundDeviceCapabilities()

MMRESULT MmeGetSoundDeviceCapabilities ( IN MMDEVICE_TYPE  DeviceType,
IN DWORD  DeviceId,
IN PVOID  Capabilities,
IN DWORD  CapabilitiesSize 
)

Definition at line 103 of file mmewrap.c.

108{
109 PSOUND_DEVICE SoundDevice;
111
112 SND_TRACE(L"MME *_GETCAPS for device %d of type %d\n", DeviceId, DeviceType);
113
114 /* FIXME: Validate device ID */
117
118 /* Our parameter checks are done elsewhere */
119
120 Result = GetSoundDevice(DeviceType, DeviceId, &SoundDevice);
121
122 if ( ! MMSUCCESS(Result) )
123 return Result;
124
125 return GetSoundDeviceCapabilities(SoundDevice,
126 DeviceId,
128 CapabilitiesSize);
129}
MMRESULT GetSoundDeviceCapabilities(IN PSOUND_DEVICE SoundDevice, IN DWORD DeviceId, OUT PVOID Capabilities, IN DWORD CapabilitiesSize)
Definition: capabilities.c:24

Referenced by auxMessage(), midMessage(), modMessage(), mxdMessage(), widMessage(), and wodMessage().

◆ MmeGetVolume()

MMRESULT MmeGetVolume ( _In_ MMDEVICE_TYPE  DeviceType,
_In_ DWORD  DeviceId,
_In_ DWORD_PTR  PrivateHandle,
_Out_ DWORD_PTR  pdwVolume 
)

Definition at line 369 of file mmewrap.c.

374{
376 PSOUND_DEVICE_INSTANCE SoundDeviceInstance;
377 PSOUND_DEVICE SoundDevice;
379
380 /* Sanity check */
384
385 VALIDATE_MMSYS_PARAMETER(PrivateHandle);
386 SoundDeviceInstance = (PSOUND_DEVICE_INSTANCE)PrivateHandle;
387
388 if (!IsValidSoundDeviceInstance(SoundDeviceInstance))
390
391 Result = GetSoundDeviceFromInstance(SoundDeviceInstance, &SoundDevice);
392 if (!MMSUCCESS(Result))
394
396 if (!MMSUCCESS(Result))
398
399 if (!FunctionTable->GetVolume)
401
402 /* Call the driver */
403 Result = FunctionTable->GetVolume(SoundDeviceInstance, DeviceId, (PDWORD)pdwVolume);
404
405 return Result;
406}
DWORD * PDWORD
Definition: pedump.c:68

Referenced by auxMessage(), modMessage(), and wodMessage().

◆ MmeOpenDevice()

MMRESULT MmeOpenDevice ( IN MMDEVICE_TYPE  DeviceType,
IN UINT  DeviceId,
IN LPWAVEOPENDESC  OpenParameters,
IN DWORD  Flags,
OUT DWORD_PTR PrivateHandle 
)

Definition at line 132 of file mmewrap.c.

138{
141 PSOUND_DEVICE SoundDevice;
142 PSOUND_DEVICE_INSTANCE SoundDeviceInstance;
144
145 SND_TRACE(L"Opening device\n");
146
148 VALIDATE_MMSYS_PARAMETER( OpenParameters );
149
150 Result = GetSoundDevice(DeviceType, DeviceId, &SoundDevice);
151 if ( ! MMSUCCESS(Result) )
153
155 {
156 Format = OpenParameters->lpFormat;
157
158 /* Does this device support the format? */
160 if ( ! MMSUCCESS(Result) )
161 {
162 SND_ERR(L"Format not supported\n");
164 }
165
166 /* If the caller just wanted to know if a format is supported, end here */
167 if ( Flags & WAVE_FORMAT_QUERY )
168 return MMSYSERR_NOERROR;
169 }
170
171 /* Check that winmm gave us a private handle to fill */
172 VALIDATE_MMSYS_PARAMETER( PrivateHandle );
173
174 /* Create a sound device instance and open the sound device */
175 Result = CreateSoundDeviceInstance(SoundDevice, &SoundDeviceInstance);
176 if ( ! MMSUCCESS(Result) )
178
179 Result = SetWaveDeviceFormat(SoundDeviceInstance, DeviceId, Format, sizeof(WAVEFORMATEX));
180 if ( ! MMSUCCESS(Result) )
181 {
182 /* TODO: Destroy sound instance */
184 }
185
186 /* Store the device instance pointer in the private handle */
187 *PrivateHandle = (DWORD_PTR)SoundDeviceInstance;
188
189 /* Store the additional information we were given - FIXME: Need flags! */
190 SetSoundDeviceInstanceMmeData(SoundDeviceInstance,
191 (HDRVR)OpenParameters->hWave, /* works because LPMIXEROPENDESC/etc has also the handle as first member */
192 OpenParameters->dwCallback,
193 OpenParameters->dwInstance,
194 Flags);
195
198 {
199 /* Let the application know the device is open */
200
207 else
209
211
212 NotifyMmeClient(SoundDeviceInstance,
213 Message,
214 0);
215
217 }
218
219 SND_TRACE(L"device now open\n");
220
221 return MMSYSERR_NOERROR;
222}
MMRESULT SetSoundDeviceInstanceMmeData(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance, IN HDRVR MmeHandle, IN DWORD_PTR ClientCallback, IN DWORD_PTR ClientCallbackData, IN DWORD Flags)
MMRESULT SetWaveDeviceFormat(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance, IN DWORD DeviceId, IN LPWAVEFORMATEX Format, IN DWORD FormatSize)
Definition: format.c:49
MMRESULT QueryWaveDeviceFormatSupport(IN PSOUND_DEVICE SoundDevice, IN LPWAVEFORMATEX Format, IN DWORD FormatSize)
Definition: format.c:14
MMRESULT CreateSoundDeviceInstance(IN PSOUND_DEVICE SoundDevice, OUT PSOUND_DEVICE_INSTANCE *SoundDeviceInstance)
#define MIM_OPEN
Definition: mmsystem.h:241
#define WOM_OPEN
Definition: mmsystem.h:181
#define WAVE_FORMAT_QUERY
Definition: mmsystem.h:188
#define MOM_OPEN
Definition: mmsystem.h:247
#define WIM_OPEN
Definition: mmsystem.h:184
#define IS_MIDI_DEVICE_TYPE(x)
Definition: sndtypes.h:49
#define IS_WAVE_DEVICE_TYPE(x)
Definition: sndtypes.h:46
#define IS_MIXER_DEVICE_TYPE(x)
Definition: sndtypes.h:55
#define DWORD_PTR
Definition: treelist.c:76
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170

Referenced by midMessage(), modMessage(), mxdMessage(), widMessage(), and wodMessage().

◆ MmeResetWavePlayback()

MMRESULT MmeResetWavePlayback ( IN DWORD_PTR  PrivateHandle)

Definition at line 280 of file mmewrap.c.

282{
283 PSOUND_DEVICE_INSTANCE SoundDeviceInstance;
284
285 SND_TRACE(L"Resetting wave device (WODM_RESET)\n");
286
287 VALIDATE_MMSYS_PARAMETER( PrivateHandle );
288 SoundDeviceInstance = (PSOUND_DEVICE_INSTANCE) PrivateHandle;
289
290 return StopStreaming(SoundDeviceInstance);
291}
MMRESULT StopStreaming(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance)
Definition: streaming.c:360

Referenced by widMessage(), and wodMessage().

◆ MmeSetState()

MMRESULT MmeSetState ( IN DWORD_PTR  PrivateHandle,
IN BOOL  bStart 
)

Definition at line 19 of file mmewrap.c.

22{
25 PSOUND_DEVICE SoundDevice;
26 PSOUND_DEVICE_INSTANCE SoundDeviceInstance;
27 BOOL OldState;
28
29 VALIDATE_MMSYS_PARAMETER( PrivateHandle );
30 SoundDeviceInstance = (PSOUND_DEVICE_INSTANCE) PrivateHandle;
31
33
34 Result = GetSoundDeviceFromInstance(SoundDeviceInstance, &SoundDevice);
35 if ( ! MMSUCCESS(Result) )
37
38 /* Get the function table, and validate it */
40 if ( ! MMSUCCESS(Result) )
42
43 SND_ASSERT( FunctionTable->SetState );
44 if ( FunctionTable->SetState == NULL )
45 {
46 /* FIXME */
48 }
49 /* Try change state */
50 Result = FunctionTable->SetState(SoundDeviceInstance, bStart);
51
52 if ( MMSUCCESS(Result) )
53 {
54 /* Get old audio stream state */
55 OldState = SoundDeviceInstance->bPaused;
56
57 /* Store audio stream pause state */
58 SoundDeviceInstance->bPaused = !bStart;
59
60 if (SoundDeviceInstance->bPaused == FALSE && OldState)
61 {
62 InitiateSoundStreaming(SoundDeviceInstance);
63 }
64 }
65
66 return Result;
67}
VOID InitiateSoundStreaming(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance)
Definition: streaming.c:409

Referenced by midMessage(), widMessage(), and wodMessage().

◆ MmeSetVolume()

MMRESULT MmeSetVolume ( _In_ MMDEVICE_TYPE  DeviceType,
_In_ DWORD  DeviceId,
_In_ DWORD_PTR  PrivateHandle,
_In_ DWORD_PTR  dwVolume 
)

Definition at line 409 of file mmewrap.c.

414{
416 PSOUND_DEVICE_INSTANCE SoundDeviceInstance;
417 PSOUND_DEVICE SoundDevice;
419
420 /* Sanity check */
424
425 VALIDATE_MMSYS_PARAMETER(PrivateHandle);
426 SoundDeviceInstance = (PSOUND_DEVICE_INSTANCE)PrivateHandle;
427
428 if (!IsValidSoundDeviceInstance(SoundDeviceInstance))
430
431 Result = GetSoundDeviceFromInstance(SoundDeviceInstance, &SoundDevice);
432 if (!MMSUCCESS(Result))
434
436 if (!MMSUCCESS(Result))
438
439 if (!FunctionTable->SetVolume)
441
442 /* Call the driver */
443 Result = FunctionTable->SetVolume(SoundDeviceInstance, DeviceId, (DWORD)dwVolume);
444
445 return Result;
446}

Referenced by auxMessage(), modMessage(), and wodMessage().

◆ NotifyMmeClient()

VOID NotifyMmeClient ( IN PSOUND_DEVICE_INSTANCE  SoundDeviceInstance,
IN UINT  Message,
IN DWORD_PTR  Parameter 
)

Definition at line 75 of file mmewrap.c.

79{
80 SND_ASSERT( SoundDeviceInstance );
81
82 SND_TRACE(L"MME client callback - message %d, parameter %d\n",
83 (int) Message,
84 (int) Parameter);
85
86 if ( SoundDeviceInstance->WinMM.ClientCallback )
87 {
88 DriverCallback(SoundDeviceInstance->WinMM.ClientCallback,
89 HIWORD(SoundDeviceInstance->WinMM.Flags),
90 SoundDeviceInstance->WinMM.Handle,
91 Message,
92 SoundDeviceInstance->WinMM.ClientCallbackInstanceData,
94 0);
95 }
96}
BOOL WINAPI DriverCallback(DWORD dwCallBack, UINT uFlags, HDRVR hDev, UINT wMsg, DWORD dwUser, DWORD dwParam1, DWORD dwParam2)
#define HIWORD(l)
Definition: typedefs.h:247

Referenced by CompleteWaveHeader(), MmeCloseDevice(), and MmeOpenDevice().

◆ OpenKernelSoundDevice()

MMRESULT OpenKernelSoundDevice ( IN PSOUND_DEVICE  SoundDevice,
IN BOOLEAN  ReadOnly,
OUT PHANDLE  Handle 
)

◆ OpenKernelSoundDeviceByName()

MMRESULT OpenKernelSoundDeviceByName ( IN PWSTR  DevicePath,
IN BOOLEAN  ReadOnly,
OUT PHANDLE  Handle 
)

Definition at line 23 of file kernel.c.

27{
28 DWORD AccessRights;
29
30 VALIDATE_MMSYS_PARAMETER( DevicePath );
32
34
35 SND_TRACE(L"OpenKernelSoundDeviceByName: %wS\n", DevicePath);
36 *Handle = CreateFile(DevicePath,
37 AccessRights,
38 FILE_SHARE_WRITE, /* FIXME? Should be read also? */
39 NULL,
42 NULL);
43
45 {
46 SND_ERR(L"CreateFile filed - winerror %d\n", GetLastError());
48 }
49
50 return MMSYSERR_NOERROR;
51}
#define OPEN_EXISTING
Definition: compat.h:775
#define GENERIC_READ
Definition: compat.h:135
#define FILE_FLAG_OVERLAPPED
Definition: disk.h:46
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define GENERIC_WRITE
Definition: nt_native.h:90
@ ReadOnly
Definition: arc.h:80
#define CreateFile
Definition: winbase.h:3774

Referenced by DetectNt4SoundDevices(), and OpenNt4KernelSoundDevice().

◆ PrepareWaveHeader()

MMRESULT PrepareWaveHeader ( IN PSOUND_DEVICE_INSTANCE  SoundDeviceInstance,
IN PWAVEHDR  Header 
)

Definition at line 89 of file header.c.

92{
94 PSOUND_DEVICE SoundDevice;
97
100
101 SND_TRACE(L"Preparing wave header\n");
102
103 Result = GetSoundDeviceFromInstance(SoundDeviceInstance, &SoundDevice);
104 if ( ! MMSUCCESS(Result) )
106
108 if ( ! MMSUCCESS(Result) )
110
112 if ( ! Extension )
113 return MMSYSERR_NOMEM;
114
115 Header->reserved = (DWORD_PTR) Extension;
116 Extension->BytesCommitted = 0;
117 Extension->BytesCompleted = 0;
118
119 /* Configure the flags */
120 Header->dwFlags |= WHDR_PREPARED;
121
122 return MMSYSERR_NOERROR;
123}

◆ QueryWaveDeviceFormatSupport()

MMRESULT QueryWaveDeviceFormatSupport ( IN PSOUND_DEVICE  SoundDevice,
IN LPWAVEFORMATEX  Format,
IN DWORD  FormatSize 
)

Definition at line 14 of file format.c.

18{
22
23 SND_TRACE(L"Querying wave format support\n");
24
27 VALIDATE_MMSYS_PARAMETER( FormatSize >= sizeof(WAVEFORMATEX) );
28
29 Result = GetSoundDeviceType(SoundDevice, &DeviceType);
31
32 /* Ensure we have a wave device (TODO: check if this applies to wavein as well) */
34
35 /* Obtain the function table */
38
39 if ( ! MMSUCCESS(Result) )
41
42 if ( ! FunctionTable->QueryWaveFormatSupport )
44
45 return FunctionTable->QueryWaveFormatSupport(SoundDevice, Format, FormatSize);
46}

Referenced by MmeOpenDevice().

◆ ReleaseEntrypointMutex()

VOID ReleaseEntrypointMutex ( IN MMDEVICE_TYPE  DeviceType)

Definition at line 92 of file reentrancy.c.

94{
95 UCHAR i;
96
99
101
103}
BOOL WINAPI DECLSPEC_HOTPATCH ReleaseMutex(IN HANDLE hMutex)
Definition: synch.c:618

Referenced by auxMessage(), midMessage(), MmeCloseDevice(), MmeOpenDevice(), modMessage(), mxdMessage(), widMessage(), and wodMessage().

◆ SetSoundDeviceFunctionTable()

MMRESULT SetSoundDeviceFunctionTable ( IN PSOUND_DEVICE  SoundDevice,
IN PMMFUNCTION_TABLE  FunctionTable 
)

Definition at line 21 of file functiontable.c.

24{
27
28 /* Zero out the existing function table (if present) */
29 ZeroMemory(&SoundDevice->FunctionTable, sizeof(MMFUNCTION_TABLE));
30
31 if ( ! FunctionTable )
33
34 /* Fill in the client-supplied functions */
35 CopyMemory(&SoundDevice->FunctionTable,
37 sizeof(MMFUNCTION_TABLE));
38
39 return MMSYSERR_NOERROR;
40}
#define CopyMemory
Definition: winbase.h:1735

Referenced by FoundDevice(), ListSoundDevice(), and PopulateWdmDeviceList().

◆ SetSoundDeviceInstanceMmeData()

MMRESULT SetSoundDeviceInstanceMmeData ( IN PSOUND_DEVICE_INSTANCE  SoundDeviceInstance,
IN HDRVR  MmeHandle,
IN DWORD_PTR  ClientCallback,
IN DWORD_PTR  ClientCallbackData,
IN DWORD  Flags 
)

Definition at line 351 of file deviceinstance.c.

357{
359
360 SND_TRACE(L"Setting MME data - handle %x, callback %x, instance data %x, flags %x\n",
361 MmeHandle, ClientCallback, ClientCallbackData, Flags);
362
363 SoundDeviceInstance->WinMM.Handle = MmeHandle;
364 SoundDeviceInstance->WinMM.ClientCallback = ClientCallback;
365 SoundDeviceInstance->WinMM.ClientCallbackInstanceData = ClientCallbackData;
366 SoundDeviceInstance->WinMM.Flags = Flags;
367
368 return MMSYSERR_NOERROR;
369}

Referenced by MmeOpenDevice().

◆ SetWaveDeviceFormat()

MMRESULT SetWaveDeviceFormat ( IN PSOUND_DEVICE_INSTANCE  SoundDeviceInstance,
IN DWORD  DeviceId,
IN LPWAVEFORMATEX  Format,
IN DWORD  FormatSize 
)

Definition at line 49 of file format.c.

54{
58 PSOUND_DEVICE SoundDevice;
59
60 SND_TRACE(L"Setting wave format\n");
61
63
64 Result = GetSoundDeviceFromInstance(SoundDeviceInstance, &SoundDevice);
65 if ( ! MMSUCCESS(Result) )
67
68 Result = GetSoundDeviceType(SoundDevice, &DeviceType);
71 {
73 VALIDATE_MMSYS_PARAMETER( FormatSize >= sizeof(WAVEFORMATEX) );
74 }
75
76 /* Ensure we have a wave device (TODO: check if this applies to wavein as well) */
78
79 /* Obtain the function table */
82
83 if ( ! MMSUCCESS(Result) )
85
86 if ( ! FunctionTable->SetWaveFormat )
88
89 return FunctionTable->SetWaveFormat(SoundDeviceInstance, DeviceId, Format, FormatSize);
90}

Referenced by MmeOpenDevice().

◆ StopStreaming()

MMRESULT StopStreaming ( IN PSOUND_DEVICE_INSTANCE  SoundDeviceInstance)

Definition at line 360 of file streaming.c.

362{
364 PSOUND_DEVICE SoundDevice;
366
367 if ( ! IsValidSoundDeviceInstance(SoundDeviceInstance) )
369
370 Result = GetSoundDeviceFromInstance(SoundDeviceInstance, &SoundDevice);
371 if ( ! MMSUCCESS(Result) )
373
374 Result = GetSoundDeviceType(SoundDevice, &DeviceType);
375 if ( ! MMSUCCESS(Result) )
377
380
381 return CallSoundThread(SoundDeviceInstance,
383 NULL);
384}
MMRESULT CallSoundThread(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance, IN SOUND_THREAD_REQUEST_HANDLER RequestHandler, IN PVOID Parameter OPTIONAL)
Definition: thread.c:71
MMRESULT StopStreamingInSoundThread(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance, IN PVOID Parameter)
Definition: streaming.c:297

Referenced by MmeResetWavePlayback().

◆ SyncOverlappedDeviceIoControl()

MMRESULT SyncOverlappedDeviceIoControl ( IN HANDLE  SoundDeviceInstance,
IN DWORD  IoControlCode,
IN LPVOID  InBuffer,
IN DWORD  InBufferSize,
OUT LPVOID  OutBuffer,
IN DWORD  OutBufferSize,
OUT LPDWORD BytesTransferred  OPTIONAL 
)

Definition at line 298 of file misc.c.

306{
307 OVERLAPPED Overlapped;
308 BOOLEAN IoResult;
309 DWORD Transferred = 0;
310
311 /* Overlapped I/O is done here - this is used for waiting for completion */
312 ZeroMemory(&Overlapped, sizeof(OVERLAPPED));
313 Overlapped.hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
314
315 if (!Overlapped.hEvent)
316 return GetLastError();
317
318 /* Talk to the device */
319 IoResult = DeviceIoControl(Handle,
321 InBuffer,
323 OutBuffer,
326 &Overlapped);
327
328 /* If failure occurs, make sure it's not just due to the overlapped I/O */
329 if (!IoResult)
330 {
332 {
333 CloseHandle(Overlapped.hEvent);
334 return GetLastError();
335 }
336 }
337
338 /* Wait for the I/O to complete */
339 IoResult = GetOverlappedResult(Handle,
340 &Overlapped,
341 &Transferred,
342 TRUE);
343
344 /* Don't need this any more */
345 CloseHandle(Overlapped.hEvent);
346
347 if (!IoResult)
348 return GetLastError();
349
350 if ( BytesTransferred )
351 *BytesTransferred = Transferred;
352
353 return ERROR_SUCCESS;
354}
#define ERROR_IO_PENDING
Definition: dderror.h:15
#define ERROR_SUCCESS
Definition: deptool.c:10
BOOL WINAPI DeviceIoControl(IN HANDLE hDevice, IN DWORD dwIoControlCode, IN LPVOID lpInBuffer OPTIONAL, IN DWORD nInBufferSize OPTIONAL, OUT LPVOID lpOutBuffer OPTIONAL, IN DWORD nOutBufferSize OPTIONAL, OUT LPDWORD lpBytesReturned OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: deviceio.c:136
BOOL WINAPI GetOverlappedResult(IN HANDLE hFile, IN LPOVERLAPPED lpOverlapped, OUT LPDWORD lpNumberOfBytesTransferred, IN BOOL bWait)
Definition: iocompl.c:221
_In_ UCHAR _In_ ULONG _Out_ PUCHAR _Outptr_result_bytebuffer_ OutBufferLength PVOID * OutBuffer
Definition: scsi.h:4071
HANDLE hEvent
Definition: winbase.h:845
_In_ WDFREQUEST _In_ size_t _In_ size_t _In_ ULONG IoControlCode
Definition: wdfio.h:325
_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
Definition: wdfusb.h:1342
_In_ ULONG OutBufferSize
Definition: wdfwmi.h:87
_In_ ULONG InBufferSize
Definition: wdfwmi.h:106
#define CreateEvent
Definition: winbase.h:3773

Referenced by DoDataIntersection(), GetFilterNodeProperty(), GetFilterPinCommunication(), GetFilterPinCount(), GetFilterPinDataFlow(), GetFilterPinDataRanges(), GetNt4SoundDeviceCapabilities(), IDirectSoundCaptureBufferImpl_GetCurrentPosition(), IDirectSoundCaptureBufferImpl_Start(), IDirectSoundCaptureBufferImpl_Stop(), IDirectSoundNotify_fnSetNotificationPositions(), MixerEventThreadRoutine(), MixerThreadRoutine(), PrimaryDirectSoundBuffer_GetPosition(), PrimaryDirectSoundBuffer_SetState(), QueryNt4WaveDeviceFormatSupport(), SetNt4WaveDeviceFormat(), SetPinFormat(), WdmAudCloseSoundDeviceByLegacy(), WdmAudGetCapabilitiesByLegacy(), WdmAudGetDeviceInterfaceStringByLegacy(), WdmAudGetNumWdmDevsByLegacy(), WdmAudGetWavePositionByLegacy(), WdmAudQueryMixerInfoByLegacy(), WdmAudResetStreamByLegacy(), WdmAudSetMixerDeviceFormatByLegacy(), WdmAudSetWaveDeviceFormatByLegacy(), and WdmAudSetWaveStateByLegacy().

◆ TranslateInternalMmResult()

◆ UnlistAllSoundDevices()

VOID UnlistAllSoundDevices ( VOID  )

◆ UnlistSoundDevice()

MMRESULT UnlistSoundDevice ( IN MMDEVICE_TYPE  DeviceType,
IN PSOUND_DEVICE  SoundDevice 
)

Definition at line 188 of file devicelist.c.

191{
192 PSOUND_DEVICE CurrentDevice, PreviousDevice;
193
195
198
199 PreviousDevice = NULL;
200 CurrentDevice = SoundDeviceListHeads[TypeIndex];
201
202 while ( CurrentDevice )
203 {
204 if ( CurrentDevice == SoundDevice )
205 {
206 if ( ! PreviousDevice )
207 {
208 /* This is the head node */
209 SND_TRACE(L"Removing head node from device list %d\n", DeviceType);
210 SoundDeviceListHeads[TypeIndex] =
211 SoundDeviceListHeads[TypeIndex]->Next;
212 }
213 else
214 {
215 SND_TRACE(L"Removing node from device list %d\n", DeviceType);
216 /* There are nodes before this one - cut our device out */
217 PreviousDevice->Next = CurrentDevice->Next;
218 }
219
220 if ( ! CurrentDevice->Next )
221 {
222 /* This is the tail node */
223 SND_TRACE(L"Removing tail node from device list %d\n", DeviceType);
224 SoundDeviceListTails[TypeIndex] = PreviousDevice;
225 }
226 }
227
228 PreviousDevice = CurrentDevice;
229 CurrentDevice = CurrentDevice->Next;
230 }
231
232 /* Subtract from the count */
233 -- SoundDeviceCounts[TypeIndex];
234
235 /* Finally, free up the deleted entry */
236 FreeSoundDevice(SoundDevice);
237
238 return MMSYSERR_NOERROR;
239}
BOOLEAN IsValidSoundDevice(IN PSOUND_DEVICE SoundDevice)
Definition: devicelist.c:87
VOID FreeSoundDevice(IN PSOUND_DEVICE SoundDevice)
Definition: devicelist.c:49

Referenced by UnlistSoundDevices().

◆ UnlistSoundDevices()

MMRESULT UnlistSoundDevices ( IN MMDEVICE_TYPE  DeviceType)

Definition at line 245 of file devicelist.c.

247{
248 UCHAR TypeIndex;
250
251 SND_TRACE(L"Unlisting all sound devices of type %d\n", DeviceType);
252
254
255 /* Munch away at the head of the list until it's drained */
256 while ( SoundDeviceCounts[TypeIndex] > 0 )
257 {
261 }
262
263 return MMSYSERR_NOERROR;
264}
MMRESULT UnlistSoundDevice(IN MMDEVICE_TYPE DeviceType, IN PSOUND_DEVICE SoundDevice)
Definition: devicelist.c:188

Referenced by UnlistAllSoundDevices().

◆ UnprepareWaveHeader()

MMRESULT UnprepareWaveHeader ( IN PSOUND_DEVICE_INSTANCE  SoundDeviceInstance,
IN PWAVEHDR  Header 
)

Definition at line 126 of file header.c.

129{
131 PSOUND_DEVICE SoundDevice;
134
137
138 SND_TRACE(L"Un-preparing wave header\n");
139
140 Result = GetSoundDeviceFromInstance(SoundDeviceInstance, &SoundDevice);
141 if ( ! MMSUCCESS(Result) )
143
145 if ( ! MMSUCCESS(Result) )
147
148 SND_ASSERT( Header->reserved );
149 Extension = (PWAVEHDR_EXTENSION) Header->reserved;
151
152 /* Configure the flags */
153 Header->dwFlags &= ~WHDR_PREPARED;
154
155 return MMSYSERR_NOERROR;
156}

◆ Win32ErrorToMmResult()

MMRESULT Win32ErrorToMmResult ( IN UINT  ErrorCode)

Definition at line 87 of file utility.c.

89{
90 switch ( ErrorCode )
91 {
92 case NO_ERROR :
93 case ERROR_IO_PENDING :
94 return MMSYSERR_NOERROR;
95
96 case ERROR_BUSY :
97 return MMSYSERR_ALLOCATED;
98
102
104 return MMSYSERR_NOMEM;
105
108
110 return MMSYSERR_INVALPARAM;
111
113 return MMSYSERR_INVALPARAM;
114
115
116 default :
117 return MMSYSERR_ERROR;
118 }
119}
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define NO_ERROR
Definition: dderror.h:5
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define ERROR_BUSY
Definition: dderror.h:12
#define ERROR_INVALID_FUNCTION
Definition: dderror.h:6
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define ERROR_NOT_SUPPORTED
Definition: compat.h:100
#define ERROR_ACCESS_DENIED
Definition: compat.h:97
#define MMSYSERR_ALLOCATED
Definition: mmsystem.h:100
_In_ NDIS_ERROR_CODE ErrorCode
Definition: ndis.h:4436

Referenced by CreateSoundThread(), InitEntrypointMutexes(), OpenKernelSoundDeviceByName(), and SyncOverlappedDeviceIoControl().

◆ WriteFileEx_Committer()

MMRESULT WriteFileEx_Committer ( IN PSOUND_DEVICE_INSTANCE  SoundDeviceInstance,
IN PVOID  OffsetPtr,
IN DWORD  Length,
IN PSOUND_OVERLAPPED  Overlap,
IN LPOVERLAPPED_COMPLETION_ROUTINE  CompletionRoutine 
)

Definition at line 264 of file streaming.c.

270{
272
273 VALIDATE_MMSYS_PARAMETER( SoundDeviceInstance );
274 VALIDATE_MMSYS_PARAMETER( OffsetPtr );
275 VALIDATE_MMSYS_PARAMETER( Overlap );
277
278 GetSoundDeviceInstanceHandle(SoundDeviceInstance, &Handle);
279
280 if ( ! WriteFileEx(Handle, OffsetPtr, Length, (LPOVERLAPPED)Overlap, CompletionRoutine) )
281 {
282 // TODO
283 }
284
285 return MMSYSERR_NOERROR;
286}
BOOL WINAPI WriteFileEx(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, IN LPOVERLAPPED lpOverlapped, IN LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine)
Definition: rw.c:262
MMRESULT GetSoundDeviceInstanceHandle(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance, OUT PVOID *Handle)
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
_In_ WDFREQUEST _In_opt_ PFN_WDF_REQUEST_COMPLETION_ROUTINE CompletionRoutine
Definition: wdfrequest.h:895

Referenced by FoundDevice().

◆ WriteWaveHeader()

MMRESULT WriteWaveHeader ( IN PSOUND_DEVICE_INSTANCE  SoundDeviceInstance,
IN PWAVEHDR  Header 
)

Definition at line 159 of file header.c.

162{
164 PSOUND_DEVICE SoundDevice;
166
169
170 SND_TRACE(L"Submitting wave header\n");
171
172 Result = GetSoundDeviceFromInstance(SoundDeviceInstance, &SoundDevice);
173 if ( ! MMSUCCESS(Result) )
175
177 if ( ! MMSUCCESS(Result) )
179
180 if ( ! FunctionTable->CommitWaveBuffer )
182
183 /*
184 A few minor sanity checks - any custom checks should've been carried
185 out during wave header preparation etc.
186 */
188 VALIDATE_MMSYS_PARAMETER( Header->dwBufferLength > 0 );
191
193
194 /* Clear the "done" flag for the buffer */
195 Header->dwFlags &= ~WHDR_DONE;
196
197 Result = CallSoundThread(SoundDeviceInstance,
199 Header);
200
201 return Result;
202}
MMRESULT EnqueueWaveHeader(PSOUND_DEVICE_INSTANCE SoundDeviceInstance, IN PVOID Parameter)
Definition: header.c:218
VOID SanitizeWaveHeader(PWAVEHDR Header)
Definition: header.c:64