ReactOS 0.4.16-dev-297-gc569aee
mmixer.c File Reference
#include "wdmaud.h"
#include <winreg.h>
#include <setupapi.h>
#include <mmixer.h>
#include <ndk/rtlfuncs.h>
#include <ndk/iofuncs.h>
#include <debug.h>
#include <mmebuddy_debug.h>
Include dependency graph for mmixer.c:

Go to the source code of this file.

Macros

#define NTOS_MODE_USER
 
#define NDEBUG
 

Functions

PVOID Alloc (ULONG NumBytes)
 
MIXER_STATUS Close (HANDLE hDevice)
 
VOID Free (PVOID Block)
 
VOID Copy (PVOID Src, PVOID Dst, ULONG NumBytes)
 
MIXER_STATUS Open (IN LPWSTR DevicePath, OUT PHANDLE hDevice)
 
MIXER_STATUS Control (IN HANDLE hMixer, IN ULONG dwIoControlCode, IN PVOID lpInBuffer, IN ULONG nInBufferSize, OUT PVOID lpOutBuffer, ULONG nOutBufferSize, PULONG lpBytesReturned)
 
MIXER_STATUS Enum (IN PVOID EnumContext, IN ULONG DeviceIndex, OUT LPWSTR *DeviceName, OUT PHANDLE OutHandle, OUT PHANDLE OutKey)
 
MIXER_STATUS OpenKey (IN HANDLE hKey, IN LPWSTR SubKey, IN ULONG DesiredAccess, OUT PHANDLE OutKey)
 
MIXER_STATUS CloseKey (IN HANDLE hKey)
 
MIXER_STATUS QueryKeyValue (IN HANDLE hKey, IN LPWSTR KeyName, OUT PVOID *ResultBuffer, OUT PULONG ResultLength, OUT PULONG KeyType)
 
PVOID AllocEventData (IN ULONG ExtraSize)
 
VOID FreeEventData (IN PVOID EventData)
 
BOOL WdmAudInitUserModeMixer ()
 
MMRESULT WdmAudCleanupByMMixer ()
 
MMRESULT WdmAudGetMixerCapabilities (IN ULONG DeviceId, LPMIXERCAPSW Capabilities)
 
MMRESULT WdmAudGetLineInfo (IN HANDLE hMixer, IN DWORD MixerId, IN LPMIXERLINEW MixLine, IN ULONG Flags)
 
MMRESULT WdmAudGetLineControls (IN HANDLE hMixer, IN DWORD MixerId, IN LPMIXERLINECONTROLSW MixControls, IN ULONG Flags)
 
MMRESULT WdmAudSetControlDetails (IN HANDLE hMixer, IN DWORD MixerId, IN LPMIXERCONTROLDETAILS MixDetails, IN ULONG Flags)
 
MMRESULT WdmAudGetControlDetails (IN HANDLE hMixer, IN DWORD MixerId, IN LPMIXERCONTROLDETAILS MixDetails, IN ULONG Flags)
 
MMRESULT WdmAudGetWaveOutCapabilities (IN ULONG DeviceId, LPWAVEOUTCAPSW Capabilities)
 
MMRESULT WdmAudGetWaveInCapabilities (IN ULONG DeviceId, LPWAVEINCAPSW Capabilities)
 
MMRESULT WdmAudSetWaveDeviceFormatByMMixer (IN PSOUND_DEVICE_INSTANCE Instance, IN DWORD DeviceId, IN PWAVEFORMATEX WaveFormat, IN DWORD WaveFormatSize)
 
MMRESULT WdmAudGetCapabilitiesByMMixer (IN PSOUND_DEVICE SoundDevice, IN DWORD DeviceId, OUT PVOID Capabilities, IN DWORD CapabilitiesSize)
 
MMRESULT WdmAudOpenSoundDeviceByMMixer (IN struct _SOUND_DEVICE *SoundDevice, OUT PVOID *Handle)
 
MMRESULT WdmAudCloseSoundDeviceByMMixer (IN struct _SOUND_DEVICE_INSTANCE *SoundDeviceInstance, IN PVOID Handle)
 
MMRESULT WdmAudGetNumWdmDevsByMMixer (IN MMDEVICE_TYPE DeviceType, OUT DWORD *DeviceCount)
 
MMRESULT WdmAudQueryMixerInfoByMMixer (IN struct _SOUND_DEVICE_INSTANCE *SoundDeviceInstance, IN DWORD MixerId, IN UINT uMsg, IN LPVOID Parameter, IN DWORD Flags)
 
MMRESULT WdmAudGetDeviceInterfaceStringByMMixer (IN MMDEVICE_TYPE DeviceType, IN DWORD DeviceId, IN LPWSTR Interface, IN DWORD InterfaceLength, OUT DWORD *InterfaceSize)
 
VOID CALLBACK MixerEventCallback (IN PVOID MixerEventContext, IN HANDLE hMixer, IN ULONG NotificationType, IN ULONG Value)
 
MMRESULT WdmAudSetMixerDeviceFormatByMMixer (IN PSOUND_DEVICE_INSTANCE Instance, IN DWORD DeviceId, IN PWAVEFORMATEX WaveFormat, IN DWORD WaveFormatSize)
 
MMRESULT WdmAudSetWaveStateByMMixer (IN struct _SOUND_DEVICE_INSTANCE *SoundDeviceInstance, IN BOOL bStart)
 
MMRESULT WdmAudResetStreamByMMixer (IN struct _SOUND_DEVICE_INSTANCE *SoundDeviceInstance, IN MMDEVICE_TYPE DeviceType, IN BOOLEAN bStartReset)
 
MMRESULT WdmAudGetWavePositionByMMixer (IN struct _SOUND_DEVICE_INSTANCE *SoundDeviceInstance, IN MMTIME *Time)
 
MMRESULT WdmAudGetVolumeByMMixer (_In_ PSOUND_DEVICE_INSTANCE SoundDeviceInstance, _In_ DWORD DeviceId, _Out_ PDWORD pdwVolume)
 
MMRESULT WdmAudSetVolumeByMMixer (_In_ PSOUND_DEVICE_INSTANCE SoundDeviceInstance, _In_ DWORD DeviceId, _In_ DWORD dwVolume)
 
static VOID WINAPI CommitWaveBufferApc (PVOID ApcContext, PIO_STATUS_BLOCK IoStatusBlock, ULONG Reserved)
 
MMRESULT WdmAudCommitWaveBufferByMMixer (IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance, IN PVOID OffsetPtr, IN DWORD Length, IN PSOUND_OVERLAPPED Overlap, IN LPOVERLAPPED_COMPLETION_ROUTINE CompletionRoutine)
 

Variables

BOOL MMixerLibraryInitialized = FALSE
 
MIXER_CONTEXT MixerContext
 
GUID CategoryGuid = {STATIC_KSCATEGORY_AUDIO}
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 19 of file mmixer.c.

◆ NTOS_MODE_USER

#define NTOS_MODE_USER

Definition at line 15 of file mmixer.c.

Function Documentation

◆ Alloc()

PVOID Alloc ( ULONG  NumBytes)

Definition at line 105 of file mmixer.c.

106{
107 return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, NumBytes);
108}
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HEAP_ZERO_MEMORY
Definition: compat.h:134

◆ AllocEventData()

PVOID AllocEventData ( IN ULONG  ExtraSize)

Definition at line 307 of file mmixer.c.

