2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS Kernel Streaming
4 * FILE: drivers/wdm/audio/sysaudio/deviface.c
5 * PURPOSE: System Audio graph builder
6 * PROGRAMMER: Johannes Anderwald
13 Pin_fnDeviceIoControl(
14 PDEVICE_OBJECT DeviceObject
,
17 PDISPATCH_CONTEXT Context
;
20 PIO_STACK_LOCATION IoStack
;
22 DPRINT("Pin_fnDeviceIoControl called DeviceObject %p Irp %p\n", DeviceObject
);
24 /* Get current stack location */
25 IoStack
= IoGetCurrentIrpStackLocation(Irp
);
27 /* The dispatch context is stored in the FsContext2 member */
28 Context
= (PDISPATCH_CONTEXT
)IoStack
->FileObject
->FsContext2
;
32 ASSERT(Context
->FileObject
!= NULL
);
34 /* Re-dispatch the request to the real target pin */
35 Status
= KsSynchronousIoControlDevice(Context
->FileObject
, KernelMode
, IoStack
->Parameters
.DeviceIoControl
.IoControlCode
,
36 IoStack
->Parameters
.DeviceIoControl
.Type3InputBuffer
,
37 IoStack
->Parameters
.DeviceIoControl
.InputBufferLength
,
39 IoStack
->Parameters
.DeviceIoControl
.OutputBufferLength
,
42 /* Save status and information */
43 Irp
->IoStatus
.Information
= BytesReturned
;
44 Irp
->IoStatus
.Status
= Status
;
45 /* Complete the irp */
46 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
54 PDEVICE_OBJECT DeviceObject
,
57 PDISPATCH_CONTEXT Context
;
58 PIO_STACK_LOCATION IoStack
;
62 /* Get current stack location */
63 IoStack
= IoGetCurrentIrpStackLocation(Irp
);
65 /* The dispatch context is stored in the FsContext2 member */
66 Context
= (PDISPATCH_CONTEXT
)IoStack
->FileObject
->FsContext2
;
70 ASSERT(Context
->FileObject
!= NULL
);
72 /* Re-dispatch the request to the real target pin */
73 Status
= KsSynchronousIoControlDevice(Context
->FileObject
, KernelMode
, IOCTL_KS_READ_STREAM
,
74 MmGetMdlVirtualAddress(Irp
->MdlAddress
),
75 IoStack
->Parameters
.Read
.Length
,
80 if (Context
->hMixerPin
&& Context
->MixerFileObject
)
83 // call kmixer to convert stream
87 /* Save status and information */
88 Irp
->IoStatus
.Status
= Status
;
89 Irp
->IoStatus
.Information
= 0;
90 /* Complete the irp */
91 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
99 PDEVICE_OBJECT DeviceObject
,
102 PDISPATCH_CONTEXT Context
;
103 PIO_STACK_LOCATION IoStack
;
107 /* Get current stack location */
108 IoStack
= IoGetCurrentIrpStackLocation(Irp
);
110 /* The dispatch context is stored in the FsContext2 member */
111 Context
= (PDISPATCH_CONTEXT
)IoStack
->FileObject
->FsContext2
;
115 ASSERT(Context
->FileObject
!= NULL
);
117 if (Context
->hMixerPin
&& Context
->MixerFileObject
)
120 // call kmixer to convert stream
125 /* Re-dispatch the request to the real target pin */
126 Status
= KsSynchronousIoControlDevice(Context
->FileObject
, KernelMode
, IOCTL_KS_WRITE_STREAM
,
127 MmGetMdlVirtualAddress(Irp
->MdlAddress
),
128 IoStack
->Parameters
.Read
.Length
,
133 /* Save status and information */
134 Irp
->IoStatus
.Status
= Status
;
135 Irp
->IoStatus
.Information
= 0;
136 /* Complete the irp */
137 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
145 PDEVICE_OBJECT DeviceObject
,
148 PDISPATCH_CONTEXT Context
;
149 PIO_STACK_LOCATION IoStack
;
150 PDEVICE_OBJECT PinDeviceObject
;
152 IO_STATUS_BLOCK IoStatus
;
154 NTSTATUS Status
= STATUS_UNSUCCESSFUL
;
156 /* Get current stack location */
157 IoStack
= IoGetCurrentIrpStackLocation(Irp
);
159 /* The dispatch context is stored in the FsContext2 member */
160 Context
= (PDISPATCH_CONTEXT
)IoStack
->FileObject
->FsContext2
;
164 ASSERT(Context
->FileObject
!= NULL
);
166 /* Get Pin's device object */
167 PinDeviceObject
= IoGetRelatedDeviceObject(Context
->FileObject
);
169 /* Initialize notification event */
170 KeInitializeEvent(&Event
, NotificationEvent
, FALSE
);
172 /* build target irp */
173 PinIrp
= IoBuildSynchronousFsdRequest(IRP_MJ_FLUSH_BUFFERS
, PinDeviceObject
, NULL
, 0, NULL
, &Event
, &IoStatus
);
177 /* Get the next stack location */
178 IoStack
= IoGetNextIrpStackLocation(PinIrp
);
179 /* The file object must be present in the irp as it contains the KSOBJECT_HEADER */
180 IoStack
->FileObject
= Context
->FileObject
;
182 /* call the driver */
183 Status
= IoCallDriver(PinDeviceObject
, PinIrp
);
184 /* Has request already completed ? */
185 if (Status
== STATUS_PENDING
)
187 /* Wait untill the request has completed */
188 KeWaitForSingleObject(&Event
, UserRequest
, KernelMode
, FALSE
, NULL
);
190 Status
= IoStatus
.Status
;
195 Irp
->IoStatus
.Status
= Status
;
196 Irp
->IoStatus
.Information
= 0;
197 /* Complete the irp */
198 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
206 PDEVICE_OBJECT DeviceObject
,
209 DPRINT1("Pin_fnClose called DeviceObject %p Irp %p\n", DeviceObject
);
211 Irp
->IoStatus
.Status
= STATUS_SUCCESS
;
212 Irp
->IoStatus
.Information
= 0;
213 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
214 return STATUS_SUCCESS
;
220 PDEVICE_OBJECT DeviceObject
,
223 DPRINT1("Pin_fnQuerySecurity called DeviceObject %p Irp %p\n", DeviceObject
);
225 Irp
->IoStatus
.Status
= STATUS_UNSUCCESSFUL
;
226 Irp
->IoStatus
.Information
= 0;
227 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
228 return STATUS_UNSUCCESSFUL
;
234 PDEVICE_OBJECT DeviceObject
,
238 DPRINT1("Pin_fnSetSecurity called DeviceObject %p Irp %p\n", DeviceObject
);
240 Irp
->IoStatus
.Status
= STATUS_UNSUCCESSFUL
;
241 Irp
->IoStatus
.Information
= 0;
242 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
243 return STATUS_UNSUCCESSFUL
;
248 Pin_fnFastDeviceIoControl(
249 PFILE_OBJECT FileObject
,
252 ULONG InputBufferLength
,
254 ULONG OutputBufferLength
,
256 PIO_STATUS_BLOCK IoStatus
,
257 PDEVICE_OBJECT DeviceObject
)
259 DPRINT1("Pin_fnFastDeviceIoControl called DeviceObject %p Irp %p\n", DeviceObject
);
269 PFILE_OBJECT FileObject
,
270 PLARGE_INTEGER FileOffset
,
275 PIO_STATUS_BLOCK IoStatus
,
276 PDEVICE_OBJECT DeviceObject
)
278 DPRINT1("Pin_fnFastRead called DeviceObject %p Irp %p\n", DeviceObject
);
287 PFILE_OBJECT FileObject
,
288 PLARGE_INTEGER FileOffset
,
293 PIO_STATUS_BLOCK IoStatus
,
294 PDEVICE_OBJECT DeviceObject
)
296 PDISPATCH_CONTEXT Context
;
299 //DPRINT1("Pin_fnFastWrite called DeviceObject %p Irp %p\n", DeviceObject);
301 Context
= (PDISPATCH_CONTEXT
)FileObject
->FsContext2
;
303 if (Context
->hMixerPin
&& Context
->MixerFileObject
)
305 Status
= KsStreamIo(Context
->MixerFileObject
, NULL
, NULL
, NULL
, NULL
, 0, IoStatus
, Buffer
, Length
, KSSTREAM_WRITE
, KernelMode
);
306 if (!NT_SUCCESS(Status
))
308 DPRINT1("Mixing stream failed with %lx\n", Status
);
313 Status
= KsStreamIo(Context
->FileObject
, NULL
, NULL
, NULL
, NULL
, 0, IoStatus
, Buffer
, Length
, KSSTREAM_WRITE
, KernelMode
);
314 if (Status
== STATUS_SUCCESS
)
320 static KSDISPATCH_TABLE PinTable
=
322 Pin_fnDeviceIoControl
,
329 Pin_fnFastDeviceIoControl
,
339 KSOBJECT_HEADER ObjectHeader
;
341 /* allocate object header */
342 Status
= KsAllocateObjectHeader(&ObjectHeader
, 0, NULL
, Irp
, &PinTable
);