ReactOS  0.4.14-dev-77-gd9e7c48
filter_wavepci.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_wavepci.cpp
5  * PURPOSE: portcls wave pci 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 CPortFilterWavePci : public IPortFilterWavePci
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  CPortFilterWavePci(IUnknown *OuterUnknown){}
40  virtual ~CPortFilterWavePci(){}
41 
42 protected:
43  IPortWavePci* m_Port;
44  IPortPinWavePci ** m_Pins;
46 
48 };
49 
51 NTAPI
53 
54  IN REFIID refiid,
55  OUT PVOID* Output)
56 {
57 
58  if (IsEqualGUIDAligned(refiid, IID_IIrpTarget) ||
60  {
61  *Output = PVOID(PUNKNOWN(this));
62  PUNKNOWN(*Output)->AddRef();
63  return STATUS_SUCCESS;
64  }
65  else if (IsEqualGUIDAligned(refiid, IID_IPort))
66  {
68  PUNKNOWN(*Output)->AddRef();
69  return STATUS_SUCCESS;
70  }
71 
72  return STATUS_UNSUCCESSFUL;
73 }
74 
76 NTAPI
77 CPortFilterWavePci::NewIrpTarget(
78  OUT struct IIrpTarget **OutTarget,
79  IN PCWSTR Name,
83  IN PIRP Irp,
84  IN KSOBJECT_CREATE *CreateObject)
85 {
87  IPortPinWavePci * Pin;
88  PKSPIN_CONNECT ConnectDetails;
89 
90 #if 0
91  ASSERT(m_Port);
93  ASSERT(m_Pins);
94 #endif
95 
96  DPRINT("CPortFilterWavePci::NewIrpTarget entered\n");
97 
98  // let's verify the connection request
100  if (!NT_SUCCESS(Status))
101  {
102  return STATUS_UNSUCCESSFUL;
103  }
104 
105  if (m_Pins[ConnectDetails->PinId] &&
107  {
108  // no available instance
109  return STATUS_UNSUCCESSFUL;
110  }
111 
112 
113  // now create the pin
115  if (!NT_SUCCESS(Status))
116  {
117  return Status;
118  }
119 
120  // initialize the pin
121  Status = Pin->Init(m_Port, this, ConnectDetails, &m_Descriptor->Factory.KsPinDescriptor[ConnectDetails->PinId], GetDeviceObjectFromPortWavePci(m_Port));
122  if (!NT_SUCCESS(Status))
123  {
124  Pin->Release();
125  return Status;
126  }
127 
128  // store pin
129  m_Pins[ConnectDetails->PinId] = Pin;
130 
131  // store result
132  *OutTarget = (IIrpTarget*)Pin;
133 
134  // increment current instance count
136 
137  return Status;
138 }
139 
140 NTSTATUS
141 NTAPI
144  IN PIRP Irp)
145 {
146  PIO_STACK_LOCATION IoStack;
148 
150 
151  if (IoStack->Parameters.DeviceIoControl.IoControlCode != IOCTL_KS_PROPERTY)
152  {
153  DPRINT("Unhandled function %lx Length %x\n", IoStack->Parameters.DeviceIoControl.IoControlCode, IoStack->Parameters.DeviceIoControl.InputBufferLength);
154 
155  Irp->IoStatus.Status = STATUS_SUCCESS;
156 
158  return STATUS_SUCCESS;
159  }
160 
162  if (Status != STATUS_PENDING)
163  {
164  Irp->IoStatus.Status = Status;
165  DPRINT("Result %x Length %u\n", Status, Irp->IoStatus.Information);
167  }
168  return Status;
169 }
170 
171 NTSTATUS
172 NTAPI
175  IN PIRP Irp)
176 {
178 }
179 
180 NTSTATUS
181 NTAPI
184  IN PIRP Irp)
185 {
187 }
188 
189 NTSTATUS
190 NTAPI
193  IN PIRP Irp)
194 {
196 }
197 
198 NTSTATUS
199 NTAPI
202  IN PIRP Irp)
203 {
204  Irp->IoStatus.Status = STATUS_SUCCESS;
205  Irp->IoStatus.Information = 0;
207 
208  return STATUS_UNSUCCESSFUL;
209 }
210 
211 NTSTATUS
212 NTAPI
213 CPortFilterWavePci::QuerySecurity(
215  IN PIRP Irp)
216 {
218 }
219 
220 NTSTATUS
221 NTAPI
222 CPortFilterWavePci::SetSecurity(
224  IN PIRP Irp)
225 {
227 }
228 
229 BOOLEAN
230 NTAPI
231 CPortFilterWavePci::FastDeviceIoControl(
233  IN BOOLEAN Wait,
239  OUT PIO_STATUS_BLOCK StatusBlock,
241 {
242  return FALSE;
243 }
244 
245 BOOLEAN
246 NTAPI
247 CPortFilterWavePci::FastRead(
250  IN ULONG Length,
251  IN BOOLEAN Wait,
252  IN ULONG LockKey,
253  IN PVOID Buffer,
254  OUT PIO_STATUS_BLOCK StatusBlock,
256 {
257  return FALSE;
258 }
259 
260 BOOLEAN
261 NTAPI
262 CPortFilterWavePci::FastWrite(
265  IN ULONG Length,
266  IN BOOLEAN Wait,
267  IN ULONG LockKey,
268  IN PVOID Buffer,
269  OUT PIO_STATUS_BLOCK StatusBlock,
271 {
272  return FALSE;
273 }
274 
275 NTSTATUS
276 NTAPI
278  IN IPortWavePci* Port)
279 {
280  ISubdevice * ISubDevice;
283 
284  m_Port = Port;
285 
286  // get our private interface
287  Status = m_Port->QueryInterface(IID_ISubdevice, (PVOID*)&ISubDevice);
288  if (!NT_SUCCESS(Status))
289  return STATUS_UNSUCCESSFUL;
290 
291  // get the subdevice descriptor
292  Status = ISubDevice->GetDescriptor(&Descriptor);
293 
294  // release subdevice interface
295  ISubDevice->Release();
296 
297  if (!NT_SUCCESS(Status))
298  return STATUS_UNSUCCESSFUL;
299 
300  // save descriptor
302 
303  // allocate pin array
304  m_Pins = (IPortPinWavePci**)AllocateItem(NonPagedPool, Descriptor->Factory.PinDescriptorCount * sizeof(IPortPinWavePci*), TAG_PORTCLASS);
305 
306  if (!m_Pins)
307  return STATUS_UNSUCCESSFUL;
308 
309  // increment reference count
310  Port->AddRef();
311 
312  return STATUS_SUCCESS;
313 }
314 
315 NTSTATUS
316 NTAPI
317 CPortFilterWavePci::FreePin(
318  IN struct IPortPinWavePci* Pin)
319 {
320  ULONG Index;
321 
323  {
324  if (m_Pins[Index] == Pin)
325  {
327  m_Pins[Index] = NULL;
328  return STATUS_SUCCESS;
329  }
330  }
331  return STATUS_UNSUCCESSFUL;
332 }
333 
334 
335 NTSTATUS
337  OUT IPortFilterWavePci ** OutFilter)
338 {
340 
342  if (!This)
344 
345  This->AddRef();
346 
347  // return result
348  *OutFilter = (IPortFilterWavePci*)This;
349 
350  return STATUS_SUCCESS;
351 }
CPPORT Port[4]
Definition: headless.c:34
#define IOCTL_KS_PROPERTY
Definition: ks.h:127
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:118
IPortPinWavePci ** m_Pins
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_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
STDMETHODIMP QueryInterface(REFIID InterfaceId, PVOID *Interface)
BOOL Init(PUSERCONNECT UserCon)
Definition: dllmain.c:385
static BOOL Write(PBYTE Address, PBYTE Data, SIZE_T Size)
Definition: vmhorizon.c:15
CHAR InputBuffer[80]
Definition: conmgr.c:33
#define IsEqualGUIDAligned(guid1, guid2)
Definition: wdm.template.h:233
IPortWavePci * m_Port
ULONG PinId
Definition: ks.h:2603
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
STDMETHODIMP_(ULONG) AddRef()
#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
ULONG MaxFilterInstanceCount
Definition: interfaces.hpp:189
_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
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
static const UCHAR Index[8]
Definition: usbohci.c:18
nsrefcnt Release()
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
CPortFilterWavePci(IUnknown *OuterUnknown)
* PFILE_OBJECT
Definition: iotypes.h:1955
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 NewPortFilterWavePci(OUT IPortFilterWavePci **OutFilter)
SUBDEVICE_DESCRIPTOR * m_Descriptor
_Must_inspect_result_ _In_ PFILE_OBJECT _In_ ULONG _In_ ULONG InputBufferLength
Definition: fltkernel.h:1372
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 NewPortPinWavePci(OUT IPortPinWavePci **OutPin)
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
STDMETHODIMP_(ULONG) Release()
ULONG PinDescriptorCount
Definition: interfaces.hpp:198
virtual ~CPortFilterWavePci()
static ULONG WINAPI AddRef(IStream *iface)
Definition: clist.c:90
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:566
PKSPROPERTY_SET FilterPropertySet
Definition: interfaces.hpp:210
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2772
PDEVICE_OBJECT GetDeviceObjectFromPortWavePci(IPortWavePci *iface)
return STATUS_SUCCESS
Definition: btrfs.c:2966
_Must_inspect_result_ _In_ FLT_CONTEXT_TYPE _In_ SIZE_T _In_ POOL_TYPE PoolType
Definition: fltkernel.h:1444
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