ReactOS  0.4.13-dev-464-g6b95727
filter_wavert.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_wavert.cpp
5  * PURPOSE: portcls wave RT filter
6  * PROGRAMMER: Johannes Anderwald
7  */
8 
9 #include "private.hpp"
10 
11 #ifndef YDEBUG
12 #define NDEBUG
13 #endif
14 
15 #include <debug.h>
16 
17 class CPortFilterWaveRT : public IPortFilterWaveRT
18 {
19 public:
21 
23  {
25  return m_Ref;
26  }
28  {
30 
31  if (!m_Ref)
32  {
33  delete this;
34  return 0;
35  }
36  return m_Ref;
37  }
39  CPortFilterWaveRT(IUnknown *OuterUnknown){}
40  virtual ~CPortFilterWaveRT(){}
41 
42 protected:
43 
44 
45  IPortWaveRT* m_Port;
46  IPortPinWaveRT ** m_Pins;
49 };
50 
52 NTAPI
54  IN REFIID refiid,
55  OUT PVOID* Output)
56 {
57  if (IsEqualGUIDAligned(refiid, IID_IIrpTarget) ||
59  {
60  *Output = PVOID(PUNKNOWN(this));
61  PUNKNOWN(*Output)->AddRef();
62  return STATUS_SUCCESS;
63  }
64  else if (IsEqualGUIDAligned(refiid, IID_IPort))
65  {
67  PUNKNOWN(*Output)->AddRef();
68  return STATUS_SUCCESS;
69  }
70 
71  return STATUS_UNSUCCESSFUL;
72 }
73 
75 NTAPI
76 CPortFilterWaveRT::NewIrpTarget(
77  OUT struct IIrpTarget **OutTarget,
78  IN PCWSTR Name,
82  IN PIRP Irp,
83  IN KSOBJECT_CREATE *CreateObject)
84 {
86  IPortPinWaveRT * Pin;
87  PKSPIN_CONNECT ConnectDetails;
88 
89 #if 0
90  ASSERT(m_Port);
92  ASSERT(m_Pins);
93 #endif
94 
95  DPRINT("CPortFilterWaveRT::NewIrpTarget entered\n");
96 
97  // let's verify the connection request
99  if (!NT_SUCCESS(Status))
100  {
101  return STATUS_UNSUCCESSFUL;
102  }
103 
104  if (m_Pins[ConnectDetails->PinId] && m_Descriptor->Factory.Instances[ConnectDetails->PinId].CurrentPinInstanceCount)
105  {
106  // release existing instance
107  PC_ASSERT(0);
108  m_Pins[ConnectDetails->PinId]->Close(DeviceObject, NULL);
109  }
110 
111  // now create the pin
113  if (!NT_SUCCESS(Status))
114  {
115  return Status;
116  }
117 
118  // initialize the pin
119  Status = Pin->Init(m_Port, this, ConnectDetails, &m_Descriptor->Factory.KsPinDescriptor[ConnectDetails->PinId], GetDeviceObjectFromPortWaveRT(m_Port));
120  if (!NT_SUCCESS(Status))
121  {
122  Pin->Release();
123  return Status;
124  }
125 
126  // release existing pin
127  if (m_Pins[ConnectDetails->PinId])
128  {
129  m_Pins[ConnectDetails->PinId]->Release();
130  }
131  // store pin
132  m_Pins[ConnectDetails->PinId] = Pin;
133 
134  // store result
135  *OutTarget = (IIrpTarget*)Pin;
136 
137  // increment current instance count
139 
140  return Status;
141 }
142 
143 NTSTATUS
144 NTAPI
147  IN PIRP Irp)
148 {
149  PIO_STACK_LOCATION IoStack;
151 
153 
154  if (IoStack->Parameters.DeviceIoControl.IoControlCode != IOCTL_KS_PROPERTY)
155  {
156  DPRINT("Unhandled function %lx Length %x\n", IoStack->Parameters.DeviceIoControl.IoControlCode, IoStack->Parameters.DeviceIoControl.InputBufferLength);
157 
158  Irp->IoStatus.Status = STATUS_SUCCESS;
159 
161  return STATUS_SUCCESS;
162  }
163 
165  if (Status != STATUS_PENDING)
166  {
167  Irp->IoStatus.Status = Status;
168  DPRINT("Result %x Length %u\n", Status, Irp->IoStatus.Information);
170  }
171  return Status;
172 }
173 
174 NTSTATUS
175 NTAPI
178  IN PIRP Irp)
179 {
181 }
182 
183 NTSTATUS
184 NTAPI
187  IN PIRP Irp)
188 {
190 }
191 
192 NTSTATUS
193 NTAPI
196  IN PIRP Irp)
197 {
199 }
200 
201 NTSTATUS
202 NTAPI
205  IN PIRP Irp)
206 {
207  Irp->IoStatus.Status = STATUS_SUCCESS;
208  Irp->IoStatus.Information = 0;
210 
211  return STATUS_UNSUCCESSFUL;
212 }
213 
214 NTSTATUS
215 NTAPI
216 CPortFilterWaveRT::QuerySecurity(
218  IN PIRP Irp)
219 {
221 }
222 
223 NTSTATUS
224 NTAPI
225 CPortFilterWaveRT::SetSecurity(
227  IN PIRP Irp)
228 {
230 }
231 
232 BOOLEAN
233 NTAPI
234 CPortFilterWaveRT::FastDeviceIoControl(
236  IN BOOLEAN Wait,
242  OUT PIO_STATUS_BLOCK StatusBlock,
244 {
245  return FALSE;
246 }
247 
248 BOOLEAN
249 NTAPI
250 CPortFilterWaveRT::FastRead(
253  IN ULONG Length,
254  IN BOOLEAN Wait,
255  IN ULONG LockKey,
256  IN PVOID Buffer,
257  OUT PIO_STATUS_BLOCK StatusBlock,
259 {
260  return FALSE;
261 }
262 
263 BOOLEAN
264 NTAPI
265 CPortFilterWaveRT::FastWrite(
266 
269  IN ULONG Length,
270  IN BOOLEAN Wait,
271  IN ULONG LockKey,
272  IN PVOID Buffer,
273  OUT PIO_STATUS_BLOCK StatusBlock,
275 {
276  return FALSE;
277 }
278 
279 NTSTATUS
280 NTAPI
282  IN IPortWaveRT* Port)
283 {
284  ISubdevice * ISubDevice;
287 
288  m_Port = Port;
289 
290  // get our private interface
291  Status = m_Port->QueryInterface(IID_ISubdevice, (PVOID*)&ISubDevice);
292  if (!NT_SUCCESS(Status))
293  return STATUS_UNSUCCESSFUL;
294 
295  // get the subdevice descriptor
296  Status = ISubDevice->GetDescriptor(&Descriptor);
297 
298  // release subdevice interface
299  ISubDevice->Release();
300 
301  if (!NT_SUCCESS(Status))
302  return STATUS_UNSUCCESSFUL;
303 
304  // save descriptor
306 
307  // allocate pin array
308  m_Pins = (IPortPinWaveRT**)AllocateItem(NonPagedPool, Descriptor->Factory.PinDescriptorCount * sizeof(IPortPinWaveRT*), TAG_PORTCLASS);
309 
310  if (!m_Pins)
311  return STATUS_UNSUCCESSFUL;
312 
313  // increment reference count
314  Port->AddRef();
315 
316  return STATUS_SUCCESS;
317 }
318 
319 NTSTATUS
321  OUT IPortFilterWaveRT ** OutFilter)
322 {
324 
326  if (!This)
328 
329  This->AddRef();
330 
331  // return result
332  *OutFilter = (CPortFilterWaveRT*)This;
333 
334  return STATUS_SUCCESS;
335 }
CPPORT Port[4]
Definition: headless.c:34
#define IOCTL_KS_PROPERTY
Definition: ks.h:150
IPortWaveRT * m_Port
const uint16_t * PCWSTR
Definition: typedefs.h:55
#define IN
Definition: typedefs.h:38
_In_ BOOLEAN Read
Definition: strmini.h:479
NTSTATUS NTAPI PcHandlePropertyWithTable(IN PIRP Irp, IN ULONG PropertySetCount, IN PKSPROPERTY_SET PropertySet, IN PSUBDEVICE_DESCRIPTOR Descriptor)
Definition: undoc.cpp:81
#define REFIID
Definition: guiddef.h:113
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define PC_ASSERT(exp)
Definition: usbehci.h:17
_Must_inspect_result_ _In_ PFILE_OBJECT _In_ ULONG IoControlCode
Definition: fltkernel.h:1383
_In_ BOOLEAN Release
Definition: classpnp.h:929
_In_ PIRP Irp
Definition: csq.h:116
IUnknown * PUNKNOWN
Definition: com_apitest.h:45
#define TAG_PORTCLASS
Definition: private.hpp:24
PVOID AllocateItem(IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes)
Definition: misc.c:30
LONG NTSTATUS
Definition: precomp.h:26
_Must_inspect_result_ _In_ PFILE_OBJECT _In_ ULONG _In_ ULONG _In_ ULONG OutputBufferLength
Definition: fltkernel.h:1374
BOOL Init(PUSERCONNECT UserCon)
Definition: dllmain.c:367
static BOOL Write(PBYTE Address, PBYTE Data, SIZE_T Size)
Definition: vmhorizon.c:15
CHAR InputBuffer[80]
Definition: conmgr.c:33
STDMETHODIMP_(ULONG) Release()
#define IsEqualGUIDAligned(guid1, guid2)
Definition: wdm.template.h:233
ULONG PinId
Definition: ks.h:2632
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
ULONG CurrentPinInstanceCount
Definition: interfaces.hpp:191
long LONG
Definition: pedump.c:60
IPortPinWaveRT ** m_Pins
NTSTATUS NewPortFilterWaveRT(OUT IPortFilterWaveRT **OutFilter)
#define STDMETHODIMP
Definition: basetyps.h:43
KSPIN_FACTORY Factory
Definition: interfaces.hpp:208
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
#define IoCompleteRequest
Definition: irp.c:1240
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
_Must_inspect_result_ __drv_aliasesMem _In_ PDEVICE_OBJECT _In_opt_ PVOID _In_ ULONG _Out_opt_ PVOID OutputBuffer
Definition: iofuncs.h:713
void * PVOID
Definition: retypes.h:9
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
SUBDEVICE_DESCRIPTOR * m_Descriptor
IN PLARGE_INTEGER IN ULONG IN BOOLEAN IN ULONG LockKey
Definition: fatprocs.h:2650
IN PVOID IN PVOID IN USHORT IN USHORT IN PINTERFACE Interface
Definition: pci.h:359
KSDDKAPI NTSTATUS NTAPI KsDispatchInvalidDeviceRequest(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1156
IN PDCB IN VBO IN ULONG IN BOOLEAN Pin
Definition: fatprocs.h:415
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_PENDING
Definition: ntstatus.h:82
INT POOL_TYPE
Definition: typedefs.h:76
const GUID IID_IUnknown
nsrefcnt Release()
CPortFilterWaveRT(IUnknown *OuterUnknown)
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
* PFILE_OBJECT
Definition: iotypes.h:1954
ULONG AddRef()
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define InterlockedDecrement
Definition: armddk.h:52
Definition: arc.h:85
NTSTATUS NewPortPinWaveRT(OUT IPortPinWaveRT **OutPin)
Definition: pin_wavert.cpp:686
_Must_inspect_result_ _In_ PFILE_OBJECT _In_ ULONG _In_ ULONG InputBufferLength
Definition: fltkernel.h:1372
PDEVICE_OBJECT GetDeviceObjectFromPortWaveRT(PPORTWAVERT iface)
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
BOOL WINAPI DeviceIoControl(IN HANDLE hDevice, IN DWORD dwIoControlCode, IN LPVOID lpInBuffer OPTIONAL, IN DWORD nInBufferSize OPTIONAL, OUT LPVOID lpOutBuffer OPTIONAL, IN DWORD nOutBufferSize OPTIONAL, OUT LPDWORD lpBytesReturned OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: deviceio.c:136
#define InterlockedIncrement
Definition: armddk.h:53
NTSTATUS NTAPI PcValidateConnectRequest(IN PIRP Irp, IN KSPIN_FACTORY *Descriptor, OUT PKSPIN_CONNECT *Connect)
Definition: undoc.cpp:998
Definition: sacdrv.h:267
_In_ PFCB _In_ LONGLONG FileOffset
Definition: cdprocs.h:151
static ULONG WINAPI AddRef(IStream *iface)
Definition: clist.c:90
STDMETHODIMP_(ULONG) AddRef()
PIN_INSTANCE_INFO * Instances
Definition: interfaces.hpp:201
#define OUT
Definition: typedefs.h:39
unsigned int ULONG
Definition: retypes.h:1
#define IO_NO_INCREMENT
Definition: iotypes.h:565
PKSPROPERTY_SET FilterPropertySet
Definition: interfaces.hpp:210
virtual ~CPortFilterWaveRT()
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2771
return STATUS_SUCCESS
Definition: btrfs.c:2777
_Must_inspect_result_ _In_ FLT_CONTEXT_TYPE _In_ SIZE_T _In_ POOL_TYPE PoolType
Definition: fltkernel.h:1444
STDMETHODIMP QueryInterface(REFIID InterfaceId, PVOID *Interface)
KSPIN_DESCRIPTOR * KsPinDescriptor
Definition: interfaces.hpp:200
IN BOOLEAN Wait
Definition: fatprocs.h:1529
_In_ PSTORAGE_PROPERTY_ID _Outptr_ PSTORAGE_DESCRIPTOR_HEADER * Descriptor
Definition: classpnp.h:966