ReactOS  0.4.14-dev-358-gbef841c
dispatcher.c
Go to the documentation of this file.
1 /*
2  * COPYRIGHT: See COPYING in the top level directory
3  * PROJECT: ReactOS Kernel Streaming
4  * FILE: drivers/wdm/audio/sysaudio/dispatcher.c
5  * PURPOSE: System Audio graph builder
6  * PROGRAMMER: Johannes Anderwald
7  */
8 
9 #include "sysaudio.h"
10 
11 #define NDEBUG
12 #include <debug.h>
13 
15 NTAPI
18  PIRP Irp)
19 {
20  PIO_STACK_LOCATION IoStack;
21 
23  if (IoStack->Parameters.DeviceIoControl.IoControlCode == IOCTL_KS_PROPERTY)
24  {
26  }
27 
28  /* unsupported request */
29  Irp->IoStatus.Status = STATUS_UNSUCCESSFUL;
30  Irp->IoStatus.Information = 0;
32  return STATUS_UNSUCCESSFUL;
33 }
34 
36 NTAPI
39  PIRP Irp)
40 {
41  DPRINT("Dispatch_fnClose called DeviceObject %p Irp %p\n", DeviceObject);
42 
43  Irp->IoStatus.Status = STATUS_SUCCESS;
44  Irp->IoStatus.Information = 0;
46  return STATUS_SUCCESS;
47 }
48 
49 static KSDISPATCH_TABLE DispatchTable =
50 {
60  KsDispatchFastWriteFailure,
61 };
62 
64 NTAPI
67  IN PIRP Irp)
68 {
70  KSOBJECT_HEADER ObjectHeader;
71  PKSOBJECT_CREATE_ITEM CreateItem;
72 
73  DPRINT("DispatchCreateSysAudio entered\n");
74 
75  /* allocate create item */
76  CreateItem = AllocateItem(NonPagedPool, sizeof(KSOBJECT_CREATE_ITEM));
77  if (!CreateItem)
78  {
79  Irp->IoStatus.Information = 0;
80  Irp->IoStatus.Status = STATUS_INSUFFICIENT_RESOURCES;
83  }
84 
85  /* zero create struct */
86  RtlZeroMemory(CreateItem, sizeof(KSOBJECT_CREATE_ITEM));
87 
88  /* setup create context */
89  CreateItem->Create = DispatchCreateSysAudioPin;
90  RtlInitUnicodeString(&CreateItem->ObjectClass, KSSTRING_Pin);
91 
92  /* allocate object header */
93  Status = KsAllocateObjectHeader(&ObjectHeader, 1, CreateItem, Irp, &DispatchTable);
94 
95  DPRINT("KsAllocateObjectHeader result %x\n", Status);
96  /* complete the irp */
97  Irp->IoStatus.Information = 0;
98  Irp->IoStatus.Status = Status;
100  return Status;
101 }
102 
103 NTSTATUS
105  IN SYSAUDIODEVEXT *DeviceExtension)
106 {
108  PKSOBJECT_CREATE_ITEM CreateItem;
109 
110  /* allocate create item */
111  CreateItem = AllocateItem(NonPagedPool, sizeof(KSOBJECT_CREATE_ITEM));
112  if (!CreateItem)
114 
115  /* initialize create item struct */
116  RtlZeroMemory(CreateItem, sizeof(KSOBJECT_CREATE_ITEM));
117  CreateItem->Create = DispatchCreateSysAudio;
118 
119  /* FIXME Sysaudio doesnt need a named create item because it installs itself
120  * via the device interface
121  */
122  RtlInitUnicodeString(&CreateItem->ObjectClass, L"GLOBAL");
123  CreateItem->Flags = KSCREATE_ITEM_WILDCARD;
124 
125  Status = KsAllocateDeviceHeader(&DeviceExtension->KsDeviceHeader,
126  1,
127  CreateItem);
128  return Status;
129 }
130 
131 NTSTATUS
133  IN SYSAUDIODEVEXT *DeviceExtension)
134 {
136  UNICODE_STRING DeviceInstanceName = RTL_CONSTANT_STRING(L"\\Device\\kmixer\\GLOBAL");
137  UNICODE_STRING DevicePath = RTL_CONSTANT_STRING(L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\kmixer");
138 
139  Status = ZwLoadDriver(&DevicePath);
140 
141  if (NT_SUCCESS(Status))
142  {
143  Status = OpenDevice(&DeviceInstanceName, &DeviceExtension->KMixerHandle, &DeviceExtension->KMixerFileObject);
144  if (!NT_SUCCESS(Status))
145  {
146  DeviceExtension->KMixerHandle = NULL;
147  DeviceExtension->KMixerFileObject = NULL;
148  }
149  }
150 
151  DPRINT("Status %lx KMixerHandle %p KMixerFileObject %p\n", Status, DeviceExtension->KMixerHandle, DeviceExtension->KMixerFileObject);
152  return STATUS_SUCCESS;
153 }
#define IOCTL_KS_PROPERTY
Definition: ks.h:127
#define IN
Definition: typedefs.h:38
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
NTSTATUS SysAudioOpenKMixer(IN SYSAUDIODEVEXT *DeviceExtension)
Definition: dispatcher.c:132
KSDDKAPI NTSTATUS NTAPI KsAllocateDeviceHeader(OUT KSDEVICE_HEADER *OutHeader, IN ULONG ItemsCount, IN PKSOBJECT_CREATE_ITEM ItemsList OPTIONAL)
Definition: api.c:522
_In_ PIRP Irp
Definition: csq.h:116
PVOID AllocateItem(IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes)
Definition: misc.c:30
#define KSSTRING_Pin
Definition: ks.h:48
LONG NTSTATUS
Definition: precomp.h:26
KSDDKAPI BOOLEAN NTAPI KsDispatchFastIoDeviceControlFailure(IN PFILE_OBJECT FileObject, IN BOOLEAN Wait, IN PVOID InputBuffer OPTIONAL, IN ULONG InputBufferLength, OUT PVOID OutputBuffer OPTIONAL, IN ULONG OutputBufferLength, IN ULONG IoControlCode, OUT PIO_STATUS_BLOCK IoStatus, IN PDEVICE_OBJECT DeviceObject)
Definition: irp.c:1218
NTSTATUS SysAudioAllocateDeviceHeader(IN SYSAUDIODEVEXT *DeviceExtension)
Definition: dispatcher.c:104
MMRESULT OpenDevice(DeviceInfo **private_data, MIDIOPENDESC *open_desc, DWORD flags)
Definition: beepmidi.c:264
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
NTSTATUS NTAPI DispatchCreateSysAudioPin(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: pin.c:431
smooth NULL
Definition: ftsmooth.c:416
#define IoCompleteRequest
Definition: irp.c:1240
void DPRINT(...)
Definition: polytest.cpp:61
KSDDKAPI NTSTATUS NTAPI KsDispatchInvalidDeviceRequest(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1156
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSTATUS SysAudioHandleProperty(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: control.c:288
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
static KSDISPATCH_TABLE DispatchTable
Definition: dispatcher.c:49
static const WCHAR L[]
Definition: oid.c:1250
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
NTSTATUS NTAPI DispatchCreateSysAudio(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: dispatcher.c:65
KSDDKAPI BOOLEAN NTAPI KsDispatchFastReadFailure(IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN BOOLEAN Wait, IN ULONG LockKey, OUT PVOID Buffer, OUT PIO_STATUS_BLOCK IoStatus, IN PDEVICE_OBJECT DeviceObject)
Definition: irp.c:1238
NTSTATUS NTAPI Dispatch_fnDeviceIoControl(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: dispatcher.c:16
KSDDKAPI NTSTATUS NTAPI KsAllocateObjectHeader(OUT KSOBJECT_HEADER *Header, IN ULONG ItemsCount, IN PKSOBJECT_CREATE_ITEM ItemsList OPTIONAL, IN PIRP Irp, IN KSDISPATCH_TABLE *Table)
Definition: api.c:610
#define IO_NO_INCREMENT
Definition: iotypes.h:566
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
NTSTATUS NTAPI Dispatch_fnClose(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: dispatcher.c:37
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2772
return STATUS_SUCCESS
Definition: btrfs.c:2938
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14