ReactOS 0.4.15-dev-5664-g3bf4ef6
wdmaud.h File Reference
#include <portcls.h>
#include <mmsystem.h>
#include "interface.h"
Include dependency graph for wdmaud.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  WDMAUD_COMPLETION_CONTEXT
 
struct  WDMAUD_HANDLE
 
struct  WDMAUD_CLIENT
 
struct  EVENT_ENTRY
 
struct  SYSAUDIO_ENTRY
 
struct  WDMAUD_DEVICE_EXTENSION
 
struct  PIN_CREATE_CONTEXT
 

Typedefs

typedef struct WDMAUD_COMPLETION_CONTEXTPWDMAUD_COMPLETION_CONTEXT
 
typedef struct WDMAUD_HANDLEPWDMAUD_HANDLE
 
typedef struct WDMAUD_CLIENTPWDMAUD_CLIENT
 
typedef struct EVENT_ENTRYPEVENT_ENTRY
 
typedef struct SYSAUDIO_ENTRYPSYSAUDIO_ENTRY
 
typedef struct WDMAUD_DEVICE_EXTENSIONPWDMAUD_DEVICE_EXTENSION
 
typedef struct PIN_CREATE_CONTEXTPPIN_CREATE_CONTEXT
 

Functions

NTSTATUS NTAPI OpenWavePin (IN PWDMAUD_DEVICE_EXTENSION DeviceExtension, IN ULONG FilterId, IN ULONG PinId, IN LPWAVEFORMATEX WaveFormatEx, IN ACCESS_MASK DesiredAccess, OUT PHANDLE PinHandle)
 
NTSTATUS WdmAudRegisterDeviceInterface (IN PDEVICE_OBJECT PhysicalDeviceObject, IN PWDMAUD_DEVICE_EXTENSION DeviceExtension)
 
NTSTATUS WdmAudOpenSysAudioDevices (IN PDEVICE_OBJECT DeviceObject, IN PWDMAUD_DEVICE_EXTENSION DeviceExtension)
 
NTSTATUS WdmAudOpenSysaudio (IN PDEVICE_OBJECT DeviceObject, IN PWDMAUD_CLIENT *pClient)
 
NTSTATUS NTAPI WdmAudDeviceControl (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS NTAPI WdmAudReadWrite (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS NTAPI WdmAudWrite (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS WdmAudControlOpenMixer (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PWDMAUD_DEVICE_INFO DeviceInfo, IN PWDMAUD_CLIENT ClientInfo)
 
NTSTATUS WdmAudControlCloseMixer (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PWDMAUD_DEVICE_INFO DeviceInfo, IN PWDMAUD_CLIENT ClientInfo, IN ULONG Index)
 
VOID WdmAudCloseAllMixers (IN PDEVICE_OBJECT DeviceObject, IN PWDMAUD_CLIENT ClientInfo, IN ULONG Index)
 
NTSTATUS WdmAudControlOpenWave (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PWDMAUD_DEVICE_INFO DeviceInfo, IN PWDMAUD_CLIENT ClientInfo)
 
NTSTATUS WdmAudControlOpenMidi (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PWDMAUD_DEVICE_INFO DeviceInfo, IN PWDMAUD_CLIENT ClientInfo)
 
ULONG GetNumOfMixerDevices (IN PDEVICE_OBJECT DeviceObject)
 
NTSTATUS SetIrpIoStatus (IN PIRP Irp, IN NTSTATUS Status, IN ULONG Length)
 
NTSTATUS WdmAudOpenSysAudioDevice (IN LPWSTR DeviceName, OUT PHANDLE Handle)
 
NTSTATUS FindProductName (IN LPWSTR PnpName, IN ULONG ProductNameSize, OUT LPWSTR ProductName)
 
NTSTATUS WdmAudMixerCapabilities (IN PDEVICE_OBJECT DeviceObject, IN PWDMAUD_DEVICE_INFO DeviceInfo, IN PWDMAUD_CLIENT ClientInfo, IN PWDMAUD_DEVICE_EXTENSION DeviceExtension)
 
NTSTATUS WdmAudWaveCapabilities (IN PDEVICE_OBJECT DeviceObject, IN PWDMAUD_DEVICE_INFO DeviceInfo, IN PWDMAUD_CLIENT ClientInfo, IN PWDMAUD_DEVICE_EXTENSION DeviceExtension)
 
NTSTATUS WdmAudMidiCapabilities (IN PDEVICE_OBJECT DeviceObject, IN PWDMAUD_DEVICE_INFO DeviceInfo, IN PWDMAUD_CLIENT ClientInfo, IN PWDMAUD_DEVICE_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI WdmAudFrameSize (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PWDMAUD_DEVICE_INFO DeviceInfo, IN PWDMAUD_CLIENT ClientInfo)
 
NTSTATUS NTAPI WdmAudGetLineInfo (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PWDMAUD_DEVICE_INFO DeviceInfo, IN PWDMAUD_CLIENT ClientInfo)
 
NTSTATUS NTAPI WdmAudGetLineControls (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PWDMAUD_DEVICE_INFO DeviceInfo, IN PWDMAUD_CLIENT ClientInfo)
 
NTSTATUS NTAPI WdmAudSetControlDetails (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PWDMAUD_DEVICE_INFO DeviceInfo, IN PWDMAUD_CLIENT ClientInfo)
 
NTSTATUS NTAPI WdmAudGetMixerEvent (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PWDMAUD_DEVICE_INFO DeviceInfo, IN PWDMAUD_CLIENT ClientInfo)
 
NTSTATUS NTAPI WdmAudGetControlDetails (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PWDMAUD_DEVICE_INFO DeviceInfo, IN PWDMAUD_CLIENT ClientInfo)
 
NTSTATUS WdmAudMixerInitialize (IN PDEVICE_OBJECT DeviceObject)
 
NTSTATUS NTAPI WdmAudWaveInitialize (IN PDEVICE_OBJECT DeviceObject)
 
ULONG ClosePin (IN PWDMAUD_CLIENT ClientInfo, IN ULONG FilterId, IN ULONG PinId, IN SOUND_DEVICE_TYPE DeviceType)
 
NTSTATUS InsertPinHandle (IN PWDMAUD_CLIENT ClientInfo, IN ULONG FilterId, IN ULONG PinId, IN SOUND_DEVICE_TYPE DeviceType, IN HANDLE PinHandle, IN ULONG FreeIndex)
 
NTSTATUS GetSysAudioDevicePnpName (IN PDEVICE_OBJECT DeviceObject, IN ULONG DeviceIndex, OUT LPWSTR *Device)
 
NTSTATUS OpenSysAudioDeviceByIndex (IN PDEVICE_OBJECT DeviceObject, IN ULONG DeviceIndex, IN PHANDLE DeviceHandle, IN PFILE_OBJECT *FileObject)
 
NTSTATUS OpenDevice (IN LPWSTR Device, OUT PHANDLE DeviceHandle, OUT PFILE_OBJECT *FileObject)
 
ULONG WdmAudGetMixerDeviceCount (VOID)
 
ULONG WdmAudGetWaveInDeviceCount (VOID)
 
ULONG WdmAudGetWaveOutDeviceCount (VOID)
 
ULONG WdmAudGetMidiInDeviceCount (VOID)
 
ULONG WdmAudGetMidiOutDeviceCount (VOID)
 
NTSTATUS WdmAudGetPnpNameByIndexAndType (IN ULONG DeviceIndex, IN SOUND_DEVICE_TYPE DeviceType, OUT LPWSTR *Device)
 
ULONG GetSysAudioDeviceCount (IN PDEVICE_OBJECT DeviceObject)
 
PVOID AllocateItem (IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes)
 
VOID FreeItem (IN PVOID Item)
 

Typedef Documentation

◆ PEVENT_ENTRY

◆ PPIN_CREATE_CONTEXT

◆ PSYSAUDIO_ENTRY

◆ PWDMAUD_CLIENT

◆ PWDMAUD_COMPLETION_CONTEXT

◆ PWDMAUD_DEVICE_EXTENSION

◆ PWDMAUD_HANDLE

Function Documentation

◆ AllocateItem()

PVOID AllocateItem ( IN POOL_TYPE  PoolType,
IN SIZE_T  NumberOfBytes 
)

Definition at line 30 of file misc.c.

33{
35 if (!Item)
36 return Item;
37
39 return Item;
40}
#define TAG_KS
Definition: misc.c:14
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
_In_ WDFCOLLECTION _In_ WDFOBJECT Item
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ _Strict_type_match_ POOL_TYPE PoolType
Definition: wdfdevice.h:3815
_Must_inspect_result_ typedef _In_ PHYSICAL_ADDRESS _Inout_ PLARGE_INTEGER NumberOfBytes
Definition: iotypes.h:1036

◆ ClosePin()

ULONG ClosePin ( IN PWDMAUD_CLIENT  ClientInfo,
IN ULONG  FilterId,
IN ULONG  PinId,
IN SOUND_DEVICE_TYPE  DeviceType 
)

Definition at line 80 of file sup.c.

85{
87
88 for(Index = 0; Index < ClientInfo->NumPins; Index++)
89 {
90 if (ClientInfo->hPins[Index].FilterId == FilterId && ClientInfo->hPins[Index].PinId == PinId && ClientInfo->hPins[Index].Handle && ClientInfo->hPins[Index].Type == DeviceType)
91 {
92 if (ClientInfo->hPins[Index].Type != MIXER_DEVICE_TYPE)
93 {
94 ZwClose(ClientInfo->hPins[Index].Handle);
95 }
96 ClientInfo->hPins[Index].Handle = NULL;
97 return Index;
98 }
99 }
100 return MAXULONG;
101}
#define NULL
Definition: types.h:112
CLIENT_DATA ClientInfo
unsigned int ULONG
Definition: retypes.h:1
DeviceType
Definition: mmdrv.h:42
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
@ MIXER_DEVICE_TYPE
Definition: sndtypes.h:33
#define MAXULONG
Definition: typedefs.h:251
_In_ WDFCOLLECTION _In_ ULONG Index

Referenced by CreatePinCallback().

◆ FindProductName()

NTSTATUS FindProductName ( IN LPWSTR  PnpName,
IN ULONG  ProductNameSize,
OUT LPWSTR  ProductName 
)

Definition at line 254 of file sup.c.

258{
259 UNICODE_STRING KeyName = RTL_CONSTANT_STRING(L"\\Registry\\Machine\\System\\CurrentControlSet\\Control\\Class\\{4D36E96C-E325-11CE-BFC1-08002BE10318}");
260
262 WCHAR SubKey[20];
264 HANDLE hKey, hSubKey;
267 PKEY_FULL_INFORMATION KeyInformation;
268
269 for(Index = 0; Index < wcslen(PnpName); Index++)
270 {
271 if (PnpName[Index] == '#')
272 PnpName[Index] = L'\\';
273 }
274
275
276 /* initialize key attributes */
278
279 /* open the key */
280 Status = ZwOpenKey(&hKey, GENERIC_READ, &ObjectAttributes);
281
282 /* check for success */
283 if (!NT_SUCCESS(Status))
284 return Status;
285
286 /* query num of subkeys */
287 Status = ZwQueryKey(hKey, KeyFullInformation, NULL, 0, &Length);
288
290 {
291 DPRINT1("ZwQueryKey failed with %x\n", Status);
292 /* failed */
293 ZwClose(hKey);
294 return Status;
295 }
296
297 /* allocate key information struct */
298 KeyInformation = AllocateItem(NonPagedPool, Length);
299 if (!KeyInformation)
300 {
301 /* no memory */
302 ZwClose(hKey);
304 }
305
306 /* query num of subkeys */
307 Status = ZwQueryKey(hKey, KeyFullInformation, (PVOID)KeyInformation, Length, &Length);
308
309 if (!NT_SUCCESS(Status))
310 {
311 DPRINT1("ZwQueryKey failed with %x\n", Status);
312 FreeItem(KeyInformation);
313 ZwClose(hKey);
314 return Status;
315 }
316
317 /* now iterate through all subkeys */
318 for(Index = 0; Index < KeyInformation->SubKeys; Index++)
319 {
320 /* subkeys are always in the format 0000-XXXX */
321 swprintf(SubKey, L"%04u", Index);
322
323 /* initialize subkey name */
325
326 /* initialize key attributes */
328
329 /* open the sub key */
330 Status = ZwOpenKey(&hSubKey, GENERIC_READ, &ObjectAttributes);
331
332 /* check for success */
333 if (NT_SUCCESS(Status))
334 {
335 /* compare product name */
336 Status = CompareProductName(hSubKey, PnpName, ProductNameSize, ProductName);
337
338 /* close subkey */
339 ZwClose(hSubKey);
340
341 if (NT_SUCCESS(Status))
342 break;
343 }
344 }
345
346 /* free buffer */
347 FreeItem(KeyInformation);
348
349 /* close key */
350 ZwClose(hKey);
351
352 /* no matching key found */
353 return Status;
354}
LONG NTSTATUS
Definition: precomp.h:26
#define DPRINT1
Definition: precomp.h:8
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define GENERIC_READ
Definition: compat.h:135
#define swprintf
Definition: precomp.h:40
PVOID AllocateItem(IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes)
Definition: sup.c:20
NTSTATUS CompareProductName(IN HANDLE hSubKey, IN LPWSTR PnpName, IN ULONG ProductNameSize, OUT LPWSTR ProductName)
Definition: sup.c:191
VOID FreeItem(IN PVOID Item)
Definition: sup.c:33
#define NonPagedPool
Definition: env_spec_w32.h:307
FxAutoRegKey hKey
Status
Definition: gdiplustypes.h:25
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
#define OBJ_OPENIF
Definition: winternl.h:229
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ PNDIS_STRING SubKeyName
Definition: ndis.h:4725
@ KeyFullInformation
Definition: nt_native.h:1133
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
#define L(x)
Definition: ntvdm.h:50
static PNP_ID_NAME PnpName[]
Definition: pnpdump.c:52
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING KeyName
Definition: wdfdevice.h:2699
__wchar_t WCHAR
Definition: xmlstorage.h:180

◆ FreeItem()

VOID FreeItem ( IN PVOID  Item)

Definition at line 43 of file misc.c.

45{
47}
#define ExFreePool(addr)
Definition: env_spec_w32.h:352

◆ GetNumOfMixerDevices()

ULONG GetNumOfMixerDevices ( IN PDEVICE_OBJECT  DeviceObject)

◆ GetSysAudioDeviceCount()

ULONG GetSysAudioDeviceCount ( IN PDEVICE_OBJECT  DeviceObject)

Definition at line 42 of file sup.c.

44{
45 PWDMAUD_DEVICE_EXTENSION DeviceExtension;
49
50 /* setup the query request */
54
55 DeviceExtension = (PWDMAUD_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
56
57 /* query sysaudio for the device count */
59 if (!NT_SUCCESS(Status))
60 return 0;
61
62 return Count;
63}
KSDDKAPI NTSTATUS NTAPI KsSynchronousIoControlDevice(IN PFILE_OBJECT FileObject, IN KPROCESSOR_MODE RequestorMode, IN ULONG IoControl, IN PVOID InBuffer, IN ULONG InSize, OUT PVOID OutBuffer, IN ULONG OutSize, OUT PULONG BytesReturned)
Definition: api.c:1099
struct WDMAUD_DEVICE_EXTENSION * PWDMAUD_DEVICE_EXTENSION
struct KSIDENTIFIER KSPROPERTY
#define KSPROPERTY_TYPE_GET
Definition: dmksctrl.h:42
IN PDCB IN VBO IN ULONG IN BOOLEAN Pin
Definition: fatprocs.h:427
#define IOCTL_KS_PROPERTY
Definition: ks.h:127
@ KSPROPERTY_SYSAUDIO_DEVICE_COUNT
Definition: ksmedia.h:1168
#define KSPROPSETID_Sysaudio
Definition: ksmedia.h:1165
#define KernelMode
Definition: asm.h:34
int Count
Definition: noreturn.cpp:7
PFILE_OBJECT FileObject
Definition: wdmaud.h:62
ULONG Flags
Definition: ntfs.h:536
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_ ULONG _In_opt_ PWDF_MEMORY_DESCRIPTOR _In_opt_ PWDF_MEMORY_DESCRIPTOR _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_opt_ PULONG_PTR BytesReturned
Definition: wdfiotarget.h:1052

Referenced by Enum(), GetSysAudioDevicePnpName(), WdmAudCloseAllMixers(), and WdmAudInitWorkerRoutine().

◆ GetSysAudioDevicePnpName()

NTSTATUS GetSysAudioDevicePnpName ( IN PDEVICE_OBJECT  DeviceObject,
IN ULONG  DeviceIndex,
OUT LPWSTR Device 
)

Definition at line 357 of file sup.c.

361{
363 KSP_PIN Pin;
365 PWDMAUD_DEVICE_EXTENSION DeviceExtension;
366
367 /* first check if the device index is within bounds */
368 if (DeviceIndex >= GetSysAudioDeviceCount(DeviceObject))
370
371 /* setup the query request */
372 Pin.Property.Set = KSPROPSETID_Sysaudio;
374 Pin.Property.Flags = KSPROPERTY_TYPE_GET;
375 Pin.PinId = DeviceIndex;
376
377 DeviceExtension = (PWDMAUD_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
378
379 /* query sysaudio for the device path */
381
382 /* check if the request failed */
384 return STATUS_UNSUCCESSFUL;
385
386 /* allocate buffer for the device */
388 if (!Device)
390
391 /* query sysaudio again for the device path */
393
394 if (!NT_SUCCESS(Status))
395 {
396 /* failed */
398 return Status;
399 }
400
401 return Status;
402}
ULONG GetSysAudioDeviceCount(IN PDEVICE_OBJECT DeviceObject)
Definition: sup.c:42
@ KSPROPERTY_SYSAUDIO_DEVICE_INTERFACE_NAME
Definition: ksmedia.h:1171
Definition: ks.h:642
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474

Referenced by Enum().

◆ InsertPinHandle()

NTSTATUS InsertPinHandle ( IN PWDMAUD_CLIENT  ClientInfo,
IN ULONG  FilterId,
IN ULONG  PinId,
IN SOUND_DEVICE_TYPE  DeviceType,
IN HANDLE  PinHandle,
IN ULONG  FreeIndex 
)

Definition at line 104 of file sup.c.

111{
112 PWDMAUD_HANDLE Handles;
113
114 if (FreeIndex != MAXULONG)
115 {
116 /* re-use a free index */
117 ClientInfo->hPins[FreeIndex].Handle = PinHandle;
118 ClientInfo->hPins[FreeIndex].FilterId = FilterId;
119 ClientInfo->hPins[FreeIndex].PinId = PinId;
120 ClientInfo->hPins[FreeIndex].Type = DeviceType;
121
122 return STATUS_SUCCESS;
123 }
124
125 Handles = AllocateItem(NonPagedPool, sizeof(WDMAUD_HANDLE) * (ClientInfo->NumPins+1));
126
127 if (!Handles)
129
130 if (ClientInfo->NumPins)
131 {
132 RtlMoveMemory(Handles, ClientInfo->hPins, sizeof(WDMAUD_HANDLE) * ClientInfo->NumPins);
133 FreeItem(ClientInfo->hPins);
134 }
135
136 ClientInfo->hPins = Handles;
137 ClientInfo->hPins[ClientInfo->NumPins].Handle = PinHandle;
138 ClientInfo->hPins[ClientInfo->NumPins].Type = DeviceType;
139 ClientInfo->hPins[ClientInfo->NumPins].FilterId = FilterId;
140 ClientInfo->hPins[ClientInfo->NumPins].PinId = PinId;
141 ClientInfo->NumPins++;
142
143 return STATUS_SUCCESS;
144}
#define STATUS_SUCCESS
Definition: shellext.h:65
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:264

Referenced by CreatePinCallback().

◆ OpenDevice()

NTSTATUS OpenDevice ( IN LPWSTR  Device,
OUT PHANDLE  DeviceHandle,
OUT PFILE_OBJECT FileObject 
)

Definition at line 405 of file sup.c.

409{
411 HANDLE hDevice;
412
413 /* now open the device */
415
416 if (!NT_SUCCESS(Status))
417 {
418 return Status;
419 }
420
421 *DeviceHandle = hDevice;
422
423 if (FileObject)
424 {
426
427 if (!NT_SUCCESS(Status))
428 {
429 ZwClose(hDevice);
430 }
431 }
432
433 return Status;
434
435}
NTSTATUS WdmAudOpenSysAudioDevice(IN LPWSTR DeviceName, OUT PHANDLE Handle)
Definition: deviface.c:16
_Inout_ PUSB_DEVICE_HANDLE DeviceHandle
Definition: hubbusif.h:121
POBJECT_TYPE IoFileObjectType
Definition: iomgr.c:36
#define FILE_WRITE_DATA
Definition: nt_native.h:631
#define FILE_READ_DATA
Definition: nt_native.h:628
NTSTATUS NTAPI ObReferenceObjectByHandle(IN HANDLE Handle, IN ACCESS_MASK DesiredAccess, IN POBJECT_TYPE ObjectType, IN KPROCESSOR_MODE AccessMode, OUT PVOID *Object, OUT POBJECT_HANDLE_INFORMATION HandleInformation OPTIONAL)
Definition: obref.c:494
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:550

◆ OpenSysAudioDeviceByIndex()

NTSTATUS OpenSysAudioDeviceByIndex ( IN PDEVICE_OBJECT  DeviceObject,
IN ULONG  DeviceIndex,
IN PHANDLE  DeviceHandle,
IN PFILE_OBJECT FileObject 
)

◆ OpenWavePin()

NTSTATUS NTAPI OpenWavePin ( IN PWDMAUD_DEVICE_EXTENSION  DeviceExtension,
IN ULONG  FilterId,
IN ULONG  PinId,
IN LPWAVEFORMATEX  WaveFormatEx,
IN ACCESS_MASK  DesiredAccess,
OUT PHANDLE  PinHandle 
)

◆ SetIrpIoStatus()

◆ WdmAudCloseAllMixers()

VOID WdmAudCloseAllMixers ( IN PDEVICE_OBJECT  DeviceObject,
IN PWDMAUD_CLIENT  ClientInfo,
IN ULONG  Index 
)

Definition at line 501 of file mmixer.c.

505{
506 ULONG DeviceCount, DeviceIndex;
507
508 /* Get all mixers */
510
511 /* Close every mixer attached to the device */
512 for (DeviceIndex = 0; DeviceIndex < DeviceCount; DeviceIndex++)
513 {
515 {
516 DPRINT1("Failed to close mixer for device %lu\n", DeviceIndex);
517 }
518 }
519
520 /* Dereference event */
521 if (ClientInfo->hPins[Index].NotifyEvent)
522 {
523 ObDereferenceObject(ClientInfo->hPins[Index].NotifyEvent);
524 ClientInfo->hPins[Index].NotifyEvent = NULL;
525 }
526}
MIXER_CONTEXT MixerContext
Definition: mmixer.c:41
VOID CALLBACK EventCallback(IN PVOID MixerEventContext, IN HANDLE hMixer, IN ULONG NotificationType, IN ULONG Value)
Definition: mmixer.c:333
@ MM_STATUS_SUCCESS
Definition: mmixer.h:5
ULONG DeviceCount
Definition: mpu401.c:26
MIXER_STATUS MMixerClose(IN PMIXER_CONTEXT MixerContext, IN ULONG MixerId, IN PVOID MixerEventContext, IN PMIXER_EVENT MixerEventRoutine)
Definition: mixer.c:116
#define ObDereferenceObject
Definition: obfuncs.h:203

Referenced by WdmAudCleanup().

◆ WdmAudControlCloseMixer()

NTSTATUS WdmAudControlCloseMixer ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp,
IN PWDMAUD_DEVICE_INFO  DeviceInfo,
IN PWDMAUD_CLIENT  ClientInfo,
IN ULONG  Index 
)

Definition at line 475 of file mmixer.c.

481{
482 /* Remove event associated to this client */
484 {
485 DPRINT1("Failed to close mixer\n");
487 }
488
489 /* Dereference event */
490 if (ClientInfo->hPins[Index].NotifyEvent)
491 {
492 ObDereferenceObject(ClientInfo->hPins[Index].NotifyEvent);
493 ClientInfo->hPins[Index].NotifyEvent = NULL;
494 }
495
496 /* FIXME: do we need to free ClientInfo->hPins ? */
498}
NTSTATUS SetIrpIoStatus(IN PIRP Irp, IN NTSTATUS Status, IN ULONG Length)
Definition: sup.c:67

Referenced by WdmAudIoctlClose().

◆ WdmAudControlOpenMidi()

NTSTATUS WdmAudControlOpenMidi ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp,
IN PWDMAUD_DEVICE_INFO  DeviceInfo,
IN PWDMAUD_CLIENT  ClientInfo 
)

Definition at line 847 of file mmixer.c.

852{
855
856 Context.ClientInfo = ClientInfo;
857 Context.DeviceExtension = (PWDMAUD_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
858 Context.DeviceType = DeviceInfo->DeviceType;
859
861
864 else
866}
MIXER_STATUS CreatePinCallback(IN PVOID Ctx, IN ULONG VirtualDeviceId, IN ULONG PinId, IN HANDLE hFilter, IN PKSPIN_CONNECT PinConnect, IN ACCESS_MASK DesiredAccess, OUT PHANDLE PinHandle)
Definition: mmixer.c:774
MIXER_STATUS
Definition: mmixer.h:4
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:423
MIXER_STATUS MMixerOpenMidi(IN PMIXER_CONTEXT MixerContext, IN ULONG DeviceIndex, IN ULONG bMidiIn, IN PIN_CREATE_CALLBACK CreateCallback, IN PVOID Context, OUT PHANDLE PinHandle)
Definition: midi.c:454
@ MIDI_IN_DEVICE_TYPE
Definition: sndtypes.h:30

Referenced by WdmAudControlOpen().

◆ WdmAudControlOpenMixer()

NTSTATUS WdmAudControlOpenMixer ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp,
IN PWDMAUD_DEVICE_INFO  DeviceInfo,
IN PWDMAUD_CLIENT  ClientInfo 
)

Definition at line 411 of file mmixer.c.

416{
418 PWDMAUD_HANDLE Handles;
419 //PWDMAUD_DEVICE_EXTENSION DeviceExtension;
421 PKEVENT EventObject = NULL;
422
423 DPRINT("WdmAudControlOpenMixer\n");
424
425 //DeviceExtension = (PWDMAUD_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
426
427 if (DeviceInfo->u.hNotifyEvent)
428 {
430
431 if (!NT_SUCCESS(Status))
432 {
433 DPRINT1("Invalid notify event passed %p from client %p\n", DeviceInfo->u.hNotifyEvent, ClientInfo);
436 }
437 }
438
440 {
441 ObDereferenceObject(EventObject);
442 DPRINT1("Failed to open mixer\n");
444 }
445
446
447 Handles = AllocateItem(NonPagedPool, sizeof(WDMAUD_HANDLE) * (ClientInfo->NumPins+1));
448
449 if (Handles)
450 {
451 if (ClientInfo->NumPins)
452 {
453 RtlMoveMemory(Handles, ClientInfo->hPins, sizeof(WDMAUD_HANDLE) * ClientInfo->NumPins);
454 FreeItem(ClientInfo->hPins);
455 }
456
457 ClientInfo->hPins = Handles;
458 ClientInfo->hPins[ClientInfo->NumPins].Handle = hMixer;
459 ClientInfo->hPins[ClientInfo->NumPins].Type = MIXER_DEVICE_TYPE;
460 ClientInfo->hPins[ClientInfo->NumPins].NotifyEvent = EventObject;
461 ClientInfo->NumPins++;
462 }
463 else
464 {
465 ObDereferenceObject(EventObject);
467 }
468
469 DeviceInfo->hDevice = hMixer;
470
472}
NTSYSAPI void WINAPI DbgBreakPoint(void)
PVOID AllocateItem(IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes)
Definition: misc.c:30
VOID FreeItem(IN PVOID Item)
Definition: misc.c:43
HMIXER hMixer
Definition: test.c:10
#define UserMode
Definition: asm.h:35
POBJECT_TYPE ExEventObjectType
Definition: event.c:18
MIXER_STATUS MMixerOpen(IN PMIXER_CONTEXT MixerContext, IN ULONG MixerId, IN PVOID MixerEventContext, IN PMIXER_EVENT MixerEventRoutine, OUT PHANDLE MixerHandle)
Definition: mixer.c:77
#define DPRINT
Definition: sndvol32.h:71
#define EVENT_MODIFY_STATE
Definition: winbase.h:163

Referenced by WdmAudControlOpen().

◆ WdmAudControlOpenWave()

NTSTATUS WdmAudControlOpenWave ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp,
IN PWDMAUD_DEVICE_INFO  DeviceInfo,
IN PWDMAUD_CLIENT  ClientInfo 
)

Definition at line 825 of file mmixer.c.

830{
833
834 Context.ClientInfo = ClientInfo;
835 Context.DeviceExtension = (PWDMAUD_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
836 Context.DeviceType = DeviceInfo->DeviceType;
837
838 Status = MMixerOpenWave(&MixerContext, DeviceInfo->DeviceIndex, DeviceInfo->DeviceType == WAVE_IN_DEVICE_TYPE, &DeviceInfo->u.WaveFormatEx, CreatePinCallback, &Context, &DeviceInfo->hDevice);
839
842 else
844}
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:436
@ WAVE_IN_DEVICE_TYPE
Definition: sndtypes.h:28

Referenced by WdmAudControlOpen().

◆ WdmAudDeviceControl()

NTSTATUS NTAPI WdmAudDeviceControl ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 302 of file control.c.

305{
306 PIO_STACK_LOCATION IoStack;
309
311
312 DPRINT("WdmAudDeviceControl entered\n");
313
314 if (IoStack->Parameters.DeviceIoControl.InputBufferLength < sizeof(WDMAUD_DEVICE_INFO))
315 {
316 /* invalid parameter */
317 DPRINT1("Input buffer too small size %u expected %u\n", IoStack->Parameters.DeviceIoControl.InputBufferLength, sizeof(WDMAUD_DEVICE_INFO));
319 }
320
321 DeviceInfo = (PWDMAUD_DEVICE_INFO)Irp->AssociatedIrp.SystemBuffer;
322
324 {
325 /* invalid parameter */
326 DPRINT1("Error: device type not set\n");
328 }
329
330 if (!IoStack->FileObject || !IoStack->FileObject->FsContext)
331 {
332 /* file object parameter */
333 DPRINT1("Error: file object is not attached\n");
335 }
336 ClientInfo = (PWDMAUD_CLIENT)IoStack->FileObject->FsContext;
337
338 DPRINT("WdmAudDeviceControl entered\n");
339
340 switch(IoStack->Parameters.DeviceIoControl.IoControlCode)
341 {
368 case IOCTL_GETPOS:
369 case IOCTL_GETDEVID:
370 case IOCTL_GETVOLUME:
371 case IOCTL_SETVOLUME:
372
373 DPRINT1("Unhandled %x\n", IoStack->Parameters.DeviceIoControl.IoControlCode);
374 break;
375 }
376
378}
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
MMRESULT WdmAudSetControlDetails(IN HANDLE hMixer, IN DWORD MixerId, IN LPMIXERCONTROLDETAILS MixDetails, IN ULONG Flags)
Definition: mmixer.c:426
NTSTATUS NTAPI WdmAudFrameSize(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PWDMAUD_DEVICE_INFO DeviceInfo, IN PWDMAUD_CLIENT ClientInfo)
Definition: control.c:180
NTSTATUS NTAPI WdmAudGetDeviceInterface(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PWDMAUD_DEVICE_INFO DeviceInfo)
Definition: control.c:222
NTSTATUS NTAPI WdmAudIoctlClose(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PWDMAUD_DEVICE_INFO DeviceInfo, IN PWDMAUD_CLIENT ClientInfo)
Definition: control.c:149
NTSTATUS WdmAudControlDeviceState(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PWDMAUD_DEVICE_INFO DeviceInfo, IN PWDMAUD_CLIENT ClientInfo)
Definition: control.c:82
NTSTATUS WdmAudControlDeviceType(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PWDMAUD_DEVICE_INFO DeviceInfo, IN PWDMAUD_CLIENT ClientInfo)
Definition: control.c:44
NTSTATUS NTAPI WdmAudResetStream(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PWDMAUD_DEVICE_INFO DeviceInfo)
Definition: control.c:270
NTSTATUS WdmAudCapabilities(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PWDMAUD_DEVICE_INFO DeviceInfo, IN PWDMAUD_CLIENT ClientInfo)
Definition: control.c:118
NTSTATUS WdmAudControlOpen(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PWDMAUD_DEVICE_INFO DeviceInfo, IN PWDMAUD_CLIENT ClientInfo)
Definition: control.c:18
NTSTATUS NTAPI WdmAudGetMixerEvent(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PWDMAUD_DEVICE_INFO DeviceInfo, IN PWDMAUD_CLIENT ClientInfo)
Definition: mmixer.c:620
struct WDMAUD_CLIENT * PWDMAUD_CLIENT
if(dx< 0)
Definition: linetemp.h:194
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:239
@ MIN_SOUND_DEVICE_TYPE
Definition: sndtypes.h:36
@ MAX_SOUND_DEVICE_TYPE
Definition: sndtypes.h:37
PFILE_OBJECT FileObject
Definition: iotypes.h:3169
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3128
#define IOCTL_GETFRAMESIZE
Definition: interface.h:255
#define IOCTL_CLOSE_WDMAUD
Definition: interface.h:99
#define IOCTL_GETVOLUME
Definition: interface.h:170
#define IOCTL_GETPOS
Definition: interface.h:238
#define IOCTL_GETCONTROLDETAILS
Definition: interface.h:325
#define IOCTL_OPEN_WDMAUD
Definition: interface.h:82
#define IOCTL_RESET_STREAM
Definition: interface.h:374
#define IOCTL_GETDEVID
Definition: interface.h:152
#define IOCTL_GETCAPABILITIES
Definition: interface.h:204
#define IOCTL_SETCONTROLDETAILS
Definition: interface.h:307
#define IOCTL_GETLINEINFO
Definition: interface.h:272
#define IOCTL_SETDEVICE_STATE
Definition: interface.h:134
#define IOCTL_QUERYDEVICEINTERFACESTRING
Definition: interface.h:343
#define IOCTL_SETVOLUME
Definition: interface.h:187
#define IOCTL_GETNUMDEVS_TYPE
Definition: interface.h:117
#define IOCTL_GETLINECONTROLS
Definition: interface.h:290
#define IOCTL_GET_MIXER_EVENT
Definition: interface.h:359
struct WDMAUD_DEVICE_INFO * PWDMAUD_DEVICE_INFO
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2793

Referenced by DriverEntry().

◆ WdmAudFrameSize()

NTSTATUS NTAPI WdmAudFrameSize ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp,
IN PWDMAUD_DEVICE_INFO  DeviceInfo,
IN PWDMAUD_CLIENT  ClientInfo 
)

Definition at line 180 of file control.c.

185{
189 KSALLOCATOR_FRAMING Framing;
191
192 /* Get sysaudio pin file object */
194 if (!NT_SUCCESS(Status))
195 {
196 DPRINT1("Invalid buffer handle %p\n", DeviceInfo->hDevice);
197 return SetIrpIoStatus(Irp, Status, 0);
198 }
199
200 /* Setup get framing request */
204
206 /* Did we succeed */
207 if (NT_SUCCESS(Status))
208 {
209 /* Store framesize */
210 DeviceInfo->u.FrameSize = Framing.FrameSize;
211 }
212
213 /* Release file object */
215
217
218}
@ KSPROPERTY_CONNECTION_ALLOCATORFRAMING
Definition: ks.h:352
#define KSPROPSETID_Connection
Definition: ks.h:346
#define GENERIC_WRITE
Definition: nt_native.h:90
* PFILE_OBJECT
Definition: iotypes.h:1998

Referenced by WdmAudDeviceControl().

◆ WdmAudGetControlDetails()

NTSTATUS NTAPI WdmAudGetControlDetails ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp,
IN PWDMAUD_DEVICE_INFO  DeviceInfo,
IN PWDMAUD_CLIENT  ClientInfo 
)

Definition at line 530 of file mmixer.c.

535{
537
538 /* clear hmixer type flag */
539 DeviceInfo->Flags &= ~MIXER_OBJECTF_HMIXER;
540
541 /* query mmixer library */
542 Status = MMixerGetControlDetails(&MixerContext, DeviceInfo->hDevice, DeviceInfo->DeviceIndex, DeviceInfo->Flags, &DeviceInfo->u.MixDetails);
543
546 else
548}
MIXER_STATUS MMixerGetControlDetails(IN PMIXER_CONTEXT MixerContext, IN HANDLE MixerHandle, IN ULONG MixerId, IN ULONG Flags, OUT LPMIXERCONTROLDETAILS MixerControlDetails)
Definition: mixer.c:566

◆ WdmAudGetLineControls()

NTSTATUS NTAPI WdmAudGetLineControls ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp,
IN PWDMAUD_DEVICE_INFO  DeviceInfo,
IN PWDMAUD_CLIENT  ClientInfo 
)

Definition at line 574 of file mmixer.c.

579{
581
582 /* clear hmixer type flag */
583 DeviceInfo->Flags &= ~MIXER_OBJECTF_HMIXER;
584
585 /* query mixer library */
586 Status = MMixerGetLineControls(&MixerContext, DeviceInfo->hDevice, DeviceInfo->DeviceIndex, DeviceInfo->Flags, &DeviceInfo->u.MixControls);
587
590 else
592
593
594}
MIXER_STATUS MMixerGetLineControls(IN PMIXER_CONTEXT MixerContext, IN HANDLE MixerHandle, IN ULONG MixerId, IN ULONG Flags, OUT LPMIXERLINECONTROLSW MixerLineControls)
Definition: mixer.c:332

◆ WdmAudGetLineInfo()

NTSTATUS NTAPI WdmAudGetLineInfo ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp,
IN PWDMAUD_DEVICE_INFO  DeviceInfo,
IN PWDMAUD_CLIENT  ClientInfo 
)

Definition at line 552 of file mmixer.c.

557{
559
560 /* clear hmixer type flag */
561 DeviceInfo->Flags &= ~MIXER_OBJECTF_HMIXER;
562
563 /* query mixer library */
564 Status = MMixerGetLineInfo(&MixerContext, DeviceInfo->hDevice, DeviceInfo->DeviceIndex, DeviceInfo->Flags, &DeviceInfo->u.MixLine);
565
568 else
570}
MIXER_STATUS MMixerGetLineInfo(IN PMIXER_CONTEXT MixerContext, IN HANDLE MixerHandle, IN ULONG MixerId, IN ULONG Flags, OUT LPMIXERLINEW MixerLine)
Definition: mixer.c:149

◆ WdmAudGetMidiInDeviceCount()

ULONG WdmAudGetMidiInDeviceCount ( VOID  )

◆ WdmAudGetMidiOutDeviceCount()

ULONG WdmAudGetMidiOutDeviceCount ( VOID  )

◆ WdmAudGetMixerDeviceCount()

ULONG WdmAudGetMixerDeviceCount ( VOID  )

◆ WdmAudGetMixerEvent()

NTSTATUS NTAPI WdmAudGetMixerEvent ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp,
IN PWDMAUD_DEVICE_INFO  DeviceInfo,
IN PWDMAUD_CLIENT  ClientInfo 
)

Definition at line 620 of file mmixer.c.

625{
627 PEVENT_ENTRY EventEntry;
628
629 /* enumerate event list and check if there is a new event */
630 Entry = ClientInfo->MixerEventList.Flink;
631
632 while(Entry != &ClientInfo->MixerEventList)
633 {
634 /* grab event entry */
636
637 if (EventEntry->hMixer == DeviceInfo->hDevice)
638 {
639 /* found an entry */
640 DeviceInfo->u.MixerEvent.hMixer = EventEntry->hMixer;
641 DeviceInfo->u.MixerEvent.NotificationType = EventEntry->NotificationType;
642 DeviceInfo->u.MixerEvent.Value = EventEntry->Value;
643
644 /* remove entry from list */
645 RemoveEntryList(&EventEntry->Entry);
646
647 /* free event entry */
648 FreeItem(EventEntry);
649
650 /* done */
652 }
653
654 /* move to next */
655 Entry = Entry->Flink;
656 }
657
658 /* no event entry available */
660}
struct EVENT_ENTRY * PEVENT_ENTRY
#define RemoveEntryList(Entry)
Definition: env_spec_w32.h:986
Definition: wdmaud.h:38
ULONG Value
Definition: wdmaud.h:41
HANDLE hMixer
Definition: wdmaud.h:42
LIST_ENTRY Entry
Definition: wdmaud.h:39
ULONG NotificationType
Definition: wdmaud.h:40
base of all file and directory entries
Definition: entries.h:83
Definition: typedefs.h:120
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260

Referenced by WdmAudDeviceControl().

◆ WdmAudGetPnpNameByIndexAndType()

NTSTATUS WdmAudGetPnpNameByIndexAndType ( IN ULONG  DeviceIndex,
IN SOUND_DEVICE_TYPE  DeviceType,
OUT LPWSTR Device 
)

Definition at line 693 of file mmixer.c.

697{
699 {
701 return STATUS_SUCCESS;
702 else
703 return STATUS_UNSUCCESSFUL;
704 }
706 {
708 return STATUS_SUCCESS;
709 else
710 return STATUS_UNSUCCESSFUL;
711 }
712 else if (DeviceType == MIXER_DEVICE_TYPE)
713 {
715 }
716
717 return STATUS_UNSUCCESSFUL;
718}
#define UNIMPLEMENTED
Definition: debug.h:115
MIXER_STATUS MMixerGetWaveDevicePath(IN PMIXER_CONTEXT MixerContext, IN ULONG bWaveIn, IN ULONG DeviceId, OUT LPWSTR *DevicePath)
Definition: wave.c:659
MIXER_STATUS MMixerGetMidiDevicePath(IN PMIXER_CONTEXT MixerContext, IN ULONG bMidiIn, IN ULONG DeviceId, OUT LPWSTR *DevicePath)
Definition: midi.c:380
@ MIDI_OUT_DEVICE_TYPE
Definition: sndtypes.h:31
@ WAVE_OUT_DEVICE_TYPE
Definition: sndtypes.h:29

Referenced by WdmAudGetDeviceInterface().

◆ WdmAudGetWaveInDeviceCount()

ULONG WdmAudGetWaveInDeviceCount ( VOID  )

◆ WdmAudGetWaveOutDeviceCount()

ULONG WdmAudGetWaveOutDeviceCount ( VOID  )

◆ WdmAudMidiCapabilities()

NTSTATUS WdmAudMidiCapabilities ( IN PDEVICE_OBJECT  DeviceObject,
IN PWDMAUD_DEVICE_INFO  DeviceInfo,
IN PWDMAUD_CLIENT  ClientInfo,
IN PWDMAUD_DEVICE_EXTENSION  DeviceExtension 
)

Definition at line 747 of file mmixer.c.

752{
754
755 if (DeviceInfo->DeviceType == MIDI_IN_DEVICE_TYPE)
756 {
757 /* get capabilities */
758 Status = MMixerMidiInCapabilities(&MixerContext, DeviceInfo->DeviceIndex, &DeviceInfo->u.MidiInCaps);
759 }
760 else if (DeviceInfo->DeviceType == WAVE_OUT_DEVICE_TYPE)
761 {
762 /* get capabilities */
763 Status = MMixerMidiOutCapabilities(&MixerContext, DeviceInfo->DeviceIndex, &DeviceInfo->u.MidiOutCaps);
764 }
765
767 return STATUS_SUCCESS;
768 else
769 return STATUS_UNSUCCESSFUL;
770}
@ MM_STATUS_UNSUCCESSFUL
Definition: mmixer.h:11
MIXER_STATUS MMixerMidiInCapabilities(IN PMIXER_CONTEXT MixerContext, IN ULONG DeviceIndex, OUT LPMIDIINCAPSW Caps)
Definition: midi.c:344
MIXER_STATUS MMixerMidiOutCapabilities(IN PMIXER_CONTEXT MixerContext, IN ULONG DeviceIndex, OUT LPMIDIOUTCAPSW Caps)
Definition: midi.c:308

Referenced by WdmAudCapabilities().

◆ WdmAudMixerCapabilities()

NTSTATUS WdmAudMixerCapabilities ( IN PDEVICE_OBJECT  DeviceObject,
IN PWDMAUD_DEVICE_INFO  DeviceInfo,
IN PWDMAUD_CLIENT  ClientInfo,
IN PWDMAUD_DEVICE_EXTENSION  DeviceExtension 
)

Definition at line 398 of file mmixer.c.

403{
405 return STATUS_SUCCESS;
406
408}
MIXER_STATUS MMixerGetCapabilities(IN PMIXER_CONTEXT MixerContext, IN ULONG MixerIndex, OUT LPMIXERCAPSW MixerCaps)
Definition: mixer.c:38

Referenced by WdmAudCapabilities().

◆ WdmAudMixerInitialize()

NTSTATUS WdmAudMixerInitialize ( IN PDEVICE_OBJECT  DeviceObject)

Definition at line 380 of file mmixer.c.

382{
384
385 /* initialize the mixer library */
387
389 {
390 /* failed to initialize mmixer library */
391 DPRINT("MMixerInitialize failed with %lx\n", Status);
392 }
393
394 return Status;
395}
MIXER_STATUS Enum(IN PVOID EnumContext, IN ULONG DeviceIndex, OUT LPWSTR *DeviceName, OUT PHANDLE OutHandle, OUT PHANDLE OutKey)
Definition: mmixer.c:220
MIXER_STATUS MMixerInitialize(IN PMIXER_CONTEXT MixerContext, IN PMIXER_ENUM EnumFunction, IN PVOID EnumContext)
Definition: mixer.c:770

Referenced by WdmAudInitWorkerRoutine().

◆ WdmAudOpenSysaudio()

NTSTATUS WdmAudOpenSysaudio ( IN PDEVICE_OBJECT  DeviceObject,
IN PWDMAUD_CLIENT pClient 
)

Definition at line 206 of file deviface.c.

209{
211 PWDMAUD_DEVICE_EXTENSION DeviceExtension;
212
213 /* get device extension */
214 DeviceExtension = (PWDMAUD_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
215
216 if (!DeviceExtension->NumSysAudioDevices)
217 {
218 /* wdmaud failed to open sysaudio */
219 return STATUS_UNSUCCESSFUL;
220 }
221
222 /* sanity check */
223 ASSERT(!IsListEmpty(&DeviceExtension->SysAudioDeviceList));
224
225 /* allocate client context struct */
227
228 /* check for allocation failure */
229 if (!Client)
230 {
231 /* not enough memory */
233 }
234
235 /* zero client context struct */
237
238 /* initialize mixer event list */
239 InitializeListHead(&Client->MixerEventList);
240
241 /* store result */
242 *pClient = Client;
243
244 /* insert client into list */
245 ExInterlockedInsertTailList(&DeviceExtension->WdmAudClientList, &Client->Entry, &DeviceExtension->Lock);
246
247 /* done */
248 return STATUS_SUCCESS;
249}
#define IsListEmpty(ListHead)
Definition: env_spec_w32.h:954
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
PLIST_ENTRY NTAPI ExInterlockedInsertTailList(IN OUT PLIST_ENTRY ListHead, IN OUT PLIST_ENTRY ListEntry, IN OUT PKSPIN_LOCK Lock)
Definition: interlocked.c:140
#define ASSERT(a)
Definition: mode.c:44
Definition: client.c:28
LIST_ENTRY SysAudioDeviceList
Definition: wdmaud.h:60
LIST_ENTRY WdmAudClientList
Definition: wdmaud.h:63
KSPIN_LOCK Lock
Definition: wdmaud.h:58
ULONG NumSysAudioDevices
Definition: wdmaud.h:59

Referenced by WdmAudCreate().

◆ WdmAudOpenSysAudioDevice()

NTSTATUS WdmAudOpenSysAudioDevice ( IN LPWSTR  DeviceName,
OUT PHANDLE  Handle 
)

Definition at line 16 of file deviface.c.

19{
24
27
32 NULL,
33 0,
34 0,
37 NULL,
38 0,
40 NULL,
42
43 return Status;
44}
static const WCHAR SymbolicLink[]
Definition: interface.c:31
#define FILE_OPEN
Definition: from_kernel.h:54
#define FILE_SYNCHRONOUS_IO_NONALERT
Definition: from_kernel.h:31
ULONG Handle
Definition: gdb_input.c:15
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define SYNCHRONIZE
Definition: nt_native.h:61
NTSTATUS NTAPI IoCreateFile(OUT PHANDLE FileHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, OUT PIO_STATUS_BLOCK IoStatusBlock, IN PLARGE_INTEGER AllocationSize OPTIONAL, IN ULONG FileAttributes, IN ULONG ShareAccess, IN ULONG Disposition, IN ULONG CreateOptions, IN PVOID EaBuffer OPTIONAL, IN ULONG EaLength, IN CREATE_FILE_TYPE CreateFileType, IN PVOID ExtraCreateParameters OPTIONAL, IN ULONG Options)
Definition: file.c:3010
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_opt_ PCUNICODE_STRING DeviceName
Definition: wdfdevice.h:3275
#define IO_FORCE_ACCESS_CHECK
Definition: iotypes.h:540
#define IO_NO_PARAMETER_CHECKING
Definition: iotypes.h:541
@ CreateFileTypeNone
Definition: iotypes.h:535

Referenced by Open(), OpenDevice(), and WdmAudOpenSysAudioDevices().

◆ WdmAudOpenSysAudioDevices()

NTSTATUS WdmAudOpenSysAudioDevices ( IN PDEVICE_OBJECT  DeviceObject,
IN PWDMAUD_DEVICE_EXTENSION  DeviceExtension 
)

Definition at line 93 of file deviface.c.

96{
101 HANDLE hSysAudio;
103 UNICODE_STRING DeviceName = RTL_CONSTANT_STRING(L"\\Device\\sysaudio\\GLOBAL");
104
105 if (DeviceExtension->DeviceInterfaceSupport)
106 {
108 NULL,
109 0,
111
112 if (NT_SUCCESS(Status))
113 {
116 }
117
118
122 DeviceObject->DriverObject,
124 (PVOID)DeviceExtension,
125 &DeviceExtension->SysAudioNotification);
126 }
127 else
128 {
130 if (!Entry)
131 {
133 }
134
135
136 Length = wcslen(DeviceName.Buffer) + 1;
137 Entry->SymbolicLink.Length = 0;
138 Entry->SymbolicLink.MaximumLength = Length * sizeof(WCHAR);
139 Entry->SymbolicLink.Buffer = AllocateItem(NonPagedPool, Entry->SymbolicLink.MaximumLength);
140
141 if (!Entry->SymbolicLink.Buffer)
142 {
145 }
146
148
149 if (!NT_SUCCESS(Status))
150 {
151 FreeItem(Entry->SymbolicLink.Buffer);
153 return Status;
154 }
155
156 DPRINT("Opening device %S\n", Entry->SymbolicLink.Buffer);
157 Status = WdmAudOpenSysAudioDevice(Entry->SymbolicLink.Buffer, &hSysAudio);
158 if (!NT_SUCCESS(Status))
159 {
160 DPRINT1("Failed to open sysaudio %x\n", Status);
161 FreeItem(Entry->SymbolicLink.Buffer);
163 return Status;
164 }
165
166 InsertTailList(&DeviceExtension->SysAudioDeviceList, &Entry->Entry);
167 DeviceExtension->NumSysAudioDevices++;
168
169 /* get the file object */
171 if (!NT_SUCCESS(Status))
172 {
173 DPRINT1("Failed to reference FileObject %x\n", Status);
174 ZwClose(hSysAudio);
175 return Status;
176 }
177 DeviceExtension = (PWDMAUD_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
178 DeviceExtension->hSysAudio = hSysAudio;
179 DeviceExtension->FileObject = FileObject;
180 }
181
182 return Status;
183}
NTSTATUS WdmAudOpenSysAudioDeviceInterfaces(IN PWDMAUD_DEVICE_EXTENSION DeviceExtension, IN LPWSTR SymbolicLinkList)
Definition: deviface.c:60
NTSTATUS NTAPI DeviceInterfaceChangeCallback(IN PVOID NotificationStructure, IN PVOID Context)
Definition: deviface.c:48
#define InsertTailList(ListHead, Entry)
#define KSCATEGORY_SYSAUDIO
Definition: ksmedia.h:217
NTSYSAPI NTSTATUS NTAPI RtlAppendUnicodeStringToString(PUNICODE_STRING Destination, PUNICODE_STRING Source)
NTSTATUS NTAPI IoGetDeviceInterfaces(IN CONST GUID *InterfaceClassGuid, IN PDEVICE_OBJECT PhysicalDeviceObject OPTIONAL, IN ULONG Flags, OUT PWSTR *SymbolicLinkList)
Definition: deviface.c:454
NTSTATUS NTAPI IoRegisterPlugPlayNotification(_In_ IO_NOTIFICATION_EVENT_CATEGORY EventCategory, _In_ ULONG EventCategoryFlags, _In_opt_ PVOID EventCategoryData, _In_ PDRIVER_OBJECT DriverObject, _In_ PDRIVER_NOTIFICATION_CALLBACK_ROUTINE CallbackRoutine, _Inout_opt_ PVOID Context, _Out_ PVOID *NotificationEntry)
Definition: pnpnotify.c:345
Entry(ENTRY_TYPE etype)
Definition: entries.cpp:35
Definition: wdmaud.h:46
_In_opt_ PDEVICE_OBJECT _In_ ULONG _Outptr_result_nullonfailure_ _At_ * SymbolicLinkList(return==0, __drv_allocatesMem(Mem))) PZZWSTR *SymbolicLinkList
@ EventCategoryDeviceInterfaceChange
Definition: iotypes.h:1226
#define PNPNOTIFY_DEVICE_INTERFACE_INCLUDE_EXISTING_INTERFACES
Definition: iotypes.h:1239
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by WdmAudInitWorkerRoutine().

◆ WdmAudReadWrite()

NTSTATUS NTAPI WdmAudReadWrite ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 436 of file control.c.

439{
443 PIO_STACK_LOCATION IoStack;
445 PMDL Mdl;
446 BOOLEAN Read = TRUE;
448
449 /* allocate completion context */
451
452 if (!Context)
453 {
454 /* not enough memory */
455 Irp->IoStatus.Status = STATUS_INSUFFICIENT_RESOURCES;
457
458 /* done */
460 }
461
462 /* get current irp stack location */
464
465 /* store the input buffer in UserBuffer - as KsProbeStreamIrp operates on IRP_MJ_DEVICE_CONTROL */
466 Irp->UserBuffer = MmGetMdlVirtualAddress(Irp->MdlAddress);
467
468 /* sanity check */
469 ASSERT(Irp->UserBuffer);
470
471 /* get the length of the request length */
472 Length = IoStack->Parameters.Write.Length;
473
474 /* store outputbuffer length */
475 IoStack->Parameters.DeviceIoControl.OutputBufferLength = Length;
476
477 /* setup context */
478 Context->Length = Length;
480 Context->Mdl = Irp->MdlAddress;
481
482 /* store mdl address */
483 Mdl = Irp->MdlAddress;
484
485 /* remove mdladdress as KsProbeStreamIrp will interpret it as an already probed audio buffer */
486 Irp->MdlAddress = NULL;
487
488 if (IoStack->MajorFunction == IRP_MJ_WRITE)
489 {
490 /* probe the write stream irp */
491 Read = FALSE;
492 Status = KsProbeStreamIrp(Irp, KSPROBE_STREAMWRITE | KSPROBE_ALLOCATEMDL | KSPROBE_PROBEANDLOCK, Length);
493 }
494 else
495 {
496 /* probe the read stream irp */
497 Status = KsProbeStreamIrp(Irp, KSPROBE_STREAMREAD | KSPROBE_ALLOCATEMDL | KSPROBE_PROBEANDLOCK, Length);
498 }
499
500 if (!NT_SUCCESS(Status))
501 {
502 DPRINT1("KsProbeStreamIrp failed with Status %x Cancel %u\n", Status, Irp->Cancel);
503 Irp->MdlAddress = Mdl;
505 return SetIrpIoStatus(Irp, Status, 0);
506 }
507
508 /* get device info */
509 DeviceInfo = (PWDMAUD_DEVICE_INFO)Irp->AssociatedIrp.SystemBuffer;
511
512 /* now get sysaudio file object */
514 if (!NT_SUCCESS(Status))
515 {
516 DPRINT1("Invalid pin handle %p\n", DeviceInfo->hDevice);
517 Irp->MdlAddress = Mdl;
519 return SetIrpIoStatus(Irp, Status, 0);
520 }
521
522 /* store file object whose reference is released in the completion callback */
523 Context->FileObject = FileObject;
524
525 /* skip current irp stack location */
527
528 /* get next stack location */
530
531 /* prepare stack location */
532 IoStack->FileObject = FileObject;
533 IoStack->Parameters.Write.Length = Length;
534 IoStack->MajorFunction = IRP_MJ_WRITE;
535 IoStack->Parameters.DeviceIoControl.IoControlCode = (Read ? IOCTL_KS_READ_STREAM : IOCTL_KS_WRITE_STREAM);
537
538 /* mark irp as pending */
539// IoMarkIrpPending(Irp);
540 /* call the driver */
542 return Status;
543}
unsigned char BOOLEAN
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
KSDDKAPI NTSTATUS NTAPI KsProbeStreamIrp(IN PIRP Irp, IN ULONG ProbeFlags, IN ULONG HeaderSize)
Definition: irp.c:659
NTSTATUS NTAPI IoCompletion(PDEVICE_OBJECT DeviceObject, PIRP Irp, PVOID Ctx)
Definition: control.c:382
#define IoSetCompletionRoutine(_Irp, _CompletionRoutine, _Context, _InvokeOnSuccess, _InvokeOnError, _InvokeOnCancel)
Definition: irp.cpp:498
#define IOCTL_KS_READ_STREAM
Definition: ks.h:142
#define IOCTL_KS_WRITE_STREAM
Definition: ks.h:139
#define IoSkipCurrentIrpStackLocation(Irp)
Definition: ntifs_ex.h:421
PDEVICE_OBJECT NTAPI IoGetRelatedDeviceObject(IN PFILE_OBJECT FileObject)
Definition: device.c:1539
#define IoCallDriver
Definition: irp.c:1225
#define IRP_MJ_WRITE
Definition: rdpdr.c:47
_In_ BOOLEAN Read
Definition: strmini.h:479
_In_ WDFDEVICE _In_ PVOID _In_opt_ PMDL Mdl
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetNextIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2695
#define MmGetMdlVirtualAddress(_Mdl)

Referenced by DriverEntry().

◆ WdmAudRegisterDeviceInterface()

NTSTATUS WdmAudRegisterDeviceInterface ( IN PDEVICE_OBJECT  PhysicalDeviceObject,
IN PWDMAUD_DEVICE_EXTENSION  DeviceExtension 
)

Definition at line 186 of file deviface.c.

189{
192
194 if (NT_SUCCESS(Status))
195 {
198 //DeviceExtension->DeviceInterfaceSupport = TRUE;
199 return Status;
200 }
201
202 return Status;
203}
PDEVICE_OBJECT PhysicalDeviceObject
Definition: btrfs_drv.h:1157
#define KSCATEGORY_WDMAUD
Definition: ksmedia.h:222
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
NTSTATUS NTAPI IoRegisterDeviceInterface(IN PDEVICE_OBJECT PhysicalDeviceObject, IN CONST GUID *InterfaceClassGuid, IN PUNICODE_STRING ReferenceString OPTIONAL, OUT PUNICODE_STRING SymbolicLinkName)
Definition: deviface.c:955
NTSTATUS NTAPI IoSetDeviceInterfaceState(IN PUNICODE_STRING SymbolicLinkName, IN BOOLEAN Enable)
Definition: deviface.c:1311
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING SymbolicLinkName
Definition: wdfdevice.h:3739

Referenced by WdmaudAddDevice().

◆ WdmAudSetControlDetails()

NTSTATUS NTAPI WdmAudSetControlDetails ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp,
IN PWDMAUD_DEVICE_INFO  DeviceInfo,
IN PWDMAUD_CLIENT  ClientInfo 
)

Definition at line 598 of file mmixer.c.

603{
605
606 /* clear hmixer type flag */
607 DeviceInfo->Flags &= ~MIXER_OBJECTF_HMIXER;
608
609 /* query mixer library */
610 Status = MMixerSetControlDetails(&MixerContext, DeviceInfo->hDevice, DeviceInfo->DeviceIndex, DeviceInfo->Flags, &DeviceInfo->u.MixDetails);
611
614 else
616}
MIXER_STATUS MMixerSetControlDetails(IN PMIXER_CONTEXT MixerContext, IN HANDLE MixerHandle, IN ULONG MixerId, IN ULONG Flags, OUT LPMIXERCONTROLDETAILS MixerControlDetails)
Definition: mixer.c:496

◆ WdmAudWaveCapabilities()

NTSTATUS WdmAudWaveCapabilities ( IN PDEVICE_OBJECT  DeviceObject,
IN PWDMAUD_DEVICE_INFO  DeviceInfo,
IN PWDMAUD_CLIENT  ClientInfo,
IN PWDMAUD_DEVICE_EXTENSION  DeviceExtension 
)

Definition at line 721 of file mmixer.c.

726{
728
729 if (DeviceInfo->DeviceType == WAVE_IN_DEVICE_TYPE)
730 {
731 /* get capabilities */
732 Status = MMixerWaveInCapabilities(&MixerContext, DeviceInfo->DeviceIndex, &DeviceInfo->u.WaveInCaps);
733 }
734 else if (DeviceInfo->DeviceType == WAVE_OUT_DEVICE_TYPE)
735 {
736 /* get capabilities */
737 Status = MMixerWaveOutCapabilities(&MixerContext, DeviceInfo->DeviceIndex, &DeviceInfo->u.WaveOutCaps);
738 }
739
741 return STATUS_SUCCESS;
742 else
743 return Status;
744}
MIXER_STATUS MMixerWaveOutCapabilities(IN PMIXER_CONTEXT MixerContext, IN ULONG DeviceIndex, OUT LPWAVEOUTCAPSW Caps)
Definition: wave.c:527
MIXER_STATUS MMixerWaveInCapabilities(IN PMIXER_CONTEXT MixerContext, IN ULONG DeviceIndex, OUT LPWAVEINCAPSW Caps)
Definition: wave.c:491

Referenced by WdmAudCapabilities().

◆ WdmAudWaveInitialize()

NTSTATUS NTAPI WdmAudWaveInitialize ( IN PDEVICE_OBJECT  DeviceObject)

◆ WdmAudWrite()

NTSTATUS NTAPI WdmAudWrite ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)