ReactOS  0.4.14-dev-317-g96040ec
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 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 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);
UINT MMRESULT
Definition: mmsystem.h:962
_Must_inspect_result_ typedef _Out_ PHIDP_CAPS Capabilities
Definition: hidclass.h:103
unsigned long DWORD
Definition: ntddk_ex.h:95

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 388 of file mmebuddy.h.

◆ MmeUnprepareWaveHeader

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

Definition at line 391 of file mmebuddy.h.

◆ MmeWriteWaveHeader

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

Definition at line 394 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__); \
} \
}
static const WCHAR L[]
Definition: oid.c:1250
#define MMSYSERR_INVALPARAM
Definition: mmsystem.h:107

Definition at line 71 of file mmebuddy.h.

◆ ZeroWideString

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 167 of file mmebuddy.h.

◆ MMCLOSE_FUNC

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

Definition at line 159 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 172 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 137 of file mmebuddy.h.

◆ MMOPEN_FUNC

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

Definition at line 155 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 182 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 189 of file mmebuddy.h.

◆ MMSETSTATE_FUNC

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

Definition at line 177 of file mmebuddy.h.

◆ MMWAVEHEADER_FUNC

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

Definition at line 163 of file mmebuddy.h.

◆ MMWAVEQUERYFORMATSUPPORT_FUNC

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

Definition at line 144 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 149 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 231 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 130 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 }
DeviceType
Definition: mmdrv.h:41
HANDLE EntrypointMutexes[SOUND_DEVICE_TYPES]
Definition: reentrancy.c:13
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
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
#define SND_ASSERT(condition)
unsigned char UCHAR
Definition: xmlstorage.h:181
#define IS_VALID_SOUND_DEVICE_TYPE(x)
Definition: sndtypes.h:43
#define SOUND_DEVICE_TYPE_TO_INDEX(x)
Definition: mmebuddy.h:58
#define INFINITE
Definition: serial.h:102

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 }
static HANDLE ProcessHeapHandle
Definition: utility.c:13
smooth NULL
Definition: ftsmooth.c:416
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
static UINT CurrentAllocations
Definition: utility.c:14

◆ 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 }
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:733
_In_ PVOID Parameter
Definition: ldrtypes.h:241
#define VALIDATE_MMSYS_PARAMETER(parameter_condition)
Definition: mmebuddy.h:71
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
BOOLEAN IsValidSoundDeviceInstance(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance)
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
#define MMSYSERR_NOTSUPPORTED
Definition: mmsystem.h:104
static const WCHAR L[]
Definition: oid.c:1250
#define INFINITE
Definition: serial.h:102
#define SND_TRACE(...)

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

◆ CleanupEntrypointMutexes()

VOID CleanupEntrypointMutexes ( VOID  )

Referenced by DriverProc().

◆ 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:398
#define VALIDATE_MMSYS_PARAMETER(parameter_condition)
Definition: mmebuddy.h:71
_In_ HANDLE Handle
Definition: extypes.h:390
#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 157 of file streaming.c.

161 {
163  PSOUND_DEVICE SoundDevice;
164  PSOUND_DEVICE_INSTANCE SoundDeviceInstance;
166  PWAVEHDR WaveHdr;
167  PWAVEHDR_EXTENSION HdrExtension;
169  DWORD Bytes;
170 
171  WaveHdr = (PWAVEHDR) SoundOverlapped->Header;
172  SND_ASSERT( WaveHdr );
173 
174  HdrExtension = (PWAVEHDR_EXTENSION) WaveHdr->reserved;
175  SND_ASSERT( HdrExtension );
176 
177  SoundDeviceInstance = SoundOverlapped->SoundDeviceInstance;
178 
179  Result = GetSoundDeviceFromInstance(SoundDeviceInstance, &SoundDevice);
181 
182  Result = GetSoundDeviceType(SoundDevice, &DeviceType);
184 
185  do
186  {
187 
188  /* We have an available buffer now */
189  -- SoundDeviceInstance->OutstandingBuffers;
190 
191  /* Did we finish a WAVEHDR and aren't looping? */
192  if ( HdrExtension->BytesCompleted + dwNumberOfBytesTransferred >= WaveHdr->dwBufferLength &&
193  SoundOverlapped->PerformCompletion )
194  {
195  /* Wave buffer fully completed */
196  Bytes = WaveHdr->dwBufferLength - HdrExtension->BytesCompleted;
197 
198  HdrExtension->BytesCompleted += Bytes;
199  dwNumberOfBytesTransferred -= Bytes;
200 
201  CompleteWaveHeader(SoundDeviceInstance, WaveHdr);
202  SND_TRACE(L"%d/%d bytes of wavehdr completed\n", HdrExtension->BytesCompleted, WaveHdr->dwBufferLength);
203  }
204  else
205  {
206  /* Partially completed */
207  HdrExtension->BytesCompleted += dwNumberOfBytesTransferred;
208  SND_TRACE(L"%d/%d bytes of wavehdr completed\n", HdrExtension->BytesCompleted, WaveHdr->dwBufferLength);
209  break;
210  }
211 
212  /* Move to next wave header */
213  WaveHdr = WaveHdr->lpNext;
214 
215  if (!WaveHdr)
216  {
217  /* No following WaveHdr */
218  SND_ASSERT(dwNumberOfBytesTransferred == 0);
219  break;
220  }
221 
222  HdrExtension = (PWAVEHDR_EXTENSION) WaveHdr->reserved;
223  SND_ASSERT( HdrExtension );
224 
225 
226  }while(dwNumberOfBytesTransferred);
227 
228  // AUDIO-BRANCH DIFF
229  // completion callback is performed in a thread
230  DoWaveStreaming(SoundDeviceInstance);
231 
232  //CompleteWavePortion(SoundDeviceInstance, dwNumberOfBytesTransferred);
233 
235 }
struct wavehdr_tag * PWAVEHDR
static VOID FreeMemory(PCREATE_DATA Data)
Definition: create.c:134
BOOL PerformCompletion
Definition: mmebuddy.h:123
#define MMSUCCESS(result)
Definition: mmebuddy.h:80
DeviceType
Definition: mmdrv.h:41
_In_ UINT Bytes
Definition: mmcopy.h:9
UINT MMRESULT
Definition: mmsystem.h:962
struct _SOUND_DEVICE_INSTANCE * SoundDeviceInstance
Definition: mmebuddy.h:121
UCHAR MMDEVICE_TYPE
Definition: mmebuddy.h:88
#define SND_ASSERT(condition)
_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:426
DWORD BytesCompleted
Definition: mmebuddy.h:313
struct _SOUND_OVERLAPPED * PSOUND_OVERLAPPED
unsigned long DWORD
Definition: ntddk_ex.h:95
struct _WAVEHDR_EXTENSION * PWAVEHDR_EXTENSION
static const WCHAR L[]
Definition: oid.c:1250
DWORD dwBufferLength
Definition: mmsystem.h:1015
struct wavehdr_tag * lpNext
Definition: mmsystem.h:1020
_In_ HANDLE _In_ DWORD _In_ DWORD _Inout_opt_ LPOVERLAPPED lpOverlapped
Definition: mswsock.h:90
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
PWAVEHDR Header
Definition: mmebuddy.h:122
DWORD_PTR reserved
Definition: mmsystem.h:1021
MMRESULT GetSoundDeviceFromInstance(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance, OUT PSOUND_DEVICE *SoundDevice)
#define SND_TRACE(...)
VOID DoWaveStreaming(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance)
Definition: streaming.c:20

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 
297  Extension = (PWAVEHDR_EXTENSION)Header->reserved;
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,
365  (DWORD_PTR)Header);
366 }
#define WOM_DONE
Definition: mmsystem.h:183
#define MMSUCCESS(result)
Definition: mmebuddy.h:80
DeviceType
Definition: mmdrv.h:41
UINT MMRESULT
Definition: mmsystem.h:962
#define DUMP_WAVEHDR_QUEUE(sound_device_instance)
VOID NotifyMmeClient(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance, IN UINT Message, IN DWORD_PTR Parameter)
Definition: mmewrap.c:75
UCHAR MMDEVICE_TYPE
Definition: mmebuddy.h:88
Definition: Header.h:8
smooth NULL
Definition: ftsmooth.c:416
#define SND_ASSERT(condition)
_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:426
struct _WAVEHDR_EXTENSION * PWAVEHDR_EXTENSION
static const WCHAR L[]
Definition: oid.c:1250
uint32_t DWORD_PTR
Definition: typedefs.h:63
struct wavehdr_tag * lpNext
Definition: mmsystem.h:1020
MMRESULT GetSoundDeviceType(IN PSOUND_DEVICE SoundDevice, OUT PMMDEVICE_TYPE DeviceType)
Definition: devicelist.c:346
#define WHDR_INQUEUE
Definition: mmsystem.h:197
#define WHDR_DONE
Definition: mmsystem.h:193
#define WIM_DATA
Definition: mmsystem.h:186
MMRESULT GetSoundDeviceFromInstance(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance, OUT PSOUND_DEVICE *SoundDevice)
_Inout_opt_ PUNICODE_STRING Extension
Definition: fltkernel.h:1092
#define SND_TRACE(...)

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);
190  return MMSYSERR_NOTSUPPORTED;
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 }
#define MMSUCCESS(result)
Definition: mmebuddy.h:80
MMRESULT TranslateInternalMmResult(IN MMRESULT Result)
Definition: utility.c:132
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
UINT MMRESULT
Definition: mmsystem.h:962
MMRESULT CreateSoundThread(OUT PSOUND_THREAD *Thread)
Definition: thread.c:209
#define VALIDATE_MMSYS_PARAMETER(parameter_condition)
Definition: mmebuddy.h:71
MMRESULT GetSoundDeviceFunctionTable(IN PSOUND_DEVICE SoundDevice, OUT PMMFUNCTION_TABLE *FunctionTable)
Definition: functiontable.c:47
smooth NULL
Definition: ftsmooth.c:416
_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:426
MMRESULT AllocateSoundDeviceInstance(OUT PSOUND_DEVICE_INSTANCE *SoundDeviceInstance)
#define MMSYSERR_NOERROR
Definition: mmsystem.h:96
#define MMSYSERR_NOTSUPPORTED
Definition: mmsystem.h:104
static const WCHAR L[]
Definition: oid.c:1250
MMRESULT UnlistSoundDeviceInstance(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance)
MMRESULT ListSoundDeviceInstance(IN PSOUND_DEVICE SoundDevice, IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance)
BOOLEAN IsValidSoundDevice(IN PSOUND_DEVICE SoundDevice)
Definition: devicelist.c:87
static WLX_DISPATCH_VERSION_1_4 FunctionTable
Definition: wlx.c:736
VOID FreeSoundDeviceInstance(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance)
#define SND_TRACE(...)

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 }
static VOID FreeMemory(PCREATE_DATA Data)
Definition: create.c:134
#define CloseHandle
Definition: compat.h:398
MMRESULT Win32ErrorToMmResult(IN UINT ErrorCode)
Definition: utility.c:87
#define MMSUCCESS(result)
Definition: mmebuddy.h:80
MMRESULT TranslateInternalMmResult(IN MMRESULT Result)
Definition: utility.c:132
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
UINT MMRESULT
Definition: mmsystem.h:962
#define VALIDATE_MMSYS_PARAMETER(parameter_condition)
Definition: mmebuddy.h:71
#define MMSYSERR_NOMEM
Definition: mmsystem.h:103
#define CREATE_SUSPENDED
Definition: winbase.h:178
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
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:136
smooth NULL
Definition: ftsmooth.c:416
_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:426
#define MMSYSERR_NOERROR
Definition: mmsystem.h:96
#define AllocateStruct(thing)
Definition: mmebuddy.h:27
#define SND_ERR(...)
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
static const WCHAR L[]
Definition: oid.c:1250
HANDLE Handle
Definition: mmebuddy.h:237
MMRESULT CreateSoundThreadEvents(OUT HANDLE *ReadyEvent, OUT HANDLE *RequestEvent, OUT HANDLE *DoneEvent)
Definition: thread.c:151
struct _SOUND_THREAD::@3338 Events
DWORD WINAPI ResumeThread(IN HANDLE hThread)
Definition: thread.c:566
#define SND_TRACE(...)

