ReactOS 0.4.16-dev-336-gb667d82
filter_dmus.cpp
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/backpln/portcls/filter_dmus.cpp
5 * PURPOSE: portcls wave pci filter
6 * PROGRAMMER: Johannes Anderwald
7 */
8
9#include "private.hpp"
10
11#define NDEBUG
12#include <debug.h>
13
14class CPortFilterDMus : public CUnknownImpl<IPortFilterDMus>
15{
16public:
18
20 CPortFilterDMus(IUnknown *OuterUnknown){}
21 virtual ~CPortFilterDMus(){}
22
23protected:
24 IPortDMus* m_Port;
25 IPortPinDMus ** m_Pins;
27};
28
32 IN REFIID refiid,
34{
35
36 if (IsEqualGUIDAligned(refiid, IID_IIrpTarget) ||
38 {
39 *Output = PVOID(PUNKNOWN(this));
40 PUNKNOWN(*Output)->AddRef();
41 return STATUS_SUCCESS;
42 }
43 else if (IsEqualGUIDAligned(refiid, IID_IPort))
44 {
46 PUNKNOWN(*Output)->AddRef();
47 return STATUS_SUCCESS;
48 }
49
51}
52
55CPortFilterDMus::NewIrpTarget(
56 OUT struct IIrpTarget **OutTarget,
61 IN PIRP Irp,
62 IN KSOBJECT_CREATE *CreateObject)
63{
65 IPortPinDMus * Pin;
66 PKSPIN_CONNECT ConnectDetails;
67
71
72 DPRINT("CPortFilterDMus::NewIrpTarget entered\n");
73
74 // let's verify the connection request
76 if (!NT_SUCCESS(Status))
77 {
79 }
80
81 if (m_Pins[ConnectDetails->PinId] && m_Descriptor->Factory.Instances[ConnectDetails->PinId].CurrentPinInstanceCount)
82 {
83 // release existing instance
84 PC_ASSERT(0);
85 }
86
87 // now create the pin
89 if (!NT_SUCCESS(Status))
90 {
91 return Status;
92 }
93
94 // initialize the pin
95 Status = Pin->Init(m_Port, this, ConnectDetails, &m_Descriptor->Factory.KsPinDescriptor[ConnectDetails->PinId], DeviceObject);
96 if (!NT_SUCCESS(Status))
97 {
98 Pin->Release();
99 return Status;
100 }
101
102 // store pin
103 m_Pins[ConnectDetails->PinId] = Pin;
104
105 // store result
106 *OutTarget = (IIrpTarget*)Pin;
107
108 // increment current instance count
110
111 return Status;
112}
113
115NTAPI
116CPortFilterDMus::DeviceIoControl(
118 IN PIRP Irp)
119{
120 PIO_STACK_LOCATION IoStack;
122
124
125 if (IoStack->Parameters.DeviceIoControl.IoControlCode != IOCTL_KS_PROPERTY)
126 {
127 DPRINT("Unhandled function %lx Length %x\n", IoStack->Parameters.DeviceIoControl.IoControlCode, IoStack->Parameters.DeviceIoControl.InputBufferLength);
128
129 Irp->IoStatus.Status = STATUS_SUCCESS;
130
132 return STATUS_SUCCESS;
133 }
134
136 if (Status != STATUS_PENDING)
137 {
138 Irp->IoStatus.Status = Status;
139 DPRINT("Result %x Length %u\n", Status, Irp->IoStatus.Information);
141 }
142 return Status;
143}
144
146NTAPI
147CPortFilterDMus::Read(
149 IN PIRP Irp)
150{
152}
153
155NTAPI
156CPortFilterDMus::Write(
158 IN PIRP Irp)
159{
161}
162
164NTAPI
165CPortFilterDMus::Flush(
167 IN PIRP Irp)
168{
170}
171
173NTAPI
174CPortFilterDMus::Close(
176 IN PIRP Irp)
177{
178 Irp->IoStatus.Status = STATUS_SUCCESS;
179 Irp->IoStatus.Information = 0;
181
182 return STATUS_UNSUCCESSFUL;
183}
184
186NTAPI
187CPortFilterDMus::QuerySecurity(
189 IN PIRP Irp)
190{
192}
193
195NTAPI
196CPortFilterDMus::SetSecurity(
198 IN PIRP Irp)
199{
201}
202
204NTAPI
205CPortFilterDMus::FastDeviceIoControl(
213 OUT PIO_STATUS_BLOCK StatusBlock,
215{
216 return FALSE;
217}
218
220NTAPI
221CPortFilterDMus::FastRead(
228 OUT PIO_STATUS_BLOCK StatusBlock,
230{
232 return FALSE;
233}
234
236NTAPI
237CPortFilterDMus::FastWrite(
244 OUT PIO_STATUS_BLOCK StatusBlock,
246{
248 return FALSE;
249}
250
252NTAPI
253CPortFilterDMus::Init(
254 IN IPortDMus* Port)
255{
256 ISubdevice * ISubDevice;
258
259 m_Port = Port;
260
261 // get our private interface
262 Status = m_Port->QueryInterface(IID_ISubdevice, (PVOID*)&ISubDevice);
263 if (!NT_SUCCESS(Status))
264 return STATUS_UNSUCCESSFUL;
265
266 // get the subdevice descriptor
267 Status = ISubDevice->GetDescriptor(&m_Descriptor);
268
269 // release subdevice interface
270 ISubDevice->Release();
271
272 if (!NT_SUCCESS(Status))
273 return STATUS_UNSUCCESSFUL;
274
275 // allocate pin array
276 m_Pins = (IPortPinDMus**)AllocateItem(NonPagedPool, m_Descriptor->Factory.PinDescriptorCount * sizeof(IPortPinDMus*), TAG_PORTCLASS);
277
278 if (!m_Pins)
279 return STATUS_UNSUCCESSFUL;
280
281 // increment reference count
282 Port->AddRef();
283
284 return STATUS_SUCCESS;
285}
286
288NTAPI
289CPortFilterDMus::FreePin(
290 IN struct IPortPinDMus* Pin)
291{
292 ULONG Index;
293
295 {
296 if (m_Pins[Index] == Pin)
297 {
298 m_Pins[Index]->Release();
299 m_Pins[Index] = NULL;
300 return STATUS_SUCCESS;
301 }
302 }
303 return STATUS_UNSUCCESSFUL;
304}
305
306VOID
307NTAPI
308CPortFilterDMus::NotifyPins()
309{
310 ULONG Index;
311
312 DPRINT("Notifying %u pins\n", m_Descriptor->Factory.PinDescriptorCount);
313
315 {
316 m_Pins[Index]->Notify();
317 }
318}
319
322 OUT PPORTFILTERDMUS * OutFilter)
323{
325
327 if (!This)
329
330 This->AddRef();
331
332 // return result
333 *OutFilter = (CPortFilterDMus*)This;
334
335 return STATUS_SUCCESS;
336}
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
unsigned char BOOLEAN
IPortFilterDMus * PPORTFILTERDMUS
Definition: interfaces.hpp:839
LONG NTSTATUS
Definition: precomp.h:26
#define STDMETHODIMP
Definition: basetyps.h:43
const GUID IID_IUnknown
#define UNIMPLEMENTED
Definition: ntoskrnl.c:15
_In_ PFCB _In_ LONGLONG FileOffset
Definition: cdprocs.h:160
Definition: bufpool.h:45
CPortFilterDMus(IUnknown *OuterUnknown)
Definition: filter_dmus.cpp:20
IPortDMus * m_Port
Definition: filter_dmus.cpp:24
STDMETHODIMP QueryInterface(REFIID InterfaceId, PVOID *Interface)
Definition: filter_dmus.cpp:31
IPortPinDMus ** m_Pins
Definition: filter_dmus.cpp:25
SUBDEVICE_DESCRIPTOR * m_Descriptor
Definition: filter_dmus.cpp:26
virtual ~CPortFilterDMus()
Definition: filter_dmus.cpp:21
IUnknown * PUNKNOWN
Definition: com_apitest.h:45
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_PENDING
Definition: d3dkmdt.h:43
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
KSDDKAPI NTSTATUS NTAPI KsDispatchInvalidDeviceRequest(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1189
#define NonPagedPool
Definition: env_spec_w32.h:307
IN PLARGE_INTEGER IN ULONG IN BOOLEAN IN ULONG LockKey
Definition: fatprocs.h:2666
IN PDCB IN VBO IN ULONG IN BOOLEAN Pin
Definition: fatprocs.h:428
NTSTATUS NewPortFilterDMus(OUT PPORTFILTERDMUS *OutFilter)
Status
Definition: gdiplustypes.h:25
CPPORT Port[4]
Definition: headless.c:35
@ Unknown
Definition: i8042prt.h:114
ULONG AddRef()
nsrefcnt Release()
#define IOCTL_KS_PROPERTY
Definition: ks.h:127
PVOID AllocateItem(IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes)
Definition: misc.c:29
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
#define IoCompleteRequest
Definition: irp.c:1240
NTSTATUS NewPortPinDMus(OUT IPortPinDMus **OutPin)
Definition: pin_dmus.cpp:606
NTSTATUS NTAPI PcValidateConnectRequest(IN PIRP Irp, IN KSPIN_FACTORY *Descriptor, OUT PKSPIN_CONNECT *Connect)
Definition: undoc.cpp:985
#define TAG_PORTCLASS
Definition: private.hpp:24
#define PC_ASSERT(exp)
Definition: private.hpp:26
NTSTATUS NTAPI PcHandlePropertyWithTable(IN PIRP Irp, IN ULONG PropertySetCount, IN PKSPROPERTY_SET PropertySet, IN PSUBDEVICE_DESCRIPTOR Descriptor)
Definition: undoc.cpp:78
#define REFIID
Definition: guiddef.h:118
@ Output
Definition: arc.h:85
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:73
ULONG PinId
Definition: ks.h:2603
PIN_INSTANCE_INFO * Instances
Definition: interfaces.hpp:201
ULONG PinDescriptorCount
Definition: interfaces.hpp:198
KSPIN_DESCRIPTOR * KsPinDescriptor
Definition: interfaces.hpp:200
ULONG CurrentPinInstanceCount
Definition: interfaces.hpp:191
PKSPROPERTY_SET FilterPropertySet
Definition: interfaces.hpp:210
KSPIN_FACTORY Factory
Definition: interfaces.hpp:208
union _IO_STACK_LOCATION::@1581 Parameters
struct _IO_STACK_LOCATION::@1581::@1582 DeviceIoControl
const uint16_t * PCWSTR
Definition: typedefs.h:57
INT POOL_TYPE
Definition: typedefs.h:78
#define NTAPI
Definition: typedefs.h:36
void * PVOID
Definition: typedefs.h:50
#define IN
Definition: typedefs.h:39
uint32_t ULONG
Definition: typedefs.h:59
#define OUT
Definition: typedefs.h:40
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ WDFCOLLECTION _In_ ULONG Index
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ _Strict_type_match_ POOL_TYPE PoolType
Definition: wdfdevice.h:3815
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:550
_In_ WDFDPC _In_ BOOLEAN Wait
Definition: wdfdpc.h:170
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID _Out_ PINTERFACE Interface
Definition: wdffdo.h:465
_In_ WDFREQUEST _In_ size_t _In_ size_t _In_ ULONG IoControlCode
Definition: wdfio.h:325
_In_ WDFREQUEST _In_ size_t OutputBufferLength
Definition: wdfio.h:320
_In_ WDFREQUEST _In_ size_t _In_ size_t InputBufferLength
Definition: wdfio.h:322
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR OutputBuffer
Definition: wdfiotarget.h:863
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR InputBuffer
Definition: wdfiotarget.h:953
#define IsEqualGUIDAligned(guid1, guid2)
Definition: wdm.template.h:235
#define IO_NO_INCREMENT
Definition: iotypes.h:598
* PFILE_OBJECT
Definition: iotypes.h:1998