ReactOS  0.4.14-dev-98-gb0d4763
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
_Must_inspect_result_ typedef _In_ PHYSICAL_ADDRESS _Inout_ PLARGE_INTEGER NumberOfBytes
Definition: iotypes.h:998
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
_Must_inspect_result_ _In_ FLT_CONTEXT_TYPE _In_ SIZE_T _In_ POOL_TYPE PoolType
Definition: fltkernel.h:1444

◆ 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 {
86  ULONG Index;
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 }
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
DeviceType
Definition: mmdrv.h:41
CLIENT_DATA ClientInfo
smooth NULL
Definition: ftsmooth.c:416
static const UCHAR Index[8]
Definition: usbohci.c:18
#define MAXULONG
Definition: typedefs.h:250
unsigned int ULONG
Definition: retypes.h:1

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;
266  ULONG Length, Index;
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 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING KeyName
Definition: ndis.h:4711
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ PNDIS_STRING SubKeyName
Definition: ndis.h:4723
NTSTATUS CompareProductName(IN HANDLE hSubKey, IN LPWSTR PnpName, IN ULONG ProductNameSize, OUT LPWSTR ProductName)
Definition: sup.c:191
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
LONG NTSTATUS
Definition: precomp.h:26
PVOID AllocateItem(IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes)
Definition: sup.c:20
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:64
#define OBJ_OPENIF
Definition: winternl.h:229
VOID FreeItem(IN PVOID Item)
Definition: sup.c:33
smooth NULL
Definition: ftsmooth.c:416
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define swprintf(buf, format,...)
Definition: sprintf.c:56
static const UCHAR Index[8]
Definition: usbohci.c:18
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
static const WCHAR L[]
Definition: oid.c:1250
#define GENERIC_READ
Definition: compat.h:124
Status
Definition: gdiplustypes.h:24
#define DPRINT1
Definition: precomp.h:8
unsigned int ULONG
Definition: retypes.h:1
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
static PNP_ID_NAME PnpName[]
Definition: pnpdump.c:52
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14

◆ FreeItem()

VOID FreeItem ( IN PVOID  Item)

Definition at line 43 of file misc.c.

45 {
46  ExFreePool(Item);
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 
56 
57  /* query sysaudio for the device count */
59  if (!NT_SUCCESS(Status))
60  return 0;
61 
62  return Count;
63 }
struct KSIDENTIFIER KSPROPERTY
#define IOCTL_KS_PROPERTY
Definition: ks.h:127
LONG NTSTATUS
Definition: precomp.h:26
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1015
#define KSPROPERTY_TYPE_GET
Definition: dmksctrl.h:42
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
PVOID DeviceExtension
Definition: env_spec_w32.h:418
IN PDCB IN VBO IN ULONG IN BOOLEAN Pin
Definition: fatprocs.h:415
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
ULONG Flags
Definition: ntfs.h:532
Status
Definition: gdiplustypes.h:24
PFILE_OBJECT FileObject
Definition: wdmaud.h:62
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
_In_ FILTER_INFORMATION_CLASS _In_ ULONG _Out_ PULONG BytesReturned
Definition: fltkernel.h:1716
#define KSPROPSETID_Sysaudio
Definition: ksmedia.h:1065
unsigned int ULONG
Definition: retypes.h:1

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 
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 */
397  FreeItem(*Device);
398  return Status;
399  }
400 
401  return Status;
402 }
struct KSIDENTIFIER KSPROPERTY
#define IOCTL_KS_PROPERTY
Definition: ks.h:127
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ PIRP _In_ PDEVICE_OBJECT Device
Definition: fatprocs.h:2020
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONG NTSTATUS
Definition: precomp.h:26
PVOID AllocateItem(IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes)
Definition: sup.c:20
#define KSPROPERTY_TYPE_GET
Definition: dmksctrl.h:42
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:64
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
VOID FreeItem(IN PVOID Item)
Definition: sup.c:33
struct WDMAUD_DEVICE_EXTENSION * PWDMAUD_DEVICE_EXTENSION
PVOID DeviceExtension
Definition: env_spec_w32.h:418
smooth NULL
Definition: ftsmooth.c:416
Definition: ks.h:642
IN PDCB IN VBO IN ULONG IN BOOLEAN Pin
Definition: fatprocs.h:415
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
ULONG Flags
Definition: ntfs.h:532
Status
Definition: gdiplustypes.h:24
PFILE_OBJECT FileObject
Definition: wdmaud.h:62
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
_In_ FILTER_INFORMATION_CLASS _In_ ULONG _Out_ PULONG BytesReturned
Definition: fltkernel.h:1716
#define KSPROPSETID_Sysaudio
Definition: ksmedia.h:1065
unsigned int ULONG
Definition: retypes.h:1
ULONG GetSysAudioDeviceCount(IN PDEVICE_OBJECT DeviceObject)
Definition: sup.c:42

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_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
DeviceType
Definition: mmdrv.h:41
PVOID AllocateItem(IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes)
Definition: sup.c:20
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:263
CLIENT_DATA ClientInfo
VOID FreeItem(IN PVOID Item)
Definition: sup.c:33
#define MAXULONG
Definition: typedefs.h:250
return STATUS_SUCCESS
Definition: btrfs.c:2966

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 }
_Inout_ PUSB_DEVICE_HANDLE DeviceHandle
Definition: hubbusif.h:121
_In_ PIRP _In_ PDEVICE_OBJECT Device
Definition: fatprocs.h:2020
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
LONG NTSTATUS
Definition: precomp.h:26
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:496
#define FILE_READ_DATA
Definition: nt_native.h:628
smooth NULL
Definition: ftsmooth.c:416
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
#define FILE_WRITE_DATA
Definition: nt_native.h:631
NTSTATUS WdmAudOpenSysAudioDevice(IN LPWSTR DeviceName, OUT PHANDLE Handle)
Definition: deviface.c:16
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
POBJECT_TYPE IoFileObjectType
Definition: iomgr.c:36
Status
Definition: gdiplustypes.h:24