Referenced by CreateSoundDeviceInstance().

◆ DEFINE_GETCAPS_FUNCTYPE() [1/5]

DEFINE_GETCAPS_FUNCTYPE ( MMGETCAPS_FUNC  ,
PVOID   
)

◆ DEFINE_GETCAPS_FUNCTYPE() [2/5]

DEFINE_GETCAPS_FUNCTYPE ( MMGETWAVEOUTCAPS_FUNC  ,
LPWAVEOUTCAPS   
)

◆ DEFINE_GETCAPS_FUNCTYPE() [3/5]

DEFINE_GETCAPS_FUNCTYPE ( MMGETWAVEINCAPS_FUNC  ,
LPWAVEINCAPS   
)

◆ DEFINE_GETCAPS_FUNCTYPE() [4/5]

DEFINE_GETCAPS_FUNCTYPE ( MMGETMIDIOUTCAPS_FUNC  ,
LPMIDIOUTCAPS   
)

◆ DEFINE_GETCAPS_FUNCTYPE() [5/5]

DEFINE_GETCAPS_FUNCTYPE ( MMGETMIDIINCAPS_FUNC  ,
LPMIDIINCAPS   
)

◆ 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 }
#define MMSUCCESS(result)
Definition: mmebuddy.h:80
UINT MMRESULT
Definition: mmsystem.h:962
MMRESULT DestroySoundDeviceInstance(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance)
#define SND_ASSERT(condition)
_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:426
#define MMSYSERR_NOERROR
Definition: mmsystem.h:96
struct _SOUND_DEVICE_INSTANCE * Next
Definition: mmebuddy.h:269

◆ DestroySoundDeviceInstance()

MMRESULT DestroySoundDeviceInstance ( IN PSOUND_DEVICE_INSTANCE  SoundDeviceInstance)

Definition at line 241 of file deviceinstance.c.

243 {
246  PSOUND_DEVICE SoundDevice;
247  PVOID Handle;
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?! */
270  return MMSYSERR_NOTSUPPORTED;
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 }
#define MMSUCCESS(result)
Definition: mmebuddy.h:80
MMRESULT TranslateInternalMmResult(IN MMRESULT Result)
Definition: utility.c:132
UINT MMRESULT
Definition: mmsystem.h:962
MMRESULT GetSoundDeviceFromInstance(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance, OUT PSOUND_DEVICE *SoundDevice)
#define VALIDATE_MMSYS_PARAMETER(parameter_condition)
Definition: mmebuddy.h:71
MMRESULT DestroySoundThread(IN PSOUND_THREAD Thread)
Definition: thread.c:272
MMRESULT GetSoundDeviceFunctionTable(IN PSOUND_DEVICE SoundDevice, OUT PMMFUNCTION_TABLE *FunctionTable)
Definition: functiontable.c:47
smooth NULL
Definition: ftsmooth.c:416
#define SND_ASSERT(condition)
_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:426
_In_ HANDLE Handle
Definition: extypes.h:390
#define MMSYSERR_NOERROR
Definition: mmsystem.h:96
#define MMSYSERR_NOTSUPPORTED
Definition: mmsystem.h:104
static const WCHAR L[]
Definition: oid.c:1250
MMRESULT UnlistSoundDeviceInstance(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance)
MMRESULT GetSoundDeviceInstanceHandle(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance, OUT PVOID *Handle)
static WLX_DISPATCH_VERSION_1_4 FunctionTable
Definition: wlx.c:736
VOID FreeSoundDeviceInstance(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance)
BOOLEAN IsValidSoundDeviceInstance(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance)
#define SND_TRACE(...)

Referenced by DestroyAllSoundDeviceInstances(), and MmeCloseDevice().

◆ DestroySoundThread()

MMRESULT DestroySoundThread ( IN PSOUND_THREAD  Thread)

Definition at line 272 of file thread.c.

274 {
276  SND_ASSERT( Thread->Handle != INVALID_HANDLE_VALUE );
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? */
286  Thread->Handle = INVALID_HANDLE_VALUE;
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 */
293  ZeroMemory(Thread, sizeof(SOUND_THREAD));
295 
296  SND_TRACE(L"Finished thread cleanup\n");
297 
298  return MMSYSERR_NOERROR;
299 }
static VOID FreeMemory(PCREATE_DATA Data)
Definition: create.c:134
#define CloseHandle
Definition: compat.h:398
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
#define ZeroMemory
Definition: winbase.h:1642
#define VALIDATE_MMSYS_PARAMETER(parameter_condition)
Definition: mmebuddy.h:71
MMRESULT DestroySoundThreadEvents(IN HANDLE ReadyEvent, IN HANDLE RequestEvent, IN HANDLE DoneEvent)
Definition: thread.c:190
#define SND_ASSERT(condition)
#define MMSYSERR_NOERROR
Definition: mmsystem.h:96
MMRESULT TerminateSoundThread(IN PSOUND_THREAD Thread)
Definition: thread.c:119
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
static const WCHAR L[]
Definition: oid.c:1250
#define SND_TRACE(...)

Referenced by DestroySoundDeviceInstance().

◆ DoWaveStreaming()

VOID DoWaveStreaming ( IN PSOUND_DEVICE_INSTANCE  SoundDeviceInstance)

Definition at line 20 of file streaming.c.