309{
311 if (!Data)
312 return NULL;
313
314 Data->EventHandle.Event = CreateEventW(NULL, FALSE, FALSE, NULL);
315 if (!Data->EventHandle.Event)
316 {
318 return NULL;
319 }
320
321 Data->NotificationType = KSEVENTF_EVENT_HANDLE;
322 return Data;
323}
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define HeapFree(x, y, z)
Definition: compat.h:735
struct KSEVENTDATA * PKSEVENTDATA
#define KSEVENTF_EVENT_HANDLE
Definition: ks.h:1778
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:651

◆ Close()

MIXER_STATUS Close ( HANDLE  hDevice)

Definition at line 111 of file mmixer.c.

112{
113 if (CloseHandle(hDevice))
114 return MM_STATUS_SUCCESS;
115 else
117}
#define CloseHandle
Definition: compat.h:739
@ MM_STATUS_UNSUCCESSFUL
Definition: mmixer.h:11
@ MM_STATUS_SUCCESS
Definition: mmixer.h:5

◆ CloseKey()

MIXER_STATUS CloseKey ( IN HANDLE  hKey)

Definition at line 97 of file mmixer.c.

99{
101 return MM_STATUS_SUCCESS;
102}
#define RegCloseKey(hKey)
Definition: registry.h:49
FxAutoRegKey hKey

◆ CommitWaveBufferApc()

static VOID WINAPI CommitWaveBufferApc ( PVOID  ApcContext,
PIO_STATUS_BLOCK  IoStatusBlock,
ULONG  Reserved 
)
static

Definition at line 925 of file mmixer.c.

928{
929 DWORD dwErrorCode;
930 PSOUND_OVERLAPPED Overlap;
932
935 lpHeader = Overlap->CompletionContext;
936
937 /* Call mmebuddy overlap routine */
938 Overlap->OriginalCompletionRoutine(dwErrorCode,
939 lpHeader->DataUsed, &Overlap->Standard);
940
942}
TCHAR lpHeader[80]
Definition: ctm.c:66
unsigned long DWORD
Definition: ntddk_ex.h:95
NTSYSAPI ULONG WINAPI RtlNtStatusToDosError(NTSTATUS)
struct _SOUND_OVERLAPPED * PSOUND_OVERLAPPED
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
OVERLAPPED Standard
Definition: mmebuddy.h:120
PVOID CompletionContext
Definition: mmebuddy.h:125
LPOVERLAPPED_COMPLETION_ROUTINE OriginalCompletionRoutine
Definition: mmebuddy.h:124

Referenced by WdmAudCommitWaveBufferByMMixer().

◆ Control()

MIXER_STATUS Control ( IN HANDLE  hMixer,
IN ULONG  dwIoControlCode,
IN PVOID  lpInBuffer,
IN ULONG  nInBufferSize,
OUT PVOID  lpOutBuffer,
ULONG  nOutBufferSize,
PULONG  lpBytesReturned 
)

Definition at line 153 of file mmixer.c.

161{
162 OVERLAPPED Overlapped;
163 BOOLEAN IoResult;
164 DWORD Transferred = 0;
165
166 /* Overlapped I/O is done here - this is used for waiting for completion */
167 ZeroMemory(&Overlapped, sizeof(OVERLAPPED));
168 Overlapped.hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
169
170 if ( ! Overlapped.hEvent )
171 return MM_STATUS_NO_MEMORY;
172
173 /* Talk to the device */
174 IoResult = DeviceIoControl(hMixer,
176 lpInBuffer,
177 nInBufferSize,
178 lpOutBuffer,
179 nOutBufferSize,
180 &Transferred,
181 &Overlapped);
182
183 /* If failure occurs, make sure it's not just due to the overlapped I/O */
184 if ( ! IoResult )
185 {
187 {
188 CloseHandle(Overlapped.hEvent);
189
191 {
192 if ( lpBytesReturned )
193 *lpBytesReturned = Transferred;
195 }
196
198 }
199 }
200
201 /* Wait for the I/O to complete */
202 IoResult = GetOverlappedResult(hMixer,
203 &Overlapped,
204 &Transferred,
205 TRUE);
206
207 /* Don't need this any more */
208 CloseHandle(Overlapped.hEvent);
209
210 if ( ! IoResult )
212
213 if ( lpBytesReturned )
214 *lpBytesReturned = Transferred;
215
216 return MM_STATUS_SUCCESS;
217}
unsigned char BOOLEAN
#define ERROR_MORE_DATA
Definition: dderror.h:13
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define ERROR_IO_PENDING
Definition: dderror.h:15
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
#define TRUE
Definition: types.h:120
BOOL WINAPI GetOverlappedResult(IN HANDLE hFile, IN LPOVERLAPPED lpOverlapped, OUT LPDWORD lpNumberOfBytesTransferred, IN BOOL bWait)
Definition: iocompl.c:221
@ MM_STATUS_NO_MEMORY
Definition: mmixer.h:12
@ MM_STATUS_MORE_ENTRIES
Definition: mmixer.h:9
HMIXER hMixer
Definition: test.c:10
HANDLE hEvent
Definition: winbase.h:845
#define ZeroMemory
Definition: winbase.h:1737
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define CreateEvent
Definition: winbase.h:3773
_In_ DWORD _In_ DWORD _In_ DWORD _Out_ LPDWORD lpBytesReturned
Definition: winddi.h:1705
_In_ DWORD dwIoControlCode
Definition: winddi.h:1700

◆ Copy()

VOID Copy ( PVOID  Src,
PVOID  Dst,
ULONG  NumBytes 
)

Definition at line 126 of file mmixer.c.

127{
128 RtlMoveMemory(Src, Dst, NumBytes);
129}
#define Dst
Definition: mesh.h:153
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:264

Referenced by DECLARE_INTERFACE_(), IopQueueDeviceChangeEvent(), IopQueueDeviceInstallEvent(), IopQueueTargetDeviceEvent(), NtUserInternalGetWindowText(), PrependPacket(), and RepairList().

◆ Enum()

MIXER_STATUS Enum ( IN PVOID  EnumContext,
IN ULONG  DeviceIndex,
OUT LPWSTR DeviceName,
OUT PHANDLE  OutHandle,
OUT PHANDLE  OutKey 
)

Definition at line 220 of file mmixer.c.

226{
227 SP_DEVICE_INTERFACE_DATA InterfaceData;
230 BOOL Result;
233
234 //printf("Enum EnumContext %p DeviceIndex %lu OutHandle %p\n", EnumContext, DeviceIndex, OutHandle);
235
236 InterfaceData.cbSize = sizeof(InterfaceData);
237 InterfaceData.Reserved = 0;
238
240 NULL,
242 DeviceIndex,
243 &InterfaceData);
244
245 if (!Result)
246 {
248 {
250 }
252 }
253
256 0,
257 Length);
258 DetailData->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA_W);
259 DeviceData.cbSize = sizeof(DeviceData);
260 DeviceData.Reserved = 0;
261
263 &InterfaceData,
264 DetailData,
265 Length,
266 NULL,
267 &DeviceData);
268
269 if (!Result)
270 {
271 DPRINT("SetupDiGetDeviceInterfaceDetailW failed with %lu\n", GetLastError());
273 }
274
275
276 *OutKey = SetupDiOpenDeviceInterfaceRegKey(EnumContext, &InterfaceData, 0, KEY_READ);
277 if ((HKEY)*OutKey == INVALID_HANDLE_VALUE)
278 {
279 HeapFree(GetProcessHeap(), 0, DetailData);
281 }
282
283 Status = Open(DetailData->DevicePath, OutHandle);
284
286 {
287 RegCloseKey((HKEY)*OutKey);
288 HeapFree(GetProcessHeap(), 0, DetailData);
289 return Status;
290 }
291
292 *DeviceName = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, (wcslen(DetailData->DevicePath)+1) * sizeof(WCHAR));
293 if (*DeviceName == NULL)
294 {
295 CloseHandle(*OutHandle);
296 RegCloseKey((HKEY)*OutKey);
297 HeapFree(GetProcessHeap(), 0, DetailData);
298 return MM_STATUS_NO_MEMORY;
299 }
300 wcscpy(*DeviceName, DetailData->DevicePath);
301 HeapFree(GetProcessHeap(), 0, DetailData);
302
303 return Status;
304}
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define ERROR_NO_MORE_ITEMS
Definition: compat.h:105
#define MAX_PATH
Definition: compat.h:34
BOOL WINAPI SetupDiEnumDeviceInterfaces(HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, CONST GUID *InterfaceClassGuid, DWORD MemberIndex, PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData)
Definition: devinst.c:2780
BOOL WINAPI SetupDiGetDeviceInterfaceDetailW(HDEVINFO DeviceInfoSet, PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData, PSP_DEVICE_INTERFACE_DETAIL_DATA_W DeviceInterfaceDetailData, DWORD DeviceInterfaceDetailDataSize, PDWORD RequiredSize, PSP_DEVINFO_DATA DeviceInfoData)
Definition: devinst.c:3011
HKEY WINAPI SetupDiOpenDeviceInterfaceRegKey(IN HDEVINFO DeviceInfoSet, IN PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData, IN DWORD Reserved, IN REGSAM samDesired)
Definition: interface.c:547
GUID CategoryGuid
Definition: mmixer.c:58
unsigned int BOOL
Definition: ntddk_ex.h:94
Status
Definition: gdiplustypes.h:25
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define Open
Definition: syshdrs.h:62
MIXER_STATUS
Definition: mmixer.h:4
@ MM_STATUS_NO_MORE_DEVICES
Definition: mmixer.h:8
#define KEY_READ
Definition: nt_native.h:1023
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
struct _SP_DEVICE_INTERFACE_DETAIL_DATA_W SP_DEVICE_INTERFACE_DETAIL_DATA_W
struct _SP_DEVICE_INTERFACE_DETAIL_DATA_W * PSP_DEVICE_INTERFACE_DETAIL_DATA_W
#define DPRINT
Definition: sndvol32.h:73
WCHAR DevicePath[ANYSIZE_ARRAY]
Definition: setupapi.h:855
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_opt_ PCUNICODE_STRING DeviceName
Definition: wdfdevice.h:3275
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:409
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by Moniker_Enum(), test_Hlink_Navigate(), test_HlinkClone(), test_HlinkGetSetMonikerReference(), test_HlinkSite(), USBH_ChangeIndicationWorker(), WdmAudInitUserModeMixer(), WdmAudMixerInitialize(), and WshCollection__NewEnum().

◆ Free()

VOID Free ( PVOID  Block)

Definition at line 120 of file mmixer.c.

121{
122 HeapFree(GetProcessHeap(), 0, Block);
123}

◆ FreeEventData()

VOID FreeEventData ( IN PVOID  EventData)

Definition at line 326 of file mmixer.c.

327{
328 PKSEVENTDATA Data = (PKSEVENTDATA)EventData;
329
330 CloseHandle(Data->EventHandle.Event);
332}

◆ MixerEventCallback()

VOID CALLBACK MixerEventCallback ( IN PVOID  MixerEventContext,
IN HANDLE  hMixer,
IN ULONG  NotificationType,
IN ULONG  Value 
)

Definition at line 672 of file mmixer.c.

677{
679
680 DriverCallback(Instance->WinMM.ClientCallback,
681 HIWORD(Instance->WinMM.Flags),
682 Instance->WinMM.Handle,
684 Instance->WinMM.ClientCallbackInstanceData,
686 0);
687}
BOOL WINAPI DriverCallback(DWORD dwCallBack, UINT uFlags, HDRVR hDev, UINT wMsg, DWORD dwUser, DWORD dwParam1, DWORD dwParam2)
struct _SOUND_DEVICE_INSTANCE * PSOUND_DEVICE_INSTANCE
uint32_t DWORD_PTR
Definition: typedefs.h:65
#define HIWORD(l)
Definition: typedefs.h:247
_In_ WDF_SPECIAL_FILE_TYPE NotificationType
Definition: wdfdevice.h:1024
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_WMI_INSTANCE_CONFIG _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_opt_ WDFWMIINSTANCE * Instance
Definition: wdfwmi.h:481

Referenced by WdmAudSetMixerDeviceFormatByMMixer().

◆ Open()

MIXER_STATUS Open ( IN LPWSTR  DevicePath,
OUT PHANDLE  hDevice 
)

Definition at line 132 of file mmixer.c.

135{
136 DevicePath[1] = L'\\';
137 *hDevice = CreateFileW(DevicePath,
139 0,
140 NULL,
143 NULL);
144 if (*hDevice == INVALID_HANDLE_VALUE)
145 {
147 }
148
149 return MM_STATUS_SUCCESS;
150}
#define OPEN_EXISTING
Definition: compat.h:775
#define GENERIC_READ
Definition: compat.h:135
#define CreateFileW
Definition: compat.h:741
#define FILE_FLAG_OVERLAPPED
Definition: disk.h:46
#define GENERIC_WRITE
Definition: nt_native.h:90
#define L(x)
Definition: ntvdm.h:50

◆ OpenKey()

MIXER_STATUS OpenKey ( IN HANDLE  hKey,
IN LPWSTR  SubKey,
IN ULONG  DesiredAccess,
OUT PHANDLE  OutKey 
)

Definition at line 84 of file mmixer.c.

89{
90 if (RegOpenKeyExW((HKEY)hKey, SubKey, 0, DesiredAccess, (PHKEY)OutKey) == ERROR_SUCCESS)
91 return MM_STATUS_SUCCESS;
92
94}
#define ERROR_SUCCESS
Definition: deptool.c:10
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
_Must_inspect_result_ _In_ WDFDEVICE _In_ ULONG _In_ ACCESS_MASK DesiredAccess
Definition: wdfdevice.h:2658

◆ QueryKeyValue()

MIXER_STATUS QueryKeyValue ( IN HANDLE  hKey,
IN LPWSTR  KeyName,
OUT PVOID ResultBuffer,
OUT PULONG  ResultLength,
OUT PULONG  KeyType 
)

Definition at line 61 of file mmixer.c.

67{
70
72 if (*ResultBuffer == NULL)
74
76 {
79 }
80 return MM_STATUS_SUCCESS;
81}
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4103
PKMT_RESULTBUFFER ResultBuffer
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG _Out_ PULONG ResultLength
Definition: wdfdevice.h:3776
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING KeyName
Definition: wdfdevice.h:2699

◆ WdmAudCleanupByMMixer()

MMRESULT WdmAudCleanupByMMixer ( )

Definition at line 382 of file mmixer.c.

383{
384 /* TODO */
385 return MMSYSERR_NOERROR;
386}
#define MMSYSERR_NOERROR
Definition: mmsystem.h:96

◆ WdmAudCloseSoundDeviceByMMixer()

MMRESULT WdmAudCloseSoundDeviceByMMixer ( IN struct _SOUND_DEVICE_INSTANCE SoundDeviceInstance,
IN PVOID  Handle 
)

Definition at line 557 of file mmixer.c.

560{
562 PSOUND_DEVICE SoundDevice;
564
565 Result = GetSoundDeviceFromInstance(SoundDeviceInstance, &SoundDevice);
566
567 if ( ! MMSUCCESS(Result) )
568 {
570 }
571
572 Result = GetSoundDeviceType(SoundDevice, &DeviceType);
574
576 {
577 /* no op */
578 return MMSYSERR_NOERROR;
579 }
581 {
582 /* make sure the pin is stopped */
583 MMixerSetWaveStatus(&MixerContext, SoundDeviceInstance->Handle, KSSTATE_PAUSE);
584 MMixerSetWaveStatus(&MixerContext, SoundDeviceInstance->Handle, KSSTATE_ACQUIRE);
585 MMixerSetWaveStatus(&MixerContext, SoundDeviceInstance->Handle, KSSTATE_STOP);
586
588 return MMSYSERR_NOERROR;
589 }
590
591 /* midi is not supported */
592 return MMSYSERR_ERROR;
593}
MIXER_CONTEXT MixerContext
Definition: mmixer.c:41
ULONG Handle
Definition: gdb_input.c:15
@ KSSTATE_ACQUIRE
Definition: ks.h:1216
@ KSSTATE_PAUSE
Definition: ks.h:1217
@ KSSTATE_STOP
Definition: ks.h:1215
DeviceType
Definition: mmdrv.h:42
UCHAR MMDEVICE_TYPE
Definition: mmebuddy.h:88
MMRESULT GetSoundDeviceFromInstance(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance, OUT PSOUND_DEVICE *SoundDevice)
MMRESULT TranslateInternalMmResult(IN MMRESULT Result)
Definition: utility.c:132
MMRESULT GetSoundDeviceType(IN PSOUND_DEVICE SoundDevice, OUT PMMDEVICE_TYPE DeviceType)
Definition: devicelist.c:346
#define MMSUCCESS(result)
Definition: mmebuddy.h:80
#define SND_ASSERT(condition)
MIXER_STATUS MMixerSetWaveStatus(IN PMIXER_CONTEXT MixerContext, IN HANDLE PinHandle, IN KSSTATE State)
Definition: wave.c:652
UINT MMRESULT
Definition: mmsystem.h:962
#define MMSYSERR_ERROR
Definition: mmsystem.h:97
@ MIXER_DEVICE_TYPE
Definition: sndtypes.h:33
@ WAVE_IN_DEVICE_TYPE
Definition: sndtypes.h:28
@ WAVE_OUT_DEVICE_TYPE
Definition: sndtypes.h:29

◆ WdmAudCommitWaveBufferByMMixer()

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

Definition at line 945 of file mmixer.c.

951{
952 PSOUND_DEVICE SoundDevice;
955 ULONG IoCtl;
958
959 Result = GetSoundDeviceFromInstance(SoundDeviceInstance, &SoundDevice);
960
961 if ( ! MMSUCCESS(Result) )
962 {
964 }
965
966 Result = GetSoundDeviceType(SoundDevice, &DeviceType);
968
970 if ( ! lpHeader )
971 {
972 /* no memory */
973 return MMSYSERR_NOMEM;
974 }
975
976 /* setup stream packet */
977 lpHeader->Size = sizeof(KSSTREAM_HEADER);
978 lpHeader->PresentationTime.Numerator = 1;
979 lpHeader->PresentationTime.Denominator = 1;
980 lpHeader->Data = OffsetPtr;
981 lpHeader->FrameExtent = Length;
982 Overlap->CompletionContext = lpHeader;
983 Overlap->OriginalCompletionRoutine = CompletionRoutine;
985
987 {
988 lpHeader->DataUsed = Length;
989 }
990
991 Status = NtDeviceIoControlFile(SoundDeviceInstance->Handle,
992 NULL,
994 NULL,
995 (PIO_STATUS_BLOCK)Overlap,
996 IoCtl,
997 NULL,
998 0,
999 lpHeader,
1000 sizeof(KSSTREAM_HEADER));
1001
1002 if (!NT_SUCCESS(Status))
1003 {
1004 DPRINT1("NtDeviceIoControlFile() failed with status %08lx\n", Status);
1005 return MMSYSERR_ERROR;
1006 }
1007
1008 return MMSYSERR_NOERROR;
1009}
LONG NTSTATUS
Definition: precomp.h:26
#define DPRINT1
Definition: precomp.h:8
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
static VOID WINAPI CommitWaveBufferApc(PVOID ApcContext, PIO_STATUS_BLOCK IoStatusBlock, ULONG Reserved)
Definition: mmixer.c:925
#define IOCTL_KS_READ_STREAM
Definition: ks.h:142
#define IOCTL_KS_WRITE_STREAM
Definition: ks.h:139
#define MMSYSERR_NOMEM
Definition: mmsystem.h:103
NTSYSAPI NTSTATUS NTAPI NtDeviceIoControlFile(IN HANDLE hFile, IN HANDLE hEvent OPTIONAL, IN PIO_APC_ROUTINE IoApcRoutine OPTIONAL, IN PVOID IoApcContext OPTIONAL, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN ULONG DeviceIoControlCode, IN PVOID InBuffer OPTIONAL, IN ULONG InBufferLength, OUT PVOID OutBuffer OPTIONAL, IN ULONG OutBufferLength)
uint32_t ULONG
Definition: typedefs.h:59
_In_ WDFREQUEST _In_opt_ PFN_WDF_REQUEST_COMPLETION_ROUTINE CompletionRoutine
Definition: wdfrequest.h:895

◆ WdmAudGetCapabilitiesByMMixer()

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

Definition at line 514 of file mmixer.c.

519{
522
523 Result = GetSoundDeviceType(SoundDevice, &DeviceType);
525
527 {
529 }
531 {
533 }
535 {
537 }
538 else
539 {
540 // not supported
541 return MMSYSERR_ERROR;
542 }
543}
MMRESULT WdmAudGetWaveInCapabilities(IN ULONG DeviceId, LPWAVEINCAPSW Capabilities)
Definition: mmixer.c:465
MMRESULT WdmAudGetMixerCapabilities(IN ULONG DeviceId, LPMIXERCAPSW Capabilities)
Definition: mmixer.c:389
MMRESULT WdmAudGetWaveOutCapabilities(IN ULONG DeviceId, LPWAVEOUTCAPSW Capabilities)
Definition: mmixer.c:453
_Must_inspect_result_ typedef _Out_ PHIDP_CAPS Capabilities
Definition: hidclass.h:103

◆ WdmAudGetControlDetails()

MMRESULT WdmAudGetControlDetails ( IN HANDLE  hMixer,
IN DWORD  MixerId,
IN LPMIXERCONTROLDETAILS  MixDetails,
IN ULONG  Flags 
)

Definition at line 440 of file mmixer.c.

445{
446 if (MMixerGetControlDetails(&MixerContext, hMixer, MixerId, Flags, MixDetails) == MM_STATUS_SUCCESS)
447 return MMSYSERR_NOERROR;
448
449 return MMSYSERR_ERROR;
450}
MIXER_STATUS MMixerGetControlDetails(IN PMIXER_CONTEXT MixerContext, IN HANDLE MixerHandle, IN ULONG MixerId, IN ULONG Flags, OUT LPMIXERCONTROLDETAILS MixerControlDetails)
Definition: mixer.c:565
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170

Referenced by WdmAudDeviceControl(), WdmAudGetVolumeByMMixer(), and WdmAudQueryMixerInfoByMMixer().

◆ WdmAudGetDeviceInterfaceStringByMMixer()

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

Definition at line 659 of file mmixer.c.

665{
666 /* FIXME */
668}
#define MMSYSERR_NOTSUPPORTED
Definition: mmsystem.h:104

◆ WdmAudGetLineControls()

MMRESULT WdmAudGetLineControls ( IN HANDLE  hMixer,
IN DWORD  MixerId,
IN LPMIXERLINECONTROLSW  MixControls,
IN ULONG  Flags 
)

Definition at line 413 of file mmixer.c.

418{
419 if (MMixerGetLineControls(&MixerContext, hMixer, MixerId, Flags, MixControls) == MM_STATUS_SUCCESS)
420 return MMSYSERR_NOERROR;
421
422 return MMSYSERR_ERROR;
423}
MIXER_STATUS MMixerGetLineControls(IN PMIXER_CONTEXT MixerContext, IN HANDLE MixerHandle, IN ULONG MixerId, IN ULONG Flags, OUT LPMIXERLINECONTROLSW MixerLineControls)
Definition: mixer.c:331

Referenced by WdmAudDeviceControl(), WdmAudGetVolumeByMMixer(), WdmAudQueryMixerInfoByMMixer(), and WdmAudSetVolumeByMMixer().

◆ WdmAudGetLineInfo()

MMRESULT WdmAudGetLineInfo ( IN HANDLE  hMixer,
IN DWORD  MixerId,
IN LPMIXERLINEW  MixLine,
IN ULONG  Flags 
)

Definition at line 400 of file mmixer.c.

405{
406 if (MMixerGetLineInfo(&MixerContext, hMixer, MixerId, Flags, MixLine) == MM_STATUS_SUCCESS)
407 return MMSYSERR_NOERROR;
408
409 return MMSYSERR_ERROR;
410}
MIXER_STATUS MMixerGetLineInfo(IN PMIXER_CONTEXT MixerContext, IN HANDLE MixerHandle, IN ULONG MixerId, IN ULONG Flags, OUT LPMIXERLINEW MixerLine)
Definition: mixer.c:148

Referenced by WdmAudDeviceControl(), WdmAudGetVolumeByMMixer(), WdmAudQueryMixerInfoByMMixer(), and WdmAudSetVolumeByMMixer().

◆ WdmAudGetMixerCapabilities()

MMRESULT WdmAudGetMixerCapabilities ( IN ULONG  DeviceId,
LPMIXERCAPSW  Capabilities 
)

Definition at line 389 of file mmixer.c.

392{
394 return MMSYSERR_NOERROR;
395
397}
#define MMSYSERR_BADDEVICEID
Definition: mmsystem.h:98
MIXER_STATUS MMixerGetCapabilities(IN PMIXER_CONTEXT MixerContext, IN ULONG MixerIndex, OUT LPMIXERCAPSW MixerCaps)
Definition: mixer.c:38

Referenced by WdmAudGetCapabilitiesByMMixer().

◆ WdmAudGetNumWdmDevsByMMixer()

MMRESULT WdmAudGetNumWdmDevsByMMixer ( IN MMDEVICE_TYPE  DeviceType,
OUT DWORD DeviceCount 
)

Definition at line 596 of file mmixer.c.

599{
600 switch(DeviceType)
601 {
604 break;
607 break;
610 break;
611 default:
612 *DeviceCount = 0;
613 }
614 return MMSYSERR_NOERROR;
615}
ULONG MMixerGetWaveInCount(IN PMIXER_CONTEXT MixerContext)
Definition: wave.c:574
ULONG MMixerGetWaveOutCount(IN PMIXER_CONTEXT MixerContext)
Definition: wave.c:596
ULONG DeviceCount
Definition: mpu401.c:26
ULONG MMixerGetCount(IN PMIXER_CONTEXT MixerContext)
Definition: mixer.c:15

◆ WdmAudGetVolumeByMMixer()

MMRESULT WdmAudGetVolumeByMMixer ( _In_ PSOUND_DEVICE_INSTANCE  SoundDeviceInstance,
_In_ DWORD  DeviceId,
_Out_ PDWORD  pdwVolume 
)

Definition at line 809 of file mmixer.c.

813{
815 MIXERLINE MixLine;
816 MIXERCONTROL MixControl;
817 MIXERLINECONTROLS MixLineControls;
818 MIXERCONTROLDETAILS MixControlDetails;
819 MIXERCONTROLDETAILS_UNSIGNED MixControlDetailsU[2]; // For 2 (stereo) channels
820
821 MixLine.cbStruct = sizeof(MixLine);
823
824 /* Get line info */
825 Result = WdmAudGetLineInfo(SoundDeviceInstance->Handle,
826 DeviceId,
827 &MixLine,
829 if (!MMSUCCESS(Result))
831
832 MixLineControls.cbStruct = sizeof(MixLineControls);
833 MixLineControls.dwLineID = MixLine.dwLineID;
835 MixLineControls.cControls = 1;
836 MixLineControls.cbmxctrl = sizeof(MixControl);
837 MixLineControls.pamxctrl = &MixControl;
838
839 /* Get line controls */
840 Result = WdmAudGetLineControls(SoundDeviceInstance->Handle,
841 DeviceId,
842 &MixLineControls,
844 if (!MMSUCCESS(Result))
846
847 MixControlDetails.cbStruct = sizeof(MixControlDetails);
848 MixControlDetails.dwControlID = MixControl.dwControlID;
849 MixControlDetails.cChannels = MixLine.cChannels;
850 MixControlDetails.cMultipleItems = 0;
851 MixControlDetails.cbDetails = sizeof(MIXERCONTROLDETAILS_UNSIGNED);
852 MixControlDetails.paDetails = MixControlDetailsU;
853
854 /* Get volume control details */
855 Result = WdmAudGetControlDetails(SoundDeviceInstance->Handle,
856 DeviceId,
857 &MixControlDetails,
859 if (MMSUCCESS(Result))
860 *pdwVolume = MAKELONG(LOWORD(MixControlDetailsU[0].dwValue), HIWORD(MixControlDetailsU[1].dwValue));
861
862 return Result;
863}
MMRESULT WdmAudGetLineControls(IN HANDLE hMixer, IN DWORD MixerId, IN LPMIXERLINECONTROLSW MixControls, IN ULONG Flags)
Definition: mmixer.c:413
MMRESULT WdmAudGetControlDetails(IN HANDLE hMixer, IN DWORD MixerId, IN LPMIXERCONTROLDETAILS MixDetails, IN ULONG Flags)
Definition: mmixer.c:440
MMRESULT WdmAudGetLineInfo(IN HANDLE hMixer, IN DWORD MixerId, IN LPMIXERLINEW MixLine, IN ULONG Flags)
Definition: mmixer.c:400
#define MIXERLINE_COMPONENTTYPE_DST_SPEAKERS
Definition: mmsystem.h:319
#define MIXER_OBJECTF_MIXER
Definition: mmsystem.h:300
#define MIXERCONTROL_CONTROLTYPE_VOLUME
Definition: mmsystem.h:398
#define MIXER_GETLINEINFOF_COMPONENTTYPE
Definition: mmsystem.h:347
struct tMIXERCONTROLDETAILS_UNSIGNED MIXERCONTROLDETAILS_UNSIGNED
#define MIXER_GETLINECONTROLSF_ONEBYTYPE
Definition: mmsystem.h:410
#define LOWORD(l)
Definition: pedump.c:82
DWORD dwComponentType
Definition: mmsystem.h:1238
DWORD dwLineID
Definition: mmsystem.h:1235
DWORD cbStruct
Definition: mmsystem.h:1232
DWORD cChannels
Definition: mmsystem.h:1239
LPMIXERCONTROLA pamxctrl
Definition: mmsystem.h:1338
#define MAKELONG(a, b)
Definition: typedefs.h:249

◆ WdmAudGetWaveInCapabilities()

MMRESULT WdmAudGetWaveInCapabilities ( IN ULONG  DeviceId,
LPWAVEINCAPSW  Capabilities 
)

Definition at line 465 of file mmixer.c.

468{
470 return MMSYSERR_NOERROR;
471
472 return MMSYSERR_ERROR;
473}
MIXER_STATUS MMixerWaveInCapabilities(IN PMIXER_CONTEXT MixerContext, IN ULONG DeviceIndex, OUT LPWAVEINCAPSW Caps)
Definition: wave.c:502

Referenced by WdmAudGetCapabilitiesByMMixer().

◆ WdmAudGetWaveOutCapabilities()

MMRESULT WdmAudGetWaveOutCapabilities ( IN ULONG  DeviceId,
LPWAVEOUTCAPSW  Capabilities 
)

Definition at line 453 of file mmixer.c.

456{
458 return MMSYSERR_NOERROR;
459
460 return MMSYSERR_ERROR;
461
462}
MIXER_STATUS MMixerWaveOutCapabilities(IN PMIXER_CONTEXT MixerContext, IN ULONG DeviceIndex, OUT LPWAVEOUTCAPSW Caps)
Definition: wave.c:538

Referenced by WdmAudGetCapabilitiesByMMixer().

◆ WdmAudGetWavePositionByMMixer()

MMRESULT WdmAudGetWavePositionByMMixer ( IN struct _SOUND_DEVICE_INSTANCE SoundDeviceInstance,
IN MMTIME Time 
)

Definition at line 775 of file mmixer.c.

778{
779 PSOUND_DEVICE SoundDevice;
784
785 Result = GetSoundDeviceFromInstance(SoundDeviceInstance, &SoundDevice);
786 if (!MMSUCCESS(Result))
788
789 Result = GetSoundDeviceType(SoundDevice, &DeviceType);
791
793 {
794 Status = MMixerGetWavePosition(&MixerContext, SoundDeviceInstance->Handle, &Position);
796 {
797 /* Store position */
798 Time->wType = TIME_BYTES;
799 Time->u.cb = Position;
800
801 /* Completed successfully */
802 return MMSYSERR_NOERROR;
803 }
804 }
806}
MIXER_STATUS MMixerGetWavePosition(_In_ PMIXER_CONTEXT MixerContext, _In_ HANDLE PinHandle, _Out_ PDWORD Position)
Definition: wave.c:618
#define TIME_BYTES
Definition: mmsystem.h:30
static PLARGE_INTEGER Time
Definition: time.c:105
static COORD Position
Definition: mouse.c:34
struct _LARGE_INTEGER::@2302 u

◆ WdmAudInitUserModeMixer()

BOOL WdmAudInitUserModeMixer ( )

Definition at line 336 of file mmixer.c.

337{
340
342 {
343 /* library is already initialized */
344 return TRUE;
345 }
346
347
348 /* create a device list */
350 NULL,
351 NULL,
352 DIGCF_DEVICEINTERFACE/* FIXME |DIGCF_PRESENT*/);
353
355 {
356 /* failed to create a device list */
357 return FALSE;
358 }
359
360
361 /* initialize the mixer library */
363
364 /* free device list */
366
368 {
369 /* failed to initialize mixer library */
370 DPRINT1("Failed to initialize mixer library with %x\n", Status);
371 return FALSE;
372 }
373
374 /* library is now initialized */
376
377 /* completed successfully */
378 return TRUE;
379}
BOOL WINAPI SetupDiDestroyDeviceInfoList(HDEVINFO devinfo)
Definition: devinst.c:2893
MIXER_STATUS Enum(IN PVOID EnumContext, IN ULONG DeviceIndex, OUT LPWSTR *DeviceName, OUT PHANDLE OutHandle, OUT PHANDLE OutKey)
Definition: mmixer.c:220
BOOL MMixerLibraryInitialized
Definition: mmixer.c:24
_Inout_ PUSB_DEVICE_HANDLE DeviceHandle
Definition: hubbusif.h:121
MIXER_STATUS MMixerInitialize(IN PMIXER_CONTEXT MixerContext, IN PMIXER_ENUM EnumFunction, IN PVOID EnumContext)
Definition: mixer.c:768
#define DIGCF_DEVICEINTERFACE
Definition: setupapi.h:174
#define SetupDiGetClassDevs
Definition: setupapi.h:2593

Referenced by WdmAudOpenSoundDeviceByMMixer().

◆ WdmAudOpenSoundDeviceByMMixer()

MMRESULT WdmAudOpenSoundDeviceByMMixer ( IN struct _SOUND_DEVICE SoundDevice,
OUT PVOID Handle 
)

Definition at line 546 of file mmixer.c.

549{
551 return MMSYSERR_NOERROR;
552 else
553 return MMSYSERR_ERROR;
554}
BOOL WdmAudInitUserModeMixer()
Definition: mmixer.c:336

◆ WdmAudQueryMixerInfoByMMixer()

MMRESULT WdmAudQueryMixerInfoByMMixer ( IN struct _SOUND_DEVICE_INSTANCE SoundDeviceInstance,
IN DWORD  MixerId,
IN UINT  uMsg,
IN LPVOID  Parameter,
IN DWORD  Flags 
)

Definition at line 618 of file mmixer.c.

624{
625 LPMIXERLINEW MixLine;
626 LPMIXERLINECONTROLSW MixControls;
627 LPMIXERCONTROLDETAILS MixDetails;
629
630 MixLine = (LPMIXERLINEW)Parameter;
631 MixControls = (LPMIXERLINECONTROLSW)Parameter;
632 MixDetails = (LPMIXERCONTROLDETAILS)Parameter;
633
634 /* FIXME param checks */
635
636 if (SoundDeviceInstance)
637 {
638 hMixer = SoundDeviceInstance->Handle;
639 }
640
641 switch(uMsg)
642 {
643 case MXDM_GETLINEINFO:
644 return WdmAudGetLineInfo(hMixer, MixerId, MixLine, Flags);
646 return WdmAudGetLineControls(hMixer, MixerId, MixControls, Flags);
648 return WdmAudSetControlDetails(hMixer, MixerId, MixDetails, Flags);
650 return WdmAudGetControlDetails(hMixer, MixerId, MixDetails, Flags);
651 default:
652 DPRINT1("MixerId %lu, uMsg %lu, Parameter %p, Flags %lu\n", MixerId, uMsg, Parameter, Flags);
653 SND_ASSERT(0);
655 }
656}
#define MXDM_GETCONTROLDETAILS
Definition: mmddk.h:197
#define MXDM_GETLINECONTROLS
Definition: mmddk.h:196
#define MXDM_SETCONTROLDETAILS
Definition: mmddk.h:198
#define MXDM_GETLINEINFO
Definition: mmddk.h:195
MMRESULT WdmAudSetControlDetails(IN HANDLE hMixer, IN DWORD MixerId, IN LPMIXERCONTROLDETAILS MixDetails, IN ULONG Flags)
Definition: mmixer.c:426
struct tagMIXERLINECONTROLSW * LPMIXERLINECONTROLSW
struct tagMIXERLINEW * LPMIXERLINEW
struct tMIXERCONTROLDETAILS * LPMIXERCONTROLDETAILS
_Inout_opt_ PVOID Parameter
Definition: rtltypes.h:336

◆ WdmAudResetStreamByMMixer()

MMRESULT WdmAudResetStreamByMMixer ( IN struct _SOUND_DEVICE_INSTANCE SoundDeviceInstance,
IN MMDEVICE_TYPE  DeviceType,
IN BOOLEAN  bStartReset 
)

Definition at line 753 of file mmixer.c.

757{
759
761 {
762 Status = MMixerSetWaveResetState(&MixerContext, SoundDeviceInstance->Handle, bStartReset);
764 {
765 /* completed successfully */
766 return MMSYSERR_NOERROR;
767 }
768 }
769
770
772}
MIXER_STATUS MMixerSetWaveResetState(IN PMIXER_CONTEXT MixerContext, IN HANDLE PinHandle, IN ULONG bBegin)
Definition: wave.c:679

◆ WdmAudSetControlDetails()

MMRESULT WdmAudSetControlDetails ( IN HANDLE  hMixer,
IN DWORD  MixerId,
IN LPMIXERCONTROLDETAILS  MixDetails,
IN ULONG  Flags 
)

Definition at line 426 of file mmixer.c.

431{
432 if (MMixerSetControlDetails(&MixerContext, hMixer, MixerId, Flags, MixDetails) == MM_STATUS_SUCCESS)
433 return MMSYSERR_NOERROR;
434
435 return MMSYSERR_ERROR;
436
437}
MIXER_STATUS MMixerSetControlDetails(IN PMIXER_CONTEXT MixerContext, IN HANDLE MixerHandle, IN ULONG MixerId, IN ULONG Flags, OUT LPMIXERCONTROLDETAILS MixerControlDetails)
Definition: mixer.c:495

Referenced by WdmAudDeviceControl(), WdmAudQueryMixerInfoByMMixer(), and WdmAudSetVolumeByMMixer().

◆ WdmAudSetMixerDeviceFormatByMMixer()

MMRESULT WdmAudSetMixerDeviceFormatByMMixer ( IN PSOUND_DEVICE_INSTANCE  Instance,
IN DWORD  DeviceId,
IN PWAVEFORMATEX  WaveFormat,
IN DWORD  WaveFormatSize 
)

Definition at line 690 of file mmixer.c.

695{
697 return MMSYSERR_NOERROR;
698
700}
VOID CALLBACK MixerEventCallback(IN PVOID MixerEventContext, IN HANDLE hMixer, IN ULONG NotificationType, IN ULONG Value)
Definition: mmixer.c:672
MIXER_STATUS MMixerOpen(IN PMIXER_CONTEXT MixerContext, IN ULONG MixerId, IN PVOID MixerEventContext, IN PMIXER_EVENT MixerEventRoutine, OUT PHANDLE MixerHandle)
Definition: mixer.c:77

◆ WdmAudSetVolumeByMMixer()

MMRESULT WdmAudSetVolumeByMMixer ( _In_ PSOUND_DEVICE_INSTANCE  SoundDeviceInstance,
_In_ DWORD  DeviceId,
_In_ DWORD  dwVolume 
)

Definition at line 866 of file mmixer.c.

870{
872 MIXERLINE MixLine;
873 MIXERCONTROL MixControl;
874 MIXERLINECONTROLS MixLineControls;
875 MIXERCONTROLDETAILS MixControlDetails;
876 MIXERCONTROLDETAILS_UNSIGNED MixControlDetailsU[2]; // For 2 (stereo) channels
877
878 MixLine.cbStruct = sizeof(MixLine);
880
881 /* Get line info */
882 Result = WdmAudGetLineInfo(SoundDeviceInstance->Handle,
883 DeviceId,
884 &MixLine,
886 if (!MMSUCCESS(Result))
888
889 MixLineControls.cbStruct = sizeof(MixLineControls);
890 MixLineControls.dwLineID = MixLine.dwLineID;
892 MixLineControls.cControls = 1;
893 MixLineControls.cbmxctrl = sizeof(MixControl);
894 MixLineControls.pamxctrl = &MixControl;
895
896 /* Get line controls */
897 Result = WdmAudGetLineControls(SoundDeviceInstance->Handle,
898 DeviceId,
899 &MixLineControls,
901 if (!MMSUCCESS(Result))
903
904 /* Convert volume level to be set */
905 MixControlDetailsU[0].dwValue = LOWORD(dwVolume); // Left channel
906 MixControlDetailsU[1].dwValue = HIWORD(dwVolume); // Right channel
907
908 MixControlDetails.cbStruct = sizeof(MixControlDetails);
909 MixControlDetails.dwControlID = MixControl.dwControlID;
910 MixControlDetails.cChannels = MixLine.cChannels;
911 MixControlDetails.cMultipleItems = 0;
912 MixControlDetails.cbDetails = sizeof(MIXERCONTROLDETAILS_UNSIGNED);
913 MixControlDetails.paDetails = MixControlDetailsU;
914
915 /* Set volume control details */
916 Result = WdmAudSetControlDetails(SoundDeviceInstance->Handle,
917 DeviceId,
918 &MixControlDetails,
920 return Result;
921}

◆ WdmAudSetWaveDeviceFormatByMMixer()

MMRESULT WdmAudSetWaveDeviceFormatByMMixer ( IN PSOUND_DEVICE_INSTANCE  Instance,
IN DWORD  DeviceId,
IN PWAVEFORMATEX  WaveFormat,
IN DWORD  WaveFormatSize 
)

Definition at line 476 of file mmixer.c.

481{
483 PSOUND_DEVICE SoundDevice;
485 BOOL bWaveIn;
486
488
489 if ( ! MMSUCCESS(Result) )
490 {
492 }
493
494 Result = GetSoundDeviceType(SoundDevice, &DeviceType);
496
497 bWaveIn = (DeviceType == WAVE_IN_DEVICE_TYPE ? TRUE : FALSE);
498
499 if (MMixerOpenWave(&MixerContext, DeviceId, bWaveIn, WaveFormat, NULL, NULL, &Instance->Handle) == MM_STATUS_SUCCESS)
500 {
502 {
506 }
507 return MMSYSERR_NOERROR;
508 }
509 return MMSYSERR_ERROR;
510}
@ KSSTATE_RUN
Definition: ks.h:1218
MIXER_STATUS MMixerOpenWave(IN PMIXER_CONTEXT MixerContext, IN ULONG DeviceIndex, IN ULONG bWaveIn, IN LPWAVEFORMATEX WaveFormat, IN PIN_CREATE_CALLBACK CreateCallback, IN PVOID Context, OUT PHANDLE PinHandle)
Definition: wave.c:453

◆ WdmAudSetWaveStateByMMixer()

MMRESULT WdmAudSetWaveStateByMMixer ( IN struct _SOUND_DEVICE_INSTANCE SoundDeviceInstance,
IN BOOL  bStart 
)

Definition at line 703 of file mmixer.c.

706{
708 PSOUND_DEVICE SoundDevice;
710
711 Result = GetSoundDeviceFromInstance(SoundDeviceInstance, &SoundDevice);
713
714
715 Result = GetSoundDeviceType(SoundDevice, &DeviceType);
717
719 {
720 if (bStart)
721 {
722 MMixerSetWaveStatus(&MixerContext, SoundDeviceInstance->Handle, KSSTATE_ACQUIRE);
723 MMixerSetWaveStatus(&MixerContext, SoundDeviceInstance->Handle, KSSTATE_PAUSE);
724 MMixerSetWaveStatus(&MixerContext, SoundDeviceInstance->Handle, KSSTATE_RUN);
725 }
726 else
727 {
728 MMixerSetWaveStatus(&MixerContext, SoundDeviceInstance->Handle, KSSTATE_PAUSE);
729 MMixerSetWaveStatus(&MixerContext, SoundDeviceInstance->Handle, KSSTATE_ACQUIRE);
730 MMixerSetWaveStatus(&MixerContext, SoundDeviceInstance->Handle, KSSTATE_STOP);
731 }
732 }
734 {
735 if (bStart)
736 {
737 MMixerSetMidiStatus(&MixerContext, SoundDeviceInstance->Handle, KSSTATE_ACQUIRE);
738 MMixerSetMidiStatus(&MixerContext, SoundDeviceInstance->Handle, KSSTATE_PAUSE);
739 MMixerSetMidiStatus(&MixerContext, SoundDeviceInstance->Handle, KSSTATE_RUN);
740 }
741 else
742 {
743 MMixerSetMidiStatus(&MixerContext, SoundDeviceInstance->Handle, KSSTATE_PAUSE);
744 MMixerSetMidiStatus(&MixerContext, SoundDeviceInstance->Handle, KSSTATE_ACQUIRE);
745 MMixerSetMidiStatus(&MixerContext, SoundDeviceInstance->Handle, KSSTATE_STOP);
746 }
747 }
748
749 return MMSYSERR_NOERROR;
750}
MIXER_STATUS MMixerSetMidiStatus(IN PMIXER_CONTEXT MixerContext, IN HANDLE PinHandle, IN KSSTATE State)
Definition: midi.c:437
@ MIDI_OUT_DEVICE_TYPE
Definition: sndtypes.h:31
@ MIDI_IN_DEVICE_TYPE
Definition: sndtypes.h:30

Variable Documentation

◆ CategoryGuid

GUID CategoryGuid = {STATIC_KSCATEGORY_AUDIO}

Definition at line 58 of file mmixer.c.

Referenced by Enum(), and WdmAudInitUserModeMixer().

◆ MixerContext

MIXER_CONTEXT MixerContext
Initial value:
=
{
sizeof(MIXER_CONTEXT),
}
VOID FreeEventData(IN PVOID EventData)
Definition: mmixer.c:326
PVOID AllocEventData(IN ULONG ExtraSize)
Definition: mmixer.c:307
MIXER_STATUS OpenKey(IN HANDLE hKey, IN LPWSTR SubKey, IN ULONG DesiredAccess, OUT PHANDLE OutKey)
Definition: mmixer.c:84
PVOID Alloc(ULONG NumBytes)
Definition: mmixer.c:105
VOID Copy(PVOID Src, PVOID Dst, ULONG NumBytes)
Definition: mmixer.c:126
MIXER_STATUS CloseKey(IN HANDLE hKey)
Definition: mmixer.c:97
MIXER_STATUS QueryKeyValue(IN HANDLE hKey, IN LPWSTR KeyName, OUT PVOID *ResultBuffer, OUT PULONG ResultLength, OUT PULONG KeyType)
Definition: mmixer.c:61
@ Close
Definition: sacdrv.h:268
_In_ WDF_WMI_PROVIDER_CONTROL Control
Definition: wdfwmi.h:166
_In_opt_ PALLOCATE_FUNCTION _In_opt_ PFREE_FUNCTION Free
Definition: exfuncs.h:815

Definition at line 41 of file mmixer.c.

Referenced by MMixerAddEvent(), MMixerAddMidiPin(), MMixerAddMixerControl(), MMixerAddMixerControlsToDestinationLine(), MMixerAddMixerControlsToMixerLineByNodeIndexArray(), MMixerAddMixerSourceLines(), MMixerAddPinConnection(), MMixerAddPinIndexToArray(), MMixerAddPinToPinConnection(), MMixerAllocatePinConnect(), MMixerAllocateTopology(), MMixerAllocateTopologyNodeArray(), MMixerAllocateTopologyPinArray(), MMixerApplyOutputFilterHack(), MMixerBuildMixerDestinationLine(), MMixerBuildMixerSourceLine(), MMixerBuildTopology(), MMixerCheckFilterPinMidiSupport(), MMixerClose(), MMixerCountMixerControls(), MMixerCreateDestinationLine(), MMixerCreateMixerData(), MMixerCreateTopology(), MMixerExploreTopology(), MMixerFreeMixerInfo(), MMixerGetAllUpOrDownstreamNodesFromNodeIndex(), MMixerGetAllUpOrDownstreamNodesFromPinIndex(), MMixerGetAllUpOrDownstreamPinsFromNodeIndex(), MMixerGetAllUpOrDownstreamPinsFromPinIndex(), MMixerGetAudioPinDataRanges(), MMixerGetCapabilities(), MMixerGetChannelCountEnhanced(), MMixerGetChannelCountLegacy(), MMixerGetComponentAndTargetType(), MMixerGetControlDetails(), MMixerGetCount(), MMixerGetDeviceName(), MMixerGetDeviceNameWithComponentId(), MMixerGetFilterPinCount(), MMixerGetFilterTopologyProperty(), MMixerGetLineControls(), MMixerGetLineInfo(), MMixerGetMaxChannelsForNode(), MMixerGetMidiDevicePath(), MMixerGetMidiInCount(), MMixerGetMidiOutCount(), MMixerGetMixerDataByDeviceHandle(), MMixerGetMixerInfoByIndex(), MMixerGetPhysicalConnection(), MMixerGetPinDataFlowAndCommunication(), MMixerGetPinInstanceCount(), MMixerGetPinName(), MMixerGetUpOrDownstreamNodes(), MMixerGetUpOrDownStreamPins(), MMixerGetWaveDevicePath(), MMixerGetWaveInCount(), MMixerGetWaveOutCount(), MMixerGetWavePosition(), MMixerHandleAlternativeMixers(), MMixerHandleNodePinConnection(), MMixerHandleNodeToNodeConnection(), MMixerHandlePhysicalConnection(), MMixerHandleTopologyFilter(), MMixerInitialize(), MMixerInitializeFilter(), MMixerInitializeMidiForFilter(), MMixerInitializeTopologyNodes(), MMixerInitializeWaveInfo(), MMixerIsNodeConnectedToPin(), MMixerMidiInCapabilities(), MMixerMidiOutCapabilities(), MMixerOpen(), MMixerOpenMidi(), MMixerOpenMidiPin(), MMixerOpenWave(), MMixerOpenWavePin(), MMixerPrintMixers(), MMixerRemoveEvent(), MMixerSetControlDetails(), MMixerSetGetControlDetails(), MMixerSetGetMuteControlDetails(), MMixerSetGetMuxControlDetails(), MMixerSetGetVolumeControlDetails(), MMixerSetMidiStatus(), MMixerSetupFilter(), MMixerSetWaveResetState(), MMixerSetWaveStatus(), MMixerVerifyContext(), MMixerWaveInCapabilities(), MMixerWaveOutCapabilities(), WdmAudCloseAllMixers(), WdmAudCloseSoundDeviceByMMixer(), WdmAudControlCloseMixer(), WdmAudControlOpenMidi(), WdmAudControlOpenMixer(), WdmAudControlOpenWave(), WdmAudGetControlDetails(), WdmAudGetLineControls(), WdmAudGetLineInfo(), WdmAudGetMidiInDeviceCount(), WdmAudGetMidiOutDeviceCount(), WdmAudGetMixerCapabilities(), WdmAudGetMixerDeviceCount(), WdmAudGetNumWdmDevsByMMixer(), WdmAudGetPnpNameByIndexAndType(), WdmAudGetPosition(), WdmAudGetWaveInCapabilities(), WdmAudGetWaveInDeviceCount(), WdmAudGetWaveOutCapabilities(), WdmAudGetWaveOutDeviceCount(), WdmAudGetWavePositionByMMixer(), WdmAudInitUserModeMixer(), WdmAudMidiCapabilities(), WdmAudMixerCapabilities(), WdmAudMixerInitialize(), WdmAudResetStreamByMMixer(), WdmAudSetControlDetails(), WdmAudSetMixerDeviceFormatByMMixer(), WdmAudSetWaveDeviceFormatByMMixer(), WdmAudSetWaveStateByMMixer(), and WdmAudWaveCapabilities().

◆ MMixerLibraryInitialized

BOOL MMixerLibraryInitialized = FALSE

Definition at line 24 of file mmixer.c.

Referenced by WdmAudInitUserModeMixer().