◆ 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 }
VOID CALLBACK EventCallback(IN PVOID MixerEventContext, IN HANDLE hMixer, IN ULONG NotificationType, IN ULONG Value)
Definition: mmixer.c:333
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
CLIENT_DATA ClientInfo
MIXER_CONTEXT MixerContext
Definition: mmixer.c:46
ULONG DeviceCount
Definition: mpu401.c:26
smooth NULL
Definition: ftsmooth.c:416
MIXER_STATUS MMixerClose(IN PMIXER_CONTEXT MixerContext, IN ULONG MixerId, IN PVOID MixerEventContext, IN PMIXER_EVENT MixerEventRoutine)
Definition: mixer.c:116
static const UCHAR Index[8]
Definition: usbohci.c:18
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
#define DPRINT1
Definition: precomp.h:8
unsigned int ULONG
Definition: retypes.h:1
ULONG GetSysAudioDeviceCount(IN PDEVICE_OBJECT DeviceObject)
Definition: sup.c:42

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 }
VOID CALLBACK EventCallback(IN PVOID MixerEventContext, IN HANDLE hMixer, IN ULONG NotificationType, IN ULONG Value)
Definition: mmixer.c:333
_In_ PIRP Irp
Definition: csq.h:116
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
CLIENT_DATA ClientInfo
MIXER_CONTEXT MixerContext
Definition: mmixer.c:46
smooth NULL
Definition: ftsmooth.c:416
MIXER_STATUS MMixerClose(IN PMIXER_CONTEXT MixerContext, IN ULONG MixerId, IN PVOID MixerEventContext, IN PMIXER_EVENT MixerEventRoutine)
Definition: mixer.c:116
static const UCHAR Index[8]
Definition: usbohci.c:18
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
NTSTATUS SetIrpIoStatus(IN PIRP Irp, IN NTSTATUS Status, IN ULONG Length)
Definition: sup.c:67
#define DPRINT1
Definition: precomp.h:8
return STATUS_SUCCESS
Definition: btrfs.c:2966

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;
858  Context.DeviceType = DeviceInfo->DeviceType;
859 
861 
862  if (Status == MM_STATUS_SUCCESS)
864  else
866 }
_In_ PIRP Irp
Definition: csq.h:116
CLIENT_DATA ClientInfo
MIXER_CONTEXT MixerContext
Definition: mmixer.c:46
struct WDMAUD_DEVICE_EXTENSION * PWDMAUD_DEVICE_EXTENSION
PVOID DeviceExtension
Definition: env_spec_w32.h:418
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
Status
Definition: gdiplustypes.h:24
NTSTATUS SetIrpIoStatus(IN PIRP Irp, IN NTSTATUS Status, IN ULONG Length)
Definition: sup.c:67
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
MIXER_STATUS
Definition: mmixer.h:3
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
struct tagContext Context
Definition: acpixf.h:1024
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409
return STATUS_SUCCESS
Definition: btrfs.c:2966

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 {
417  HANDLE hMixer;
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);
434  DbgBreakPoint();
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 }
VOID CALLBACK EventCallback(IN PVOID MixerEventContext, IN HANDLE hMixer, IN ULONG NotificationType, IN ULONG Value)
Definition: mmixer.c:333
_In_ PIRP Irp
Definition: csq.h:116
PVOID AllocateItem(IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes)
Definition: misc.c:30
LONG NTSTATUS
Definition: precomp.h:26
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
void DbgBreakPoint()
Definition: mach.c:553
POBJECT_TYPE ExEventObjectType
Definition: event.c:22
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:263
CLIENT_DATA ClientInfo
VOID FreeItem(IN PVOID Item)
Definition: misc.c:43
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:496
MIXER_CONTEXT MixerContext
Definition: mmixer.c:46
HMIXER hMixer
Definition: test.c:10
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
Status
Definition: gdiplustypes.h:24
NTSTATUS SetIrpIoStatus(IN PIRP Irp, IN NTSTATUS Status, IN ULONG Length)
Definition: sup.c:67
#define DPRINT1
Definition: precomp.h:8
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 EVENT_MODIFY_STATE
Definition: winbase.h:163
return STATUS_SUCCESS
Definition: btrfs.c:2966

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;
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 
840  if (Status == MM_STATUS_SUCCESS)
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
_In_ PIRP Irp
Definition: csq.h:116
CLIENT_DATA ClientInfo
MIXER_CONTEXT MixerContext
Definition: mmixer.c:46
struct WDMAUD_DEVICE_EXTENSION * PWDMAUD_DEVICE_EXTENSION
PVOID DeviceExtension
Definition: env_spec_w32.h:418
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
Status
Definition: gdiplustypes.h:24
NTSTATUS SetIrpIoStatus(IN PIRP Irp, IN NTSTATUS Status, IN ULONG Length)
Definition: sup.c:67
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
MIXER_STATUS
Definition: mmixer.h:3
struct tagContext Context
Definition: acpixf.h:1024
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409
return STATUS_SUCCESS
Definition: btrfs.c:2966

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 
323  if (DeviceInfo->DeviceType < MIN_SOUND_DEVICE_TYPE || DeviceInfo->DeviceType > MAX_SOUND_DEVICE_TYPE)
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  {
342  case IOCTL_OPEN_WDMAUD:
350  case IOCTL_CLOSE_WDMAUD:
352  case IOCTL_GETFRAMESIZE:
354  case IOCTL_GETLINEINFO:
366  case IOCTL_RESET_STREAM:
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 }
NTSTATUS WdmAudControlDeviceType(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PWDMAUD_DEVICE_INFO DeviceInfo, IN PWDMAUD_CLIENT ClientInfo)
Definition: control.c:44
MMRESULT WdmAudGetLineInfo(IN HANDLE hMixer, IN DWORD MixerId, IN LPMIXERLINEW MixLine, IN ULONG Flags)
Definition: mmixer.c:405
#define IOCTL_SETDEVICE_STATE
Definition: interface.h:134
#define IOCTL_GETCONTROLDETAILS
Definition: interface.h:325
NTSTATUS SetIrpIoStatus(IN PIRP Irp, IN NTSTATUS Status, IN ULONG Length)
Definition: control.c:25
#define IOCTL_QUERYDEVICEINTERFACESTRING
Definition: interface.h:343
#define IOCTL_GETCAPABILITIES
Definition: interface.h:204
struct WDMAUD_CLIENT * PWDMAUD_CLIENT
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define IOCTL_GETLINEINFO
Definition: interface.h:272
NTSTATUS WdmAudControlDeviceState(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PWDMAUD_DEVICE_INFO DeviceInfo, IN PWDMAUD_CLIENT ClientInfo)
Definition: control.c:82
NTSTATUS WdmAudCapabilities(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PWDMAUD_DEVICE_INFO DeviceInfo, IN PWDMAUD_CLIENT ClientInfo)
Definition: control.c:118
#define IOCTL_SETVOLUME
Definition: interface.h:187
CLIENT_DATA ClientInfo
#define IOCTL_GETDEVID
Definition: interface.h:152
NTSTATUS NTAPI WdmAudResetStream(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PWDMAUD_DEVICE_INFO DeviceInfo)
Definition: control.c:270
#define IOCTL_GETLINECONTROLS
Definition: interface.h:290
MMRESULT WdmAudSetControlDetails(IN HANDLE hMixer, IN DWORD MixerId, IN LPMIXERCONTROLDETAILS MixDetails, IN ULONG Flags)
Definition: mmixer.c:431
MMRESULT WdmAudGetControlDetails(IN HANDLE hMixer, IN DWORD MixerId, IN LPMIXERCONTROLDETAILS MixDetails, IN ULONG Flags)
Definition: mmixer.c:445
void DPRINT(...)
Definition: polytest.cpp:61
#define IOCTL_OPEN_WDMAUD
Definition: interface.h:82
if(!(yy_init))
Definition: macro.lex.yy.c:714
#define IOCTL_GETNUMDEVS_TYPE
Definition: interface.h:117
struct _DeviceInfo DeviceInfo
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
MMRESULT WdmAudGetLineControls(IN HANDLE hMixer, IN DWORD MixerId, IN LPMIXERLINECONTROLSW MixControls, IN ULONG Flags)
Definition: mmixer.c:418
#define IOCTL_GETVOLUME
Definition: interface.h:170
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
PFILE_OBJECT FileObject
Definition: iotypes.h:2813
NTSTATUS NTAPI WdmAudFrameSize(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PWDMAUD_DEVICE_INFO DeviceInfo, IN PWDMAUD_CLIENT ClientInfo)
Definition: control.c:180
NTSTATUS WdmAudControlOpen(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PWDMAUD_DEVICE_INFO DeviceInfo, IN PWDMAUD_CLIENT ClientInfo)
Definition: control.c:18
NTSTATUS NTAPI WdmAudGetDeviceInterface(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PWDMAUD_DEVICE_INFO DeviceInfo)
Definition: control.c:222
struct WDMAUD_DEVICE_INFO * PWDMAUD_DEVICE_INFO
#define DPRINT1
Definition: precomp.h:8
#define IOCTL_CLOSE_WDMAUD
Definition: interface.h:99
NTSTATUS NTAPI WdmAudGetMixerEvent(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PWDMAUD_DEVICE_INFO DeviceInfo, IN PWDMAUD_CLIENT ClientInfo)
Definition: mmixer.c:620
#define IOCTL_GETPOS
Definition: interface.h:238
NTSTATUS NTAPI WdmAudIoctlClose(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PWDMAUD_DEVICE_INFO DeviceInfo, IN PWDMAUD_CLIENT ClientInfo)
Definition: control.c:149
#define IOCTL_GET_MIXER_EVENT
Definition: interface.h:359
#define IOCTL_GETFRAMESIZE
Definition: interface.h:255
#define IOCTL_SETCONTROLDETAILS
Definition: interface.h:307
#define IOCTL_RESET_STREAM
Definition: interface.h:374
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2772

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 
216  return SetIrpIoStatus(Irp, Status, sizeof(WDMAUD_DEVICE_INFO));
217 
218 }
#define IOCTL_KS_PROPERTY
Definition: ks.h:127
NTSTATUS SetIrpIoStatus(IN PIRP Irp, IN NTSTATUS Status, IN ULONG Length)
Definition: control.c:25
_In_ PIRP Irp
Definition: csq.h:116
LONG NTSTATUS
Definition: precomp.h:26
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
#define KSPROPERTY_TYPE_GET
Definition: dmksctrl.h:42
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
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:496
#define GENERIC_WRITE
Definition: nt_native.h:90
smooth NULL
Definition: ftsmooth.c:416
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
* PFILE_OBJECT
Definition: iotypes.h:1955
POBJECT_TYPE IoFileObjectType
Definition: iomgr.c:36
Status
Definition: gdiplustypes.h:24
_In_ DWORD Property
Definition: setupapi.h:1545
_In_ FILTER_INFORMATION_CLASS _In_ ULONG _Out_ PULONG BytesReturned
Definition: fltkernel.h:1716
#define DPRINT1
Definition: precomp.h:8
unsigned int ULONG
Definition: retypes.h:1
const GUID KSPROPSETID_Connection
Definition: control.c:18

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 
544  if (Status == MM_STATUS_SUCCESS)
546  else
548 }
_In_ PIRP Irp
Definition: csq.h:116
MIXER_STATUS MMixerGetControlDetails(IN PMIXER_CONTEXT MixerContext, IN HANDLE MixerHandle, IN ULONG MixerId, IN ULONG Flags, OUT LPMIXERCONTROLDETAILS MixerControlDetails)
Definition: mixer.c:566
MIXER_CONTEXT MixerContext
Definition: mmixer.c:46
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define MIXER_OBJECTF_HMIXER
Definition: mmsystem.h:301
Status
Definition: gdiplustypes.h:24
NTSTATUS SetIrpIoStatus(IN PIRP Irp, IN NTSTATUS Status, IN ULONG Length)
Definition: sup.c:67
MIXER_STATUS
Definition: mmixer.h:3
return STATUS_SUCCESS
Definition: btrfs.c:2966