22 {
25  PSOUND_DEVICE SoundDevice;
28  PWAVEHDR_EXTENSION HeaderExtension;
29 
30  Result = GetSoundDeviceFromInstance(SoundDeviceInstance, &SoundDevice);
32 
33  Result = GetSoundDeviceType(SoundDevice, &DeviceType);
35 
39  SND_ASSERT( FunctionTable->CommitWaveBuffer );
40 
41  /* No point in doing anything if no resources available to use */
42  if ( SoundDeviceInstance->OutstandingBuffers >= SoundDeviceInstance->BufferCount )
43  {
44  SND_TRACE(L"DoWaveStreaming: No available buffers to stream with - doing nothing\n");
45  return;
46  }
47 
48  /* Is there any work to do? */
49  Header = SoundDeviceInstance->HeadWaveHeader;
50 
51  if ( ! Header )
52  {
53  SND_TRACE(L"DoWaveStreaming: No work to do - doing nothing\n");
54  return;
55  }
56 
57  while ( ( SoundDeviceInstance->OutstandingBuffers < SoundDeviceInstance->BufferCount ) &&
58  ( Header ) && SoundDeviceInstance->ResetInProgress == FALSE)
59  {
60  HeaderExtension = (PWAVEHDR_EXTENSION) Header->reserved;
61  SND_ASSERT( HeaderExtension );
62 
63  /* Saniy checks */
64  SND_ASSERT(Header->dwFlags & WHDR_PREPARED);
65  SND_ASSERT(Header->dwFlags & WHDR_INQUEUE);
66 
67  /* Can never be *above* the length */
68  SND_ASSERT( HeaderExtension->BytesCommitted <= Header->dwBufferLength );
69 
70  /* Is this header entirely committed? */
71  if ( HeaderExtension->BytesCommitted == Header->dwBufferLength )
72  {
73  {
74  /* Move on to the next header */
75  SND_ASSERT(Header != Header->lpNext);
76  Header = Header->lpNext;
77  }
78  }
79  else
80  {
81  PSOUND_OVERLAPPED Overlap;
82  LPVOID OffsetPtr;
83  DWORD BytesRemaining, BytesToCommit;
84  BOOL OK;
85 
86  /* Where within the header buffer to stream from */
87  OffsetPtr = Header->lpData + HeaderExtension->BytesCommitted;
88 
89  /* How much of this header has not been committed */
90  BytesRemaining = Header->dwBufferLength - HeaderExtension->BytesCommitted;
91 
92  /* We can commit anything up to the buffer size limit */
93  BytesToCommit = BytesRemaining > SoundDeviceInstance->FrameSize ?
94  SoundDeviceInstance->FrameSize :
95  BytesRemaining;
96 
97  /* Should always have something to commit by this point */
98  SND_ASSERT( BytesToCommit > 0 );
99 
100  /* We need a new overlapped info structure for each buffer */
101  Overlap = AllocateStruct(SOUND_OVERLAPPED);
102 
103  if ( Overlap )
104  {
105  ZeroMemory(Overlap, sizeof(SOUND_OVERLAPPED));
106  Overlap->SoundDeviceInstance = SoundDeviceInstance;
107  Overlap->Header = Header;
108 
109  /* Don't complete this header if it's part of a loop */
110  Overlap->PerformCompletion = TRUE;
111 // ( SoundDeviceInstance->LoopsRemaining > 0 );
112 
113  /* Adjust the commit-related counters */
114  HeaderExtension->BytesCommitted += BytesToCommit;
115  ++ SoundDeviceInstance->OutstandingBuffers;
116 
117  OK = MMSUCCESS(FunctionTable->CommitWaveBuffer(SoundDeviceInstance,
118  OffsetPtr,
119  BytesToCommit,
120  Overlap,
121  CompleteIO));
122 
123  if ( ! OK )
124  {
125  /* Clean-up and try again on the next iteration (is this OK?) */
126  SND_WARN(L"FAILED\n");
127 
128  FreeMemory(Overlap);
129  HeaderExtension->BytesCommitted -= BytesToCommit;
130  -- SoundDeviceInstance->OutstandingBuffers;
131  }
132  }
133  }
134  }
135 }
static VOID FreeMemory(PCREATE_DATA Data)
Definition: create.c:134
BOOL PerformCompletion
Definition: mmebuddy.h:123
#define OK(condition, fail_message,...)
#define TRUE
Definition: types.h:120
#define MMSUCCESS(result)
Definition: mmebuddy.h:80
DeviceType
Definition: mmdrv.h:41
DWORD BytesCommitted
Definition: mmebuddy.h:312
#define ZeroMemory
Definition: winbase.h:1642
UINT MMRESULT
Definition: mmsystem.h:962
struct _SOUND_DEVICE_INSTANCE * SoundDeviceInstance
Definition: mmebuddy.h:121
UCHAR MMDEVICE_TYPE
Definition: mmebuddy.h:88
MMRESULT GetSoundDeviceFunctionTable(IN PSOUND_DEVICE SoundDevice, OUT PMMFUNCTION_TABLE *FunctionTable)
Definition: functiontable.c:47
Definition: Header.h:8
unsigned int BOOL
Definition: ntddk_ex.h:94
#define SND_ASSERT(condition)
_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:426
#define AllocateStruct(thing)
Definition: mmebuddy.h:27
unsigned long DWORD
Definition: ntddk_ex.h:95
struct _WAVEHDR_EXTENSION * PWAVEHDR_EXTENSION
static const WCHAR L[]
Definition: oid.c:1250
#define SND_WARN(...)
MMRESULT GetSoundDeviceType(IN PSOUND_DEVICE SoundDevice, OUT PMMDEVICE_TYPE DeviceType)
Definition: devicelist.c:346
#define WHDR_INQUEUE
Definition: mmsystem.h:197
#define WHDR_PREPARED
Definition: mmsystem.h:194
PWAVEHDR Header
Definition: mmebuddy.h:122
static WLX_DISPATCH_VERSION_1_4 FunctionTable
Definition: wlx.c:736
MMRESULT GetSoundDeviceFromInstance(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance, OUT PSOUND_DEVICE *SoundDevice)
VOID CALLBACK CompleteIO(IN DWORD dwErrorCode, IN DWORD dwNumberOfBytesTransferred, IN LPOVERLAPPED lpOverlapped)
Definition: streaming.c:157
#define SND_TRACE(...)

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 }
struct wavehdr_tag * PWAVEHDR
PWAVEHDR HeadWaveHeader
Definition: mmebuddy.h:287
_In_ PVOID Parameter
Definition: ldrtypes.h:241
#define DUMP_WAVEHDR_QUEUE(sound_device_instance)
#define VALIDATE_MMSYS_PARAMETER(parameter_condition)
Definition: mmebuddy.h:71
DWORD dwFlags
Definition: mmsystem.h:1018
VOID DoWaveStreaming(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance)
Definition: streaming.c:20
smooth NULL
Definition: ftsmooth.c:416
#define SND_ASSERT(condition)
#define MMSYSERR_NOERROR
Definition: mmsystem.h:96
static const WCHAR L[]
Definition: oid.c:1250
PWAVEHDR TailWaveHeader
Definition: mmebuddy.h:292
struct wavehdr_tag * lpNext
Definition: mmsystem.h:1020
#define WHDR_INQUEUE
Definition: mmsystem.h:197
#define SND_TRACE(...)

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 }
static HANDLE ProcessHeapHandle
Definition: utility.c:13
#define SND_ASSERT(condition)
static UINT CurrentAllocations
Definition: utility.c:14
#define HeapFree(x, y, z)
Definition: compat.h:394

◆ GetDigitCount()

UINT GetDigitCount ( IN UINT  Number)

Definition at line 68 of file utility.c.

70 {
71  UINT Value = Number;
72  ULONG Digits = 1;
73 
74  while ( Value > 9 )
75  {
76  Value /= 10;
77  ++ Digits;
78  }
79 
80  return Digits;
81 }
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2343
_In_opt_ PENTER_STATE_SYSTEM_HANDLER _In_opt_ PVOID _In_ LONG _In_opt_ LONG volatile * Number
Definition: ntpoapi.h:204
unsigned int UINT
Definition: ndis.h:50
unsigned int ULONG
Definition: retypes.h:1

Referenced by DetectNt4SoundDevices(), and OpenSoundDeviceRegKey().

◆ GetMemoryAllocationCount()

UINT GetMemoryAllocationCount ( VOID  )

Referenced by DriverProc().

◆ 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);
303  return MMSYSERR_BADDEVICEID;
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 }
DeviceType
Definition: mmdrv.h:41
PSOUND_DEVICE SoundDeviceListHeads[SOUND_DEVICE_TYPES]
Definition: devicelist.c:14
#define VALIDATE_MMSYS_PARAMETER(parameter_condition)
Definition: mmebuddy.h:71
#define IsValidSoundDeviceType
Definition: mmebuddy.h:69
#define SND_ASSERT(condition)
#define MMSYSERR_NOERROR
Definition: mmsystem.h:96
#define SND_ERR(...)
unsigned long DWORD
Definition: ntddk_ex.h:95
unsigned char UCHAR
Definition: xmlstorage.h:181
struct _SOUND_DEVICE * Next
Definition: mmebuddy.h:258
static const WCHAR L[]
Definition: oid.c:1250
#define MMSYSERR_BADDEVICEID
Definition: mmsystem.h:98
ULONG SoundDeviceCounts[SOUND_DEVICE_TYPES]
Definition: devicelist.c:13
#define SOUND_DEVICE_TYPE_TO_INDEX(x)
Definition: mmebuddy.h:58
#define SND_TRACE(...)

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  }
63  case WAVE_IN_DEVICE_TYPE :
64  {
65  GoodSize = CapabilitiesSize >= sizeof(WAVEINCAPSW);
66  break;
67  }
69  {
70  GoodSize = CapabilitiesSize >= sizeof(MIDIOUTCAPSW);
71  break;
72  }
73  case MIDI_IN_DEVICE_TYPE :
74  {
75  GoodSize = CapabilitiesSize >= sizeof(MIDIINCAPSW);
76  break;
77  }
78  case AUX_DEVICE_TYPE :
79  {
80  GoodSize = CapabilitiesSize >= sizeof(AUXCAPSW);
81  break;
82  }
83  case MIXER_DEVICE_TYPE :
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");
93  return MMSYSERR_INVALPARAM;
94  }
95 
96  /* Call the "get capabilities" function within the function table */
97  SND_ASSERT( FunctionTable->GetCapabilities );
98 
99  if ( ! FunctionTable->GetCapabilities )
100  return MMSYSERR_NOTSUPPORTED;
101 
102  return FunctionTable->GetCapabilities(SoundDevice,
103  DeviceId,
104  Capabilities,
105  CapabilitiesSize);
106 }
struct tagMIXERCAPSW MIXERCAPSW
#define MMSUCCESS(result)
Definition: mmebuddy.h:80
DeviceType
Definition: mmdrv.h:41
struct tagMIDIINCAPSW MIDIINCAPSW
MMRESULT TranslateInternalMmResult(IN MMRESULT Result)
Definition: utility.c:132
UINT MMRESULT
Definition: mmsystem.h:962
#define VALIDATE_MMSYS_PARAMETER(parameter_condition)
Definition: mmebuddy.h:71
UCHAR MMDEVICE_TYPE
Definition: mmebuddy.h:88
MMRESULT GetSoundDeviceFunctionTable(IN PSOUND_DEVICE SoundDevice, OUT PMMFUNCTION_TABLE *FunctionTable)
Definition: functiontable.c:47
_Must_inspect_result_ typedef _Out_ PHIDP_CAPS Capabilities
Definition: hidclass.h:103
struct tagWAVEINCAPSW WAVEINCAPSW
unsigned char BOOLEAN
#define SND_ASSERT(condition)
_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:426
#define MMSYSERR_NOERROR
Definition: mmsystem.h:96
struct tagAUXCAPSW AUXCAPSW
#define SND_ERR(...)
#define MMSYSERR_NOTSUPPORTED
Definition: mmsystem.h:104
struct tagMIDIOUTCAPSW MIDIOUTCAPSW
static const WCHAR L[]
Definition: oid.c:1250
BOOLEAN IsValidSoundDevice(IN PSOUND_DEVICE SoundDevice)
Definition: devicelist.c:87
MMRESULT GetSoundDeviceType(IN PSOUND_DEVICE SoundDevice, OUT PMMDEVICE_TYPE DeviceType)
Definition: devicelist.c:346
#define MMSYSERR_INVALPARAM
Definition: mmsystem.h:107
#define IS_VALID_SOUND_DEVICE_TYPE(x)
Definition: sndtypes.h:43
static WLX_DISPATCH_VERSION_1_4 FunctionTable
Definition: wlx.c:736
struct tagWAVEOUTCAPSW WAVEOUTCAPSW

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]);
78  return SoundDeviceCounts[Index];
79 }
DeviceType
Definition: mmdrv.h:41
#define IsValidSoundDeviceType
Definition: mmebuddy.h:69
static const UCHAR Index[8]
Definition: usbohci.c:18
static const WCHAR L[]
Definition: oid.c:1250
ULONG SoundDeviceCounts[SOUND_DEVICE_TYPES]
Definition: devicelist.c:13
unsigned int ULONG
Definition: retypes.h:1
#define SOUND_DEVICE_TYPE_TO_INDEX(x)
Definition: mmebuddy.h:58
#define SND_TRACE(...)

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

◆ GetSoundDeviceFromInstance()

◆ GetSoundDeviceFunctionTable()

MMRESULT GetSoundDeviceFunctionTable ( IN PSOUND_DEVICE  SoundDevice,
OUT PMMFUNCTION_TABLE FunctionTable 
)

Definition at line 47 of file functiontable.c.

50 {
53 
54  *FunctionTable = &SoundDevice->FunctionTable;
55 
56  return MMSYSERR_NOERROR;
57 }
#define VALIDATE_MMSYS_PARAMETER(parameter_condition)
Definition: mmebuddy.h:71
#define MMSYSERR_NOERROR
Definition: mmsystem.h:96
BOOLEAN IsValidSoundDevice(IN PSOUND_DEVICE SoundDevice)
Definition: devicelist.c:87
static WLX_DISPATCH_VERSION_1_4 FunctionTable
Definition: wlx.c:736

Referenced by CreateSoundDeviceInstance(), DestroySoundDeviceInstance(), DoWaveStreaming(), GetSoundDeviceCapabilities(), MmeGetDeviceInterfaceString(), MmeGetLineInfo(), MmeGetPosition(), MmeSetState(), PrepareWaveHeader(), QueryWaveDeviceFormatSupport(), SetWaveDeviceFormat(), StopStreamingInSoundThread(), UnprepareWaveHeader(), and WriteWaveHeader().

◆ 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 }
PVOID Identifier
Definition: mmebuddy.h:262
#define VALIDATE_MMSYS_PARAMETER(parameter_condition)
Definition: mmebuddy.h:71
#define MMSYSERR_NOERROR
Definition: mmsystem.h:96

Referenced by OpenNt4KernelSoundDevice(), and WdmAudSetWaveDeviceFormatByLegacy().

◆ GetSoundDeviceInstanceHandle()

MMRESULT GetSoundDeviceInstanceHandle ( IN PSOUND_DEVICE_INSTANCE  SoundDeviceInstance,
OUT PVOID Handle 
)

Definition at line 338 of file deviceinstance.c.

341 {
344 
345  *Handle = SoundDeviceInstance->Handle;
346 
347  return MMSYSERR_NOERROR;
348 }
#define VALIDATE_MMSYS_PARAMETER(parameter_condition)
Definition: mmebuddy.h:71
_In_ HANDLE Handle
Definition: extypes.h:390
#define MMSYSERR_NOERROR
Definition: mmsystem.h:96
BOOLEAN IsValidSoundDeviceInstance(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance)

Referenced by DestroySoundDeviceInstance(), SetNt4WaveDeviceFormat(), WdmAudCommitWaveBufferByLegacy(), WdmAudGetWavePositionByLegacy(), WdmAudQueryMixerInfoByLegacy(), WdmAudResetStreamByLegacy(), WdmAudSetWaveStateByLegacy(), WriteFileEx_Committer(), and WriteFileEx_Remixer().

◆ GetSoundDeviceType()

◆ InitEntrypointMutexes()

MMRESULT InitEntrypointMutexes ( VOID  )

Referenced by DriverProc().

◆ InitiateSoundStreaming()

VOID InitiateSoundStreaming ( IN PSOUND_DEVICE_INSTANCE  SoundDeviceInstance)

Definition at line 383 of file streaming.c.

385 {
386  HANDLE hThread;
387 
388  hThread = CreateThread(NULL, 0, WaveActivateSoundStreaming, (PVOID)SoundDeviceInstance, 0, NULL);
389 
390  if (hThread != NULL)
392 }
#define CloseHandle
Definition: compat.h:398
DWORD WINAPI WaveActivateSoundStreaming(IN PVOID lpParameter)
Definition: streaming.c:372
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:136
smooth NULL
Definition: ftsmooth.c:416
HANDLE hThread
Definition: wizard.c:27

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
PSOUND_DEVICE SoundDeviceListHeads[SOUND_DEVICE_TYPES]
Definition: devicelist.c:14
unsigned char UCHAR
Definition: xmlstorage.h:181
struct _SOUND_DEVICE * Next
Definition: mmebuddy.h:258

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 }
#define TRUE
Definition: types.h:120
#define SND_ASSERT(condition)
struct _SOUND_DEVICE_INSTANCE * HeadInstance
Definition: mmebuddy.h:259
struct _SOUND_DEVICE_INSTANCE * Next
Definition: mmebuddy.h:269

Referenced by CallSoundThread(), CloseNt4SoundDevice(), DestroySoundDeviceInstance(), GetSoundDeviceFromInstance(), GetSoundDeviceInstanceHandle(), MmeCloseDevice(), MmeGetPosition(), MmeSetState(), 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 
142  Result = AllocateSoundDevice(DeviceType, &NewDevice);
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 */
167  SetSoundDeviceFunctionTable(NewDevice, NULL);
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 }
struct _SOUND_DEVICE_INSTANCE * TailInstance
Definition: mmebuddy.h:260
MMRESULT SetSoundDeviceFunctionTable(IN PSOUND_DEVICE SoundDevice, IN PMMFUNCTION_TABLE FunctionTable)
Definition: functiontable.c:21
#define MMSUCCESS(result)
Definition: mmebuddy.h:80
DeviceType
Definition: mmdrv.h:41
PSOUND_DEVICE SoundDeviceListHeads[SOUND_DEVICE_TYPES]
Definition: devicelist.c:14
UINT MMRESULT
Definition: mmsystem.h:962
PVOID Identifier
Definition: mmebuddy.h:262
#define VALIDATE_MMSYS_PARAMETER(parameter_condition)
Definition: mmebuddy.h:71
#define IsValidSoundDeviceType
Definition: mmebuddy.h:69
smooth NULL
Definition: ftsmooth.c:416
_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:426
struct _SOUND_DEVICE_INSTANCE * HeadInstance
Definition: mmebuddy.h:259
#define MMSYSERR_NOERROR
Definition: mmsystem.h:96
#define SND_ERR(...)
unsigned char UCHAR
Definition: xmlstorage.h:181
struct _SOUND_DEVICE * Next
Definition: mmebuddy.h:258
static const WCHAR L[]
Definition: oid.c:1250
PSOUND_DEVICE SoundDeviceListTails[SOUND_DEVICE_TYPES]
Definition: devicelist.c:15
ULONG SoundDeviceCounts[SOUND_DEVICE_TYPES]
Definition: devicelist.c:13
#define SOUND_DEVICE_TYPE_TO_INDEX(x)
Definition: mmebuddy.h:58
MMRESULT AllocateSoundDevice(IN MMDEVICE_TYPE DeviceType, OUT PSOUND_DEVICE *SoundDevice)
Definition: devicelist.c:21
#define SND_TRACE(...)

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) )
240  return MMSYSERR_INVALHANDLE;
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 
259  Message = WOM_CLOSE;
260  else if (DeviceType == WAVE_IN_DEVICE_TYPE)
261  Message = WIM_CLOSE;
262  else if (DeviceType == MIDI_IN_DEVICE_TYPE)
263  Message = MIM_CLOSE;
264  else if (DeviceType == MIDI_OUT_DEVICE_TYPE)
265  Message = MOM_CLOSE;
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 }
#define MMSUCCESS(result)
Definition: mmebuddy.h:80
DeviceType
Definition: mmdrv.h:41
#define MIM_CLOSE
Definition: mmsystem.h:242
MMRESULT TranslateInternalMmResult(IN MMRESULT Result)
Definition: utility.c:132
UINT MMRESULT
Definition: mmsystem.h:962
#define MMSYSERR_INVALHANDLE
Definition: mmsystem.h:101
#define VALIDATE_MMSYS_PARAMETER(parameter_condition)
Definition: mmebuddy.h:71
struct _SOUND_DEVICE_INSTANCE * PSOUND_DEVICE_INSTANCE
UCHAR MMDEVICE_TYPE
Definition: mmebuddy.h:88
#define WOM_CLOSE
Definition: mmsystem.h:182
#define WIM_CLOSE
Definition: mmsystem.h:185
VOID AcquireEntrypointMutex(IN MMDEVICE_TYPE DeviceType)
Definition: reentrancy.c:75
_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:426
BOOLEAN IsValidSoundDeviceInstance(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance)
CHAR Message[80]
Definition: alive.c:5
#define MOM_CLOSE
Definition: mmsystem.h:248
MMRESULT DestroySoundDeviceInstance(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance)
static const WCHAR L[]
Definition: oid.c:1250
MMRESULT GetSoundDeviceType(IN PSOUND_DEVICE SoundDevice, OUT PMMDEVICE_TYPE DeviceType)
Definition: devicelist.c:346
unsigned int UINT
Definition: ndis.h:50
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
MMRESULT GetSoundDeviceFromInstance(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance, OUT PSOUND_DEVICE *SoundDevice)
#define SND_TRACE(...)

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 */
316  return MMSYSERR_NOTSUPPORTED;
317  }
318 
319  /* Call the driver */
320  Result = FunctionTable->GetDeviceInterfaceString(DeviceType, DeviceId, Interface, InterfaceLength, InterfaceSize);
321 
322  return Result;
323 }
#define MMSUCCESS(result)
Definition: mmebuddy.h:80
DeviceType
Definition: mmdrv.h:41
MMRESULT TranslateInternalMmResult(IN MMRESULT Result)
Definition: utility.c:132
UINT MMRESULT
Definition: mmsystem.h:962
MMRESULT GetSoundDevice(IN MMDEVICE_TYPE DeviceType, IN DWORD DeviceIndex, OUT PSOUND_DEVICE *Device)
Definition: devicelist.c:289
MMRESULT GetSoundDeviceFunctionTable(IN PSOUND_DEVICE SoundDevice, OUT PMMFUNCTION_TABLE *FunctionTable)
Definition: functiontable.c:47
smooth NULL
Definition: ftsmooth.c:416
_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:426
IN PVOID IN PVOID IN USHORT IN USHORT IN PINTERFACE Interface
Definition: pci.h:359
#define MMSYSERR_NOTSUPPORTED
Definition: mmsystem.h:104
static WLX_DISPATCH_VERSION_1_4 FunctionTable
Definition: wlx.c:736

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) )
343  return MMSYSERR_INVALHANDLE;
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?! */
359  return MMSYSERR_NOTSUPPORTED;
360  }
361 
362  /* Call the driver */
363  Result = FunctionTable->GetPos(SoundDeviceInstance, Time);
364 
365  return Result;
366 }
#define MMSUCCESS(result)
Definition: mmebuddy.h:80
MMRESULT TranslateInternalMmResult(IN MMRESULT Result)
Definition: utility.c:132
UINT MMRESULT
Definition: mmsystem.h:962
#define MMSYSERR_INVALHANDLE
Definition: mmsystem.h:101
#define VALIDATE_MMSYS_PARAMETER(parameter_condition)
Definition: mmebuddy.h:71
struct _SOUND_DEVICE_INSTANCE * PSOUND_DEVICE_INSTANCE
MMRESULT GetSoundDeviceFunctionTable(IN PSOUND_DEVICE SoundDevice, OUT PMMFUNCTION_TABLE *FunctionTable)
Definition: functiontable.c:47
smooth NULL
Definition: ftsmooth.c:416
_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:426
BOOLEAN IsValidSoundDeviceInstance(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance)
#define MMSYSERR_NOTSUPPORTED
Definition: mmsystem.h:104
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
#define MMSYSERR_INVALPARAM
Definition: mmsystem.h:107
static WLX_DISPATCH_VERSION_1_4 FunctionTable
Definition: wlx.c:736
MMRESULT GetSoundDeviceFromInstance(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance, OUT PSOUND_DEVICE *SoundDevice)
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,
127  Capabilities,
128  CapabilitiesSize);
129 }
#define MMSUCCESS(result)
Definition: mmebuddy.h:80
DeviceType
Definition: mmdrv.h:41
UINT MMRESULT
Definition: mmsystem.h:962
MMRESULT GetSoundDevice(IN MMDEVICE_TYPE DeviceType, IN DWORD DeviceIndex, OUT PSOUND_DEVICE *Device)
Definition: devicelist.c:289
#define VALIDATE_MMSYS_PARAMETER(parameter_condition)
Definition: mmebuddy.h:71
_Must_inspect_result_ typedef _Out_ PHIDP_CAPS Capabilities
Definition: hidclass.h:103
_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:426
static const WCHAR L[]
Definition: oid.c:1250
#define IS_VALID_SOUND_DEVICE_TYPE(x)
Definition: sndtypes.h:43
#define SND_TRACE(...)
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().

◆ 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 {
140  UINT Message;
141  PSOUND_DEVICE SoundDevice;
142  PSOUND_DEVICE_INSTANCE SoundDeviceInstance;
144 
145  SND_TRACE(L"Opening device");
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? */
159  Result = QueryWaveDeviceFormatSupport(SoundDevice, Format, sizeof(WAVEFORMATEX));
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 
202  Message = WOM_OPEN;
203  else if (DeviceType == WAVE_IN_DEVICE_TYPE)
204  Message = WIM_OPEN;
205  else if (DeviceType == MIDI_IN_DEVICE_TYPE)
206  Message = MIM_OPEN;
207  else
208  Message = MOM_OPEN;
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 }
#define WAVE_FORMAT_QUERY
Definition: mmsystem.h:188
#define DWORD_PTR
Definition: treelist.c:76
#define MMSUCCESS(result)
Definition: mmebuddy.h:80
DeviceType
Definition: mmdrv.h:41
MMRESULT SetWaveDeviceFormat(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance, IN DWORD DeviceId, IN LPWAVEFORMATEX Format, IN DWORD FormatSize)
Definition: format.c:49
MMRESULT TranslateInternalMmResult(IN MMRESULT Result)
Definition: utility.c:132
UINT MMRESULT
Definition: mmsystem.h:962
#define IS_MIDI_DEVICE_TYPE(x)
Definition: sndtypes.h:49
MMRESULT QueryWaveDeviceFormatSupport(IN PSOUND_DEVICE SoundDevice, IN LPWAVEFORMATEX Format, IN DWORD FormatSize)
Definition: format.c:14
MMRESULT GetSoundDevice(IN MMDEVICE_TYPE DeviceType, IN DWORD DeviceIndex, OUT PSOUND_DEVICE *Device)
Definition: devicelist.c:289
#define WOM_OPEN
Definition: mmsystem.h:181
MMRESULT SetSoundDeviceInstanceMmeData(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance, IN HDRVR MmeHandle, IN DWORD_PTR ClientCallback, IN DWORD_PTR ClientCallbackData, IN DWORD Flags)
#define VALIDATE_MMSYS_PARAMETER(parameter_condition)
Definition: mmebuddy.h:71
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
VOID AcquireEntrypointMutex(IN MMDEVICE_TYPE DeviceType)
Definition: reentrancy.c:75
#define WIM_OPEN
Definition: mmsystem.h:184
smooth NULL
Definition: ftsmooth.c:416
_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:426
MMRESULT CreateSoundDeviceInstance(IN PSOUND_DEVICE SoundDevice, OUT PSOUND_DEVICE_INSTANCE *SoundDeviceInstance)
#define IS_WAVE_DEVICE_TYPE(x)
Definition: sndtypes.h:46
#define MIM_OPEN
Definition: mmsystem.h:241
#define MOM_OPEN
Definition: mmsystem.h:247
#define MMSYSERR_NOERROR
Definition: mmsystem.h:96
#define SND_ERR(...)
CHAR Message[80]
Definition: alive.c:5
static const WCHAR L[]
Definition: oid.c:1250
#define IS_MIXER_DEVICE_TYPE(x)
Definition: sndtypes.h:55
unsigned int UINT
Definition: ndis.h:50
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 SND_TRACE(...)

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:334
#define VALIDATE_MMSYS_PARAMETER(parameter_condition)
Definition: mmebuddy.h:71
struct _SOUND_DEVICE_INSTANCE * PSOUND_DEVICE_INSTANCE
static const WCHAR L[]
Definition: oid.c:1250
#define SND_TRACE(...)

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 */
47  return MMSYSERR_NOTSUPPORTED;
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:383
#define MMSUCCESS(result)
Definition: mmebuddy.h:80
MMRESULT TranslateInternalMmResult(IN MMRESULT Result)
Definition: utility.c:132
UINT MMRESULT
Definition: mmsystem.h:962
#define VALIDATE_MMSYS_PARAMETER(parameter_condition)
Definition: mmebuddy.h:71
struct _SOUND_DEVICE_INSTANCE * PSOUND_DEVICE_INSTANCE
MMRESULT GetSoundDeviceFunctionTable(IN PSOUND_DEVICE SoundDevice, OUT PMMFUNCTION_TABLE *FunctionTable)
Definition: functiontable.c:47
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
#define SND_ASSERT(condition)
_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:426
BOOLEAN IsValidSoundDeviceInstance(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance)
#define MMSYSERR_NOTSUPPORTED
Definition: mmsystem.h:104
static WLX_DISPATCH_VERSION_1_4 FunctionTable
Definition: wlx.c:736
MMRESULT GetSoundDeviceFromInstance(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance, OUT PSOUND_DEVICE *SoundDevice)

Referenced by midMessage(), widMessage(), 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,
93  Parameter,
94  0);
95  }
96 }
_In_ PVOID Parameter
Definition: ldrtypes.h:241
#define SND_ASSERT(condition)
CHAR Message[80]
Definition: alive.c:5
static const WCHAR L[]
Definition: oid.c:1250
#define HIWORD(l)
Definition: typedefs.h:246
BOOL WINAPI DriverCallback(DWORD dwCallBack, UINT uFlags, HDRVR hDev, UINT wMsg, DWORD dwUser, DWORD dwParam1, DWORD dwParam2)
#define SND_TRACE(...)

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 
33  AccessRights = ReadOnly ? GENERIC_READ : GENERIC_READ | GENERIC_WRITE;
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 
44  if ( *Handle == INVALID_HANDLE_VALUE )
45  {
46  SND_ERR(L"CreateFile filed - winerror %d\n", GetLastError());
48  }
49 
50  return MMSYSERR_NOERROR;
51 }
MMRESULT Win32ErrorToMmResult(IN UINT ErrorCode)
Definition: utility.c:87
Definition: arc.h:80
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define VALIDATE_MMSYS_PARAMETER(parameter_condition)
Definition: mmebuddy.h:71
#define GENERIC_WRITE
Definition: nt_native.h:90
smooth NULL
Definition: ftsmooth.c:416
#define OPEN_EXISTING
Definition: compat.h:426
_In_ HANDLE Handle
Definition: extypes.h:390
#define MMSYSERR_NOERROR
Definition: mmsystem.h:96
#define SND_ERR(...)
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
#define GENERIC_READ
Definition: compat.h:124
IN OUT PVCB OUT PDIRENT OUT PBCB IN BOOLEAN CreateFile
Definition: fatprocs.h:904
#define FILE_FLAG_OVERLAPPED
Definition: disk.h:46
#define SND_TRACE(...)

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 }
#define DWORD_PTR
Definition: treelist.c:76
#define MMSUCCESS(result)
Definition: mmebuddy.h:80
MMRESULT TranslateInternalMmResult(IN MMRESULT Result)
Definition: utility.c:132
UINT MMRESULT
Definition: mmsystem.h:962
#define VALIDATE_MMSYS_PARAMETER(parameter_condition)
Definition: mmebuddy.h:71
MMRESULT GetSoundDeviceFunctionTable(IN PSOUND_DEVICE SoundDevice, OUT PMMFUNCTION_TABLE *FunctionTable)
Definition: functiontable.c:47
#define MMSYSERR_NOMEM
Definition: mmsystem.h:103
Definition: Header.h:8
_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:426
BOOLEAN IsValidSoundDeviceInstance(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance)
#define MMSYSERR_NOERROR
Definition: mmsystem.h:96
#define AllocateStruct(thing)
Definition: mmebuddy.h:27
static const WCHAR L[]
Definition: oid.c:1250
#define WHDR_PREPARED
Definition: mmsystem.h:194
static WLX_DISPATCH_VERSION_1_4 FunctionTable
Definition: wlx.c:736
MMRESULT GetSoundDeviceFromInstance(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance, OUT PSOUND_DEVICE *SoundDevice)
_Inout_opt_ PUNICODE_STRING Extension
Definition: fltkernel.h:1092
#define SND_TRACE(...)

◆ 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 )
43  return MMSYSERR_NOTSUPPORTED;
44 
45  return FunctionTable->QueryWaveFormatSupport(SoundDevice, Format, FormatSize);
46 }
#define MMSUCCESS(result)
Definition: mmebuddy.h:80
DeviceType
Definition: mmdrv.h:41
MMRESULT TranslateInternalMmResult(IN MMRESULT Result)
Definition: utility.c:132
UINT MMRESULT
Definition: mmsystem.h:962
#define VALIDATE_MMSYS_PARAMETER(parameter_condition)
Definition: mmebuddy.h:71
UCHAR MMDEVICE_TYPE
Definition: mmebuddy.h:88
MMRESULT GetSoundDeviceFunctionTable(IN PSOUND_DEVICE SoundDevice, OUT PMMFUNCTION_TABLE *FunctionTable)
Definition: functiontable.c:47
#define SND_ASSERT(condition)
_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:426
#define IS_WAVE_DEVICE_TYPE(x)
Definition: sndtypes.h:46
#define MMSYSERR_NOERROR
Definition: mmsystem.h:96
#define MMSYSERR_NOTSUPPORTED
Definition: mmsystem.h:104
static const WCHAR L[]
Definition: oid.c:1250
BOOLEAN IsValidSoundDevice(IN PSOUND_DEVICE SoundDevice)
Definition: devicelist.c:87
MMRESULT GetSoundDeviceType(IN PSOUND_DEVICE SoundDevice, OUT PMMDEVICE_TYPE DeviceType)
Definition: devicelist.c:346
static WLX_DISPATCH_VERSION_1_4 FunctionTable
Definition: wlx.c:736
#define SND_TRACE(...)

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 }
DeviceType
Definition: mmdrv.h:41
HANDLE EntrypointMutexes[SOUND_DEVICE_TYPES]
Definition: reentrancy.c:13
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
#define SND_ASSERT(condition)
BOOL WINAPI DECLSPEC_HOTPATCH ReleaseMutex(IN HANDLE hMutex)
Definition: synch.c:618
unsigned char UCHAR
Definition: xmlstorage.h:181
#define IS_VALID_SOUND_DEVICE_TYPE(x)
Definition: sndtypes.h:43
#define SOUND_DEVICE_TYPE_TO_INDEX(x)
Definition: mmebuddy.h:58

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 )
32  return MMSYSERR_INVALPARAM;
33 
34  /* Fill in the client-supplied functions */
35  CopyMemory(&SoundDevice->FunctionTable,
37  sizeof(MMFUNCTION_TABLE));
38 
39  return MMSYSERR_NOERROR;
40 }
#define ZeroMemory
Definition: winbase.h:1642
#define VALIDATE_MMSYS_PARAMETER(parameter_condition)
Definition: mmebuddy.h:71
#define MMSYSERR_NOERROR
Definition: mmsystem.h:96
#define CopyMemory
Definition: winbase.h:1640
BOOLEAN IsValidSoundDevice(IN PSOUND_DEVICE SoundDevice)
Definition: devicelist.c:87
#define MMSYSERR_INVALPARAM
Definition: mmsystem.h:107
static WLX_DISPATCH_VERSION_1_4 FunctionTable
Definition: wlx.c:736

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 }
#define VALIDATE_MMSYS_PARAMETER(parameter_condition)
Definition: mmebuddy.h:71
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
#define MMSYSERR_NOERROR
Definition: mmsystem.h:96
static const WCHAR L[]
Definition: oid.c:1250
BOOLEAN IsValidSoundDeviceInstance(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance)
#define SND_TRACE(...)

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 )
87  return MMSYSERR_NOTSUPPORTED;
88 
89  return FunctionTable->SetWaveFormat(SoundDeviceInstance, DeviceId, Format, FormatSize);
90 }
#define MMSUCCESS(result)
Definition: mmebuddy.h:80
DeviceType
Definition: mmdrv.h:41
MMRESULT TranslateInternalMmResult(IN MMRESULT Result)
Definition: utility.c:132
UINT MMRESULT
Definition: mmsystem.h:962
#define IS_MIDI_DEVICE_TYPE(x)
Definition: sndtypes.h:49
#define VALIDATE_MMSYS_PARAMETER(parameter_condition)
Definition: mmebuddy.h:71
UCHAR MMDEVICE_TYPE
Definition: mmebuddy.h:88
MMRESULT GetSoundDeviceFunctionTable(IN PSOUND_DEVICE SoundDevice, OUT PMMFUNCTION_TABLE *FunctionTable)
Definition: functiontable.c:47
#define SND_ASSERT(condition)
_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:426
#define IS_WAVE_DEVICE_TYPE(x)
Definition: sndtypes.h:46
BOOLEAN IsValidSoundDeviceInstance(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance)
#define MMSYSERR_NOERROR
Definition: mmsystem.h:96
#define MMSYSERR_NOTSUPPORTED
Definition: mmsystem.h:104
static const WCHAR L[]
Definition: oid.c:1250
#define IS_MIXER_DEVICE_TYPE(x)
Definition: sndtypes.h:55
MMRESULT GetSoundDeviceType(IN PSOUND_DEVICE SoundDevice, OUT PMMDEVICE_TYPE DeviceType)
Definition: devicelist.c:346
static WLX_DISPATCH_VERSION_1_4 FunctionTable
Definition: wlx.c:736
MMRESULT GetSoundDeviceFromInstance(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance, OUT PSOUND_DEVICE *SoundDevice)
#define SND_TRACE(...)

Referenced by MmeOpenDevice().

◆ StopStreaming()

MMRESULT StopStreaming ( IN PSOUND_DEVICE_INSTANCE  SoundDeviceInstance)

Definition at line 334 of file streaming.c.

336 {
338  PSOUND_DEVICE SoundDevice;
340 
341  if ( ! IsValidSoundDeviceInstance(SoundDeviceInstance) )
342  return MMSYSERR_INVALHANDLE;
343 
344  Result = GetSoundDeviceFromInstance(SoundDeviceInstance, &SoundDevice);
345  if ( ! MMSUCCESS(Result) )
347 
348  Result = GetSoundDeviceType(SoundDevice, &DeviceType);
349  if ( ! MMSUCCESS(Result) )
351 
353  return MMSYSERR_NOTSUPPORTED;
354 
355  return CallSoundThread(SoundDeviceInstance,
357  NULL);
358 }
MMRESULT CallSoundThread(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance, IN SOUND_THREAD_REQUEST_HANDLER RequestHandler, IN PVOID Parameter OPTIONAL)
Definition: thread.c:71
#define MMSUCCESS(result)
Definition: mmebuddy.h:80
DeviceType
Definition: mmdrv.h:41
MMRESULT TranslateInternalMmResult(IN MMRESULT Result)
Definition: utility.c:132
UINT MMRESULT
Definition: mmsystem.h:962
#define MMSYSERR_INVALHANDLE
Definition: mmsystem.h:101
UCHAR MMDEVICE_TYPE
Definition: mmebuddy.h:88
smooth NULL
Definition: ftsmooth.c:416
_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:426
BOOLEAN IsValidSoundDeviceInstance(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance)
#define MMSYSERR_NOTSUPPORTED
Definition: mmsystem.h:104
MMRESULT GetSoundDeviceType(IN PSOUND_DEVICE SoundDevice, OUT PMMDEVICE_TYPE DeviceType)
Definition: devicelist.c:346
MMRESULT StopStreamingInSoundThread(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance, IN PVOID Parameter)
Definition: streaming.c:271
MMRESULT GetSoundDeviceFromInstance(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance, OUT PSOUND_DEVICE *SoundDevice)

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,
322  InBufferSize,
323  OutBuffer,
325  BytesTransferred,
326  &Overlapped);
327 
328  /* If failure occurs, make sure it's not just due to the overlapped I/O */
329  if (!IoResult)
330  {
331  if ( GetLastError() != ERROR_IO_PENDING )
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 CreateEvent
Definition: winbase.h:3572
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:398
_Must_inspect_result_ _In_ PFILE_OBJECT _In_ ULONG IoControlCode
Definition: fltkernel.h:1383
#define ERROR_SUCCESS
Definition: deptool.c:10
BOOL WINAPI GetOverlappedResult(IN HANDLE hFile, IN LPOVERLAPPED lpOverlapped, OUT LPDWORD lpNumberOfBytesTransferred, IN BOOL bWait)
Definition: iocompl.c:204
_In_ PIRP _In_ ULONG _In_ ULONG _In_ ULONG _In_ ULONG OutBufferSize
Definition: classpnp.h:429
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define ZeroMemory
Definition: winbase.h:1642
#define ERROR_IO_PENDING
Definition: dderror.h:15
HANDLE hEvent
Definition: winbase.h:792
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
_In_ HANDLE Handle
Definition: extypes.h:390
_In_ PIRP _In_ ULONG _In_ ULONG _In_ ULONG InBufferSize
Definition: classpnp.h:429
unsigned long DWORD
Definition: ntddk_ex.h:95
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

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

◆ TranslateInternalMmResult()

MMRESULT TranslateInternalMmResult ( IN MMRESULT  Result)

Definition at line 132 of file utility.c.

134 {
135  switch ( Result )
136  {
137  case MMSYSERR_INVALPARAM :
138  case MMSYSERR_INVALFLAG :
139  {
140  return MMSYSERR_ERROR;
141  }
142  }
143 
144  return Result;
145 }
_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:426
#define MMSYSERR_ERROR
Definition: mmsystem.h:97
#define MMSYSERR_INVALFLAG
Definition: mmsystem.h:106
#define MMSYSERR_INVALPARAM
Definition: mmsystem.h:107

Referenced by CreateSoundDeviceInstance(), CreateSoundThread(), DestroySoundDeviceInstance(), GetNt4SoundDeviceCapabilities(), GetSoundDeviceCapabilities(), MmeCloseDevice(), MmeGetDeviceInterfaceString(), MmeGetLineInfo(), MmeGetPosition(), MmeOpenDevice(), MmeSetState(), OpenNt4KernelSoundDevice(), PopulateWdmDeviceList(), PrepareWaveHeader(), QueryNt4WaveDeviceFormatSupport(), QueryWaveDeviceFormatSupport(), SetNt4WaveDeviceFormat(), SetWaveDeviceFormat(), StopStreaming(), UnlistSoundDeviceInstance(), UnprepareWaveHeader(), WdmAudCloseSoundDeviceByLegacy(), WdmAudCloseSoundDeviceByMMixer(), WdmAudCommitWaveBufferByLegacy(), WdmAudCommitWaveBufferByMMixer(), WdmAudGetCapabilitiesByLegacy(), WdmAudGetDeviceInterfaceStringByLegacy(), WdmAudGetNumWdmDevsByLegacy(), WdmAudGetWavePositionByLegacy(), WdmAudSetMixerDeviceFormatByLegacy(), WdmAudSetWaveDeviceFormatByLegacy(), WdmAudSetWaveDeviceFormatByMMixer(), WdmAudSetWaveStateByLegacy(), and WriteWaveHeader().

◆ UnlistAllSoundDevices()

VOID UnlistAllSoundDevices ( VOID  )

Referenced by DriverProc().

◆ 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 }
DeviceType
Definition: mmdrv.h:41
PSOUND_DEVICE SoundDeviceListHeads[SOUND_DEVICE_TYPES]
Definition: devicelist.c:14
#define VALIDATE_MMSYS_PARAMETER(parameter_condition)
Definition: mmebuddy.h:71
VOID FreeSoundDevice(IN PSOUND_DEVICE SoundDevice)
Definition: devicelist.c:49
#define IsValidSoundDeviceType
Definition: mmebuddy.h:69
smooth NULL
Definition: ftsmooth.c:416
#define MMSYSERR_NOERROR
Definition: mmsystem.h:96
BOOLEAN IsValidSoundDevice(IN PSOUND_DEVICE SoundDevice)
Definition: devicelist.c:87
unsigned char UCHAR
Definition: xmlstorage.h:181
struct _SOUND_DEVICE * Next
Definition: mmebuddy.h:258
static const WCHAR L[]
Definition: oid.c:1250
PSOUND_DEVICE SoundDeviceListTails[SOUND_DEVICE_TYPES]
Definition: devicelist.c:15
ULONG SoundDeviceCounts[SOUND_DEVICE_TYPES]
Definition: devicelist.c:13
#define SOUND_DEVICE_TYPE_TO_INDEX(x)
Definition: mmebuddy.h:58
#define SND_TRACE(...)

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 }
DeviceType
Definition: mmdrv.h:41
MMRESULT UnlistSoundDevice(IN MMDEVICE_TYPE DeviceType, IN PSOUND_DEVICE SoundDevice)
Definition: devicelist.c:188
PSOUND_DEVICE SoundDeviceListHeads[SOUND_DEVICE_TYPES]
Definition: devicelist.c:14
UINT MMRESULT
Definition: mmsystem.h:962
#define VALIDATE_MMSYS_PARAMETER(parameter_condition)
Definition: mmebuddy.h:71
#define IsValidSoundDeviceType
Definition: mmebuddy.h:69
#define SND_ASSERT(condition)
_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:426
#define MMSYSERR_NOERROR
Definition: mmsystem.h:96
unsigned char UCHAR
Definition: xmlstorage.h:181
static const WCHAR L[]
Definition: oid.c:1250
ULONG SoundDeviceCounts[SOUND_DEVICE_TYPES]
Definition: devicelist.c:13
#define SOUND_DEVICE_TYPE_TO_INDEX(x)
Definition: mmebuddy.h:58
#define SND_TRACE(...)

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 }
static VOID FreeMemory(PCREATE_DATA Data)
Definition: create.c:134
#define MMSUCCESS(result)
Definition: mmebuddy.h:80
MMRESULT TranslateInternalMmResult(IN MMRESULT Result)
Definition: utility.c:132
UINT MMRESULT
Definition: mmsystem.h:962
#define VALIDATE_MMSYS_PARAMETER(parameter_condition)
Definition: mmebuddy.h:71
MMRESULT GetSoundDeviceFunctionTable(IN PSOUND_DEVICE SoundDevice, OUT PMMFUNCTION_TABLE *FunctionTable)
Definition: functiontable.c:47
Definition: Header.h:8
#define SND_ASSERT(condition)
_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:426
BOOLEAN IsValidSoundDeviceInstance(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance)
#define MMSYSERR_NOERROR
Definition: mmsystem.h:96
struct _WAVEHDR_EXTENSION * PWAVEHDR_EXTENSION
static const WCHAR L[]
Definition: oid.c:1250
#define WHDR_PREPARED
Definition: mmsystem.h:194
static WLX_DISPATCH_VERSION_1_4 FunctionTable
Definition: wlx.c:736
MMRESULT GetSoundDeviceFromInstance(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance, OUT PSOUND_DEVICE *SoundDevice)
_Inout_opt_ PUNICODE_STRING Extension
Definition: fltkernel.h:1092
#define SND_TRACE(...)

◆ 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 
99  case ERROR_NOT_SUPPORTED :
101  return MMSYSERR_NOTSUPPORTED;
102 
104  return MMSYSERR_NOMEM;
105 
106  case ERROR_ACCESS_DENIED :
107  return MMSYSERR_BADDEVICEID;
108 
110  return MMSYSERR_INVALPARAM;
111 
113  return MMSYSERR_INVALPARAM;
114 
115 
116  default :
117  return MMSYSERR_ERROR;
118  }
119 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
_In_ NDIS_ERROR_CODE ErrorCode
Definition: ndis.h:4436
#define ERROR_INVALID_FUNCTION
Definition: dderror.h:6
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define ERROR_IO_PENDING
Definition: dderror.h:15
#define NO_ERROR
Definition: dderror.h:5
#define ERROR_BUSY
Definition: dderror.h:12
#define MMSYSERR_NOMEM
Definition: mmsystem.h:103
#define ERROR_ACCESS_DENIED
Definition: compat.h:87
#define MMSYSERR_NOERROR
Definition: mmsystem.h:96
#define MMSYSERR_ERROR
Definition: mmsystem.h:97
#define MMSYSERR_ALLOCATED
Definition: mmsystem.h:100
#define MMSYSERR_NOTSUPPORTED
Definition: mmsystem.h:104
#define MMSYSERR_BADDEVICEID
Definition: mmsystem.h:98
#define MMSYSERR_INVALPARAM
Definition: mmsystem.h:107
#define ERROR_NOT_SUPPORTED
Definition: compat.h:90
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

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 238 of file streaming.c.

244 {
245  HANDLE Handle;
246 
247  VALIDATE_MMSYS_PARAMETER( SoundDeviceInstance );
248  VALIDATE_MMSYS_PARAMETER( OffsetPtr );
249  VALIDATE_MMSYS_PARAMETER( Overlap );
251 
252  GetSoundDeviceInstanceHandle(SoundDeviceInstance, &Handle);
253 
254  if ( ! WriteFileEx(Handle, OffsetPtr, Length, (LPOVERLAPPED)Overlap, CompletionRoutine) )
255  {
256  // TODO
257  }
258 
259  return MMSYSERR_NOERROR;
260 }
#define VALIDATE_MMSYS_PARAMETER(parameter_condition)
Definition: mmebuddy.h:71
_In_ HANDLE Handle
Definition: extypes.h:390
#define MMSYSERR_NOERROR
Definition: mmsystem.h:96
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
_In_ PIRP _In_opt_ PVOID _In_opt_ POPLOCK_WAIT_COMPLETE_ROUTINE CompletionRoutine
Definition: fsrtlfuncs.h:673
MMRESULT GetSoundDeviceInstanceHandle(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance, OUT PVOID *Handle)
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

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 )
181  return MMSYSERR_NOTSUPPORTED;
182 
183  /*
184  A few minor sanity checks - any custom checks should've been carried
185  out during wave header preparation etc.
186  */
187  VALIDATE_MMSYS_PARAMETER( Header->lpData != NULL );
188  VALIDATE_MMSYS_PARAMETER( Header->dwBufferLength > 0 );
190  VALIDATE_MMSYS_PARAMETER( ! (Header->dwFlags & WHDR_INQUEUE) );
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 }
VOID SanitizeWaveHeader(PWAVEHDR Header)
Definition: header.c:64
MMRESULT CallSoundThread(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance, IN SOUND_THREAD_REQUEST_HANDLER RequestHandler, IN PVOID Parameter OPTIONAL)
Definition: thread.c:71
#define MMSUCCESS(result)
Definition: mmebuddy.h:80
MMRESULT TranslateInternalMmResult(IN MMRESULT Result)
Definition: utility.c:132
UINT MMRESULT
Definition: mmsystem.h:962
#define VALIDATE_MMSYS_PARAMETER(parameter_condition)
Definition: mmebuddy.h:71
MMRESULT EnqueueWaveHeader(PSOUND_DEVICE_INSTANCE SoundDeviceInstance, IN PVOID Parameter)
Definition: header.c:218
MMRESULT GetSoundDeviceFunctionTable(IN PSOUND_DEVICE SoundDevice, OUT PMMFUNCTION_TABLE *FunctionTable)
Definition: functiontable.c:47
Definition: Header.h:8
smooth NULL
Definition: ftsmooth.c:416
_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:426
BOOLEAN IsValidSoundDeviceInstance(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance)
#define MMSYSERR_NOTSUPPORTED
Definition: mmsystem.h:104
static const WCHAR L[]
Definition: oid.c:1250
#define WHDR_INQUEUE
Definition: mmsystem.h:197
#define WHDR_PREPARED
Definition: mmsystem.h:194
#define WHDR_DONE
Definition: mmsystem.h:193
static WLX_DISPATCH_VERSION_1_4 FunctionTable
Definition: wlx.c:736
MMRESULT GetSoundDeviceFromInstance(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance, OUT PSOUND_DEVICE *SoundDevice)
#define SND_TRACE(...)