◆ 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 
588  if (Status == MM_STATUS_SUCCESS)
590  else
592 
593 
594 }
_In_ PIRP Irp
Definition: csq.h:116
MIXER_CONTEXT MixerContext
Definition: mmixer.c:46
MIXER_STATUS MMixerGetLineControls(IN PMIXER_CONTEXT MixerContext, IN HANDLE MixerHandle, IN ULONG MixerId, IN ULONG Flags, OUT LPMIXERLINECONTROLSW MixerLineControls)
Definition: mixer.c:332
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define MIXER_OBJECTF_HMIXER
Definition: mmsystem.h:301
Status
Definition: gdiplustypes.h:24
NTSTATUS SetIrpIoStatus(IN PIRP Irp, IN NTSTATUS Status, IN ULONG Length)
Definition: sup.c:67
MIXER_STATUS
Definition: mmixer.h:3
return STATUS_SUCCESS
Definition: btrfs.c:2966

◆ 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 
566  if (Status == MM_STATUS_SUCCESS)
568  else
570 }
_In_ PIRP Irp
Definition: csq.h:116
MIXER_STATUS MMixerGetLineInfo(IN PMIXER_CONTEXT MixerContext, IN HANDLE MixerHandle, IN ULONG MixerId, IN ULONG Flags, OUT LPMIXERLINEW MixerLine)
Definition: mixer.c:149
MIXER_CONTEXT MixerContext
Definition: mmixer.c:46
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define MIXER_OBJECTF_HMIXER
Definition: mmsystem.h:301
Status
Definition: gdiplustypes.h:24
NTSTATUS SetIrpIoStatus(IN PIRP Irp, IN NTSTATUS Status, IN ULONG Length)
Definition: sup.c:67
MIXER_STATUS
Definition: mmixer.h:3
return STATUS_SUCCESS
Definition: btrfs.c:2966

◆ 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 _Entry Entry
Definition: kefuncs.h:640
_In_ PIRP Irp
Definition: csq.h:116
HANDLE hMixer
Definition: wdmaud.h:42
LIST_ENTRY Entry
Definition: wdmaud.h:39
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
CLIENT_DATA ClientInfo
VOID FreeItem(IN PVOID Item)
Definition: misc.c:43
ULONG Value
Definition: wdmaud.h:41
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
struct EVENT_ENTRY * PEVENT_ENTRY
Definition: typedefs.h:117
NTSTATUS SetIrpIoStatus(IN PIRP Irp, IN NTSTATUS Status, IN ULONG Length)
Definition: sup.c:67
ULONG NotificationType
Definition: wdmaud.h:40
return STATUS_SUCCESS
Definition: btrfs.c:2966
base of all file and directory entries
Definition: entries.h:82
Definition: wdmaud.h:37

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 }
DeviceType
Definition: mmdrv.h:41
MIXER_STATUS MMixerGetMidiDevicePath(IN PMIXER_CONTEXT MixerContext, IN ULONG bMidiIn, IN ULONG DeviceId, OUT LPWSTR *DevicePath)
Definition: midi.c:380
MIXER_CONTEXT MixerContext
Definition: mmixer.c:46
MIXER_STATUS MMixerGetWaveDevicePath(IN PMIXER_CONTEXT MixerContext, IN ULONG bWaveIn, IN ULONG DeviceId, OUT LPWSTR *DevicePath)
Definition: wave.c:659
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define UNIMPLEMENTED
Definition: debug.h:114
return STATUS_SUCCESS
Definition: btrfs.c:2966

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 
766  if (Status == MM_STATUS_SUCCESS)
767  return STATUS_SUCCESS;
768  else
769  return STATUS_UNSUCCESSFUL;
770 }
MIXER_CONTEXT MixerContext
Definition: mmixer.c:46
MIXER_STATUS MMixerMidiOutCapabilities(IN PMIXER_CONTEXT MixerContext, IN ULONG DeviceIndex, OUT LPMIDIOUTCAPSW Caps)
Definition: midi.c:308
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
Status
Definition: gdiplustypes.h:24
MIXER_STATUS
Definition: mmixer.h:3
MIXER_STATUS MMixerMidiInCapabilities(IN PMIXER_CONTEXT MixerContext, IN ULONG DeviceIndex, OUT LPMIDIINCAPSW Caps)
Definition: midi.c:344
return STATUS_SUCCESS
Definition: btrfs.c:2966

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 {
404  if (MMixerGetCapabilities(&MixerContext, DeviceInfo->DeviceIndex, &DeviceInfo->u.MixCaps) == MM_STATUS_SUCCESS)
405  return STATUS_SUCCESS;
406 
408 }
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
MIXER_CONTEXT MixerContext
Definition: mmixer.c:46
MIXER_STATUS MMixerGetCapabilities(IN PMIXER_CONTEXT MixerContext, IN ULONG MixerIndex, OUT LPMIXERCAPSW MixerCaps)
Definition: mixer.c:38
return STATUS_SUCCESS
Definition: btrfs.c:2966

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 
388  if (Status != MM_STATUS_SUCCESS)
389  {
390  /* failed to initialize mmixer library */
391  DPRINT("MMixerInitialize failed with %lx\n", Status);
392  }
393 
394  return Status;
395 }
MIXER_STATUS MMixerInitialize(IN PMIXER_CONTEXT MixerContext, IN PMIXER_ENUM EnumFunction, IN PVOID EnumContext)
Definition: mixer.c:770
MIXER_CONTEXT MixerContext
Definition: mmixer.c:46
void DPRINT(...)
Definition: polytest.cpp:61
MIXER_STATUS Enum(IN PVOID EnumContext, IN ULONG DeviceIndex, OUT LPWSTR *DeviceName, OUT PHANDLE OutHandle, OUT PHANDLE OutKey)
Definition: mmixer.c:225
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
MIXER_STATUS
Definition: mmixer.h:3

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 */
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 }
Definition: client.c:29
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
PLIST_ENTRY NTAPI ExInterlockedInsertTailList(IN OUT PLIST_ENTRY ListHead, IN OUT PLIST_ENTRY ListEntry, IN OUT PKSPIN_LOCK Lock)
Definition: interlocked.c:140
PVOID AllocateItem(IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes)
Definition: misc.c:30
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
struct WDMAUD_DEVICE_EXTENSION * PWDMAUD_DEVICE_EXTENSION
ULONG NumSysAudioDevices
Definition: wdmaud.h:59
PVOID DeviceExtension
Definition: env_spec_w32.h:418
if(!(yy_init))
Definition: macro.lex.yy.c:714
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
LIST_ENTRY SysAudioDeviceList
Definition: wdmaud.h:60
KSPIN_LOCK Lock
Definition: wdmaud.h:58
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
return STATUS_SUCCESS
Definition: btrfs.c:2966
LIST_ENTRY WdmAudClientList
Definition: wdmaud.h:63

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,
35  FILE_OPEN,
37  NULL,
38  0,
40  NULL,
42 
43  return Status;
44 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
#define IO_FORCE_ACCESS_CHECK
Definition: iotypes.h:508
LONG NTSTATUS
Definition: precomp.h:26
WCHAR DeviceName[]
Definition: adapter.cpp:21
#define OBJ_OPENIF
Definition: winternl.h:229
#define IO_NO_PARAMETER_CHECKING
Definition: iotypes.h:509
#define GENERIC_WRITE
Definition: nt_native.h:90
smooth NULL
Definition: ftsmooth.c:416
_In_ HANDLE Handle
Definition: extypes.h:390
#define GENERIC_READ
Definition: compat.h:124
#define SYNCHRONIZE
Definition: nt_native.h:61
Status
Definition: gdiplustypes.h:24
#define FILE_OPEN
Definition: from_kernel.h:54
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
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:3009
#define FILE_SYNCHRONOUS_IO_NONALERT
Definition: from_kernel.h:31
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
static const WCHAR SymbolicLink[]
Definition: interface.c:31

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 {
100  ULONG Length;
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  {
143  FreeItem(Entry);
145  }
146 
148 
149  if (!NT_SUCCESS(Status))
150  {
151  FreeItem(Entry->SymbolicLink.Buffer);
152  FreeItem(Entry);
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);
162  FreeItem(Entry);
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  }
178  DeviceExtension->hSysAudio = hSysAudio;
179  DeviceExtension->FileObject = FileObject;
180  }
181 
182  return Status;
183 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_opt_ PDEVICE_OBJECT _In_ ULONG _Outptr_result_nullonfailure_ _At_ * SymbolicLinkList(return==0, __drv_allocatesMem(Mem))) PZZWSTR *SymbolicLinkList
struct _Entry Entry
Definition: kefuncs.h:640
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
PVOID AllocateItem(IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes)
Definition: misc.c:30
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI IoGetDeviceInterfaces(IN CONST GUID *InterfaceClassGuid, IN PDEVICE_OBJECT PhysicalDeviceObject OPTIONAL, IN ULONG Flags, OUT PWSTR *SymbolicLinkList)
Definition: deviface.c:454
#define PNPNOTIFY_DEVICE_INTERFACE_INCLUDE_EXISTING_INTERFACES
Definition: iotypes.h:1196
WCHAR DeviceName[]
Definition: adapter.cpp:21
#define InsertTailList(ListHead, Entry)
VOID FreeItem(IN PVOID Item)
Definition: misc.c:43
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:496
#define FILE_READ_DATA
Definition: nt_native.h:628
Entry(ENTRY_TYPE etype)
Definition: entries.cpp:35
struct WDMAUD_DEVICE_EXTENSION * PWDMAUD_DEVICE_EXTENSION
PVOID DeviceExtension
Definition: env_spec_w32.h:418
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
#define FILE_WRITE_DATA
Definition: nt_native.h:631
NTSTATUS NTAPI DeviceInterfaceChangeCallback(IN PVOID NotificationStructure, IN PVOID Context)
Definition: deviface.c:48
#define KSCATEGORY_SYSAUDIO
Definition: ksmedia.h:217
NTSTATUS WdmAudOpenSysAudioDevice(IN LPWSTR DeviceName, OUT PHANDLE Handle)
Definition: deviface.c:16
Definition: wdmaud.h:45
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
* PFILE_OBJECT
Definition: iotypes.h:1955
static const WCHAR L[]
Definition: oid.c:1250
NTSTATUS NTAPI IoRegisterPlugPlayNotification(IN IO_NOTIFICATION_EVENT_CATEGORY EventCategory, IN ULONG EventCategoryFlags, IN PVOID EventCategoryData OPTIONAL, IN PDRIVER_OBJECT DriverObject, IN PDRIVER_NOTIFICATION_CALLBACK_ROUTINE CallbackRoutine, IN PVOID Context, OUT PVOID *NotificationEntry)
Definition: pnpnotify.c:249
POBJECT_TYPE IoFileObjectType
Definition: iomgr.c:36
NTSTATUS WdmAudOpenSysAudioDeviceInterfaces(IN PWDMAUD_DEVICE_EXTENSION DeviceExtension, IN LPWSTR SymbolicLinkList)
Definition: deviface.c:60
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
NTSYSAPI NTSTATUS NTAPI RtlAppendUnicodeStringToString(PUNICODE_STRING Destination, PUNICODE_STRING Source)
#define DPRINT1
Definition: precomp.h:8
unsigned int ULONG
Definition: retypes.h:1
WCHAR * LPWSTR
Definition: xmlstorage.h:184
return STATUS_SUCCESS
Definition: btrfs.c:2966
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
base of all file and directory entries
Definition: entries.h:82
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14

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;
444  ULONG Length;
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;
504  FreeItem(Context);
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;
518  FreeItem(Context);
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 */
529  IoStack = IoGetNextIrpStackLocation(Irp);
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 }
_In_ BOOLEAN Read
Definition: strmini.h:479
#define IOCTL_KS_WRITE_STREAM
Definition: ks.h:139
#define TRUE
Definition: types.h:120
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
NTSTATUS SetIrpIoStatus(IN PIRP Irp, IN NTSTATUS Status, IN ULONG Length)
Definition: control.c:25
#define MmGetMdlVirtualAddress(_Mdl)
_In_ PIRP Irp
Definition: csq.h:116
#define IOCTL_KS_READ_STREAM
Definition: ks.h:142
PVOID AllocateItem(IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes)
Definition: misc.c:30
KSDDKAPI NTSTATUS NTAPI KsProbeStreamIrp(IN PIRP Irp, IN ULONG ProbeFlags, IN ULONG HeaderSize)
Definition: irp.c:647
LONG NTSTATUS
Definition: precomp.h:26
PDEVICE_OBJECT NTAPI IoGetRelatedDeviceObject(IN PFILE_OBJECT FileObject)
Definition: device.c:1539
#define IoSetCompletionRoutine(_Irp, _CompletionRoutine, _Context, _InvokeOnSuccess, _InvokeOnError, _InvokeOnCancel)
Definition: irp.cpp:515
VOID FreeItem(IN PVOID Item)
Definition: misc.c:43
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:496
#define GENERIC_WRITE
Definition: nt_native.h:90
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
#define IoCompleteRequest
Definition: irp.c:1240
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
struct _DeviceInfo DeviceInfo
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
* PFILE_OBJECT
Definition: iotypes.h:1955
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetNextIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2647
POBJECT_TYPE IoFileObjectType
Definition: iomgr.c:36
Status
Definition: gdiplustypes.h:24
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
PFILE_OBJECT FileObject
Definition: iotypes.h:2813
struct WDMAUD_DEVICE_INFO * PWDMAUD_DEVICE_INFO
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
#define IoSkipCurrentIrpStackLocation(Irp)
Definition: ntifs_ex.h:421
#define DPRINT1
Definition: precomp.h:8
struct tagContext Context
Definition: acpixf.h:1024
unsigned int ULONG
Definition: retypes.h:1
#define IO_NO_INCREMENT
Definition: iotypes.h:566
#define IRP_MJ_WRITE
Definition: rdpdr.c:47
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2772
NTSTATUS NTAPI IoCompletion(PDEVICE_OBJECT DeviceObject, PIRP Irp, PVOID Ctx)
Definition: control.c:382

Referenced by DriverEntry().

◆ WdmAudRegisterDeviceInterface()

NTSTATUS WdmAudRegisterDeviceInterface ( IN PDEVICE_OBJECT  PhysicalDeviceObject,
IN PWDMAUD_DEVICE_EXTENSION  DeviceExtension 
)

Definition at line 186 of file deviface.c.

189 {
191  UNICODE_STRING SymbolicLinkName;
192 
194  if (NT_SUCCESS(Status))
195  {
196  IoSetDeviceInterfaceState(&SymbolicLinkName, TRUE);
197  RtlFreeUnicodeString(&SymbolicLinkName);
198  //DeviceExtension->DeviceInterfaceSupport = TRUE;
199  return Status;
200  }
201 
202  return Status;
203 }
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
PDEVICE_OBJECT PhysicalDeviceObject
Definition: btrfs_drv.h:1114
const GUID KSCATEGORY_WDMAUD
Definition: entry.c:16
smooth NULL
Definition: ftsmooth.c:416
NTSTATUS NTAPI IoSetDeviceInterfaceState(IN PUNICODE_STRING SymbolicLinkName, IN BOOLEAN Enable)
Definition: deviface.c:1311
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
Status
Definition: gdiplustypes.h:24
NTSTATUS NTAPI IoRegisterDeviceInterface(IN PDEVICE_OBJECT PhysicalDeviceObject, IN CONST GUID *InterfaceClassGuid, IN PUNICODE_STRING ReferenceString OPTIONAL, OUT PUNICODE_STRING SymbolicLinkName)
Definition: deviface.c:955

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 
612  if (Status == MM_STATUS_SUCCESS)
614  else
616 }
_In_ PIRP Irp
Definition: csq.h:116
MIXER_CONTEXT MixerContext
Definition: mmixer.c:46
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define MIXER_OBJECTF_HMIXER
Definition: mmsystem.h:301
Status
Definition: gdiplustypes.h:24
NTSTATUS SetIrpIoStatus(IN PIRP Irp, IN NTSTATUS Status, IN ULONG Length)
Definition: sup.c:67
MIXER_STATUS MMixerSetControlDetails(IN PMIXER_CONTEXT MixerContext, IN HANDLE MixerHandle, IN ULONG MixerId, IN ULONG Flags, OUT LPMIXERCONTROLDETAILS MixerControlDetails)
Definition: mixer.c:496
MIXER_STATUS
Definition: mmixer.h:3
return STATUS_SUCCESS
Definition: btrfs.c:2966

◆ 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 
740  if (Status == MM_STATUS_SUCCESS)
741  return STATUS_SUCCESS;
742  else
743  return Status;
744 }
MIXER_CONTEXT MixerContext
Definition: mmixer.c:46
MIXER_STATUS MMixerWaveInCapabilities(IN PMIXER_CONTEXT MixerContext, IN ULONG DeviceIndex, OUT LPWAVEINCAPSW Caps)
Definition: wave.c:491
MIXER_STATUS MMixerWaveOutCapabilities(IN PMIXER_CONTEXT MixerContext, IN ULONG DeviceIndex, OUT LPWAVEOUTCAPSW Caps)
Definition: wave.c:527
Status
Definition: gdiplustypes.h:24
MIXER_STATUS
Definition: mmixer.h:3
return STATUS_SUCCESS
Definition: btrfs.c:2966

Referenced by WdmAudCapabilities().

◆ WdmAudWaveInitialize()

NTSTATUS NTAPI WdmAudWaveInitialize ( IN PDEVICE_OBJECT  DeviceObject)

◆ WdmAudWrite()

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