ReactOS  0.4.13-dev-563-g0561610
filter_wavecyclic.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_wavecyclic.c
5  * PURPOSE: portcls wave cyclic 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 CPortFilterWaveCyclic : public IPortFilterWaveCyclic
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  }
41 
42 protected:
43  IPortWaveCyclic* m_Port;
44  IPortPinWaveCyclic ** m_Pins;
46  ISubdevice * m_SubDevice;
48 };
49 
51 NTAPI
53  IN REFIID refiid,
54  OUT PVOID* Output)
55 {
56  if (IsEqualGUIDAligned(refiid, IID_IIrpTarget) ||
58  {
59  *Output = PVOID(PUNKNOWN(this));
60  PUNKNOWN(*Output)->AddRef();
61  return STATUS_SUCCESS;
62  }
63  else if (IsEqualGUIDAligned(refiid, IID_IPort))
64  {
66  PUNKNOWN(*Output)->AddRef();
67  return STATUS_SUCCESS;
68  }
69 
70  return STATUS_UNSUCCESSFUL;
71 }
72 
74 NTAPI
75 CPortFilterWaveCyclic::NewIrpTarget(
76  OUT struct IIrpTarget **OutTarget,
77  IN PCWSTR Name,
81  IN PIRP Irp,
82  IN KSOBJECT_CREATE *CreateObject)
83 {
85  IPortPinWaveCyclic * Pin;
86  PKSPIN_CONNECT ConnectDetails;
87 
88 #if 0
89  ASSERT(m_Port);
91  ASSERT(m_Pins);
92 #endif
93 
94  DPRINT("CPortFilterWaveCyclic::NewIrpTarget entered\n");
95 
96  // let's verify the connection request
98  if (!NT_SUCCESS(Status))
99  {
100  return STATUS_UNSUCCESSFUL;
101  }
102 
103  if (m_Pins[ConnectDetails->PinId] &&
105  {
106  // release existing instance
107  return STATUS_UNSUCCESSFUL;
108  }
109 
110  // now create the pin
112  if (!NT_SUCCESS(Status))
113  {
114  return Status;
115  }
116 
117  // initialize the pin
118  Status = Pin->Init(m_Port, this, ConnectDetails, &m_Descriptor->Factory.KsPinDescriptor[ConnectDetails->PinId]);
119  if (!NT_SUCCESS(Status))
120  {
121  Pin->Release();
122  return Status;
123  }
124 
125  // store pin
126  m_Pins[ConnectDetails->PinId] = Pin;
127 
128  // store result
129  *OutTarget = (IIrpTarget*)Pin;
130 
131  // increment current instance count
133 
134  return Status;
135 }
136 
137 NTSTATUS
138 NTAPI
141  IN PIRP Irp)
142 {
143  PIO_STACK_LOCATION IoStack;
145 
147 
148  if (IoStack->Parameters.DeviceIoControl.IoControlCode != IOCTL_KS_PROPERTY)
149  {
150  DPRINT("Unhandled function %lx Length %x\n", IoStack->Parameters.DeviceIoControl.IoControlCode, IoStack->Parameters.DeviceIoControl.InputBufferLength);
151 
152  Irp->IoStatus.Status = STATUS_NOT_FOUND;
153 
155  return STATUS_NOT_FOUND;
156  }
157 
159  if (Status != STATUS_PENDING)
160  {
161  Irp->IoStatus.Status = Status;
162  DPRINT("Result %x Length %u\n", Status, Irp->IoStatus.Information);
164  }
165  return Status;
166 }
167 
168 NTSTATUS
169 NTAPI
172  IN PIRP Irp)
173 {
175 }
176 
177 NTSTATUS
178 NTAPI
181  IN PIRP Irp)
182 {
184 }
185 
186 NTSTATUS
187 NTAPI
190  IN PIRP Irp)
191 {
193 }
194 
195 NTSTATUS
196 NTAPI
199  IN PIRP Irp)
200 {
201  //ULONG Index;
203 
204 #if 0
205  if (m_ref == 1)
206  {
208  {
209  // all pins should have been closed by now
210  ASSERT(m_Pins[Index] == NULL);
211  }
212 
213  // release reference to port
214  m_SubDevice->Release(m_SubDevice);
215 
216  // time to shutdown the audio system
217  Status = m_SubDevice->ReleaseChildren(m_SubDevice);
218  }
219 #endif
220 
221  Irp->IoStatus.Status = Status;
222  Irp->IoStatus.Information = 0;
224 
225  return STATUS_SUCCESS;
226 }
227 
228 NTSTATUS
229 NTAPI
230 CPortFilterWaveCyclic::QuerySecurity(
232  IN PIRP Irp)
233 {
235 }
236 
237 NTSTATUS
238 NTAPI
239 CPortFilterWaveCyclic::SetSecurity(
241  IN PIRP Irp)
242 {
244 }
245 
246 BOOLEAN
247 NTAPI
248 CPortFilterWaveCyclic::FastDeviceIoControl(
250  IN BOOLEAN Wait,
256  OUT PIO_STATUS_BLOCK StatusBlock,
258 {
260 }
261 
262 BOOLEAN
263 NTAPI
264 CPortFilterWaveCyclic::FastRead(
267  IN ULONG Length,
268  IN BOOLEAN Wait,
269  IN ULONG LockKey,
270  IN PVOID Buffer,
271  OUT PIO_STATUS_BLOCK StatusBlock,
273 {
275  return FALSE;
276 }
277 
278 BOOLEAN
279 NTAPI
280 CPortFilterWaveCyclic::FastWrite(
283  IN ULONG Length,
284  IN BOOLEAN Wait,
285  IN ULONG LockKey,
286  IN PVOID Buffer,
287  OUT PIO_STATUS_BLOCK StatusBlock,
289 {
291  return FALSE;
292 }
293 
294 NTSTATUS
295 NTAPI
297  IN IPortWaveCyclic* Port)
298 {
299  ISubdevice * ISubDevice;
302 
303  // get our private interface
304  Status = Port->QueryInterface(IID_ISubdevice, (PVOID*)&ISubDevice);
305  if (!NT_SUCCESS(Status))
306  return STATUS_UNSUCCESSFUL;
307 
308  // get the subdevice descriptor
309  Status = ISubDevice->GetDescriptor(&Descriptor);
310 
311  // store subdevice interface
312  m_SubDevice = ISubDevice;
313 
314  if (!NT_SUCCESS(Status))
315  return STATUS_UNSUCCESSFUL;
316 
317  // save descriptor
319 
320  // allocate pin array
321  m_Pins = (IPortPinWaveCyclic**)AllocateItem(NonPagedPool, Descriptor->Factory.PinDescriptorCount * sizeof(IPortPinWaveCyclic*), TAG_PORTCLASS);
322 
323  if (!m_Pins)
324  return STATUS_UNSUCCESSFUL;
325 
326  // store port driver
327  m_Port = Port;
328 
329  return STATUS_SUCCESS;
330 }
331 
332 
333 NTSTATUS
334 NTAPI
335 CPortFilterWaveCyclic::FreePin(
337 {
338  ULONG Index;
339 
341  {
342  if (m_Pins[Index] == Pin)
343  {
345  m_Pins[Index] = NULL;
346  return STATUS_SUCCESS;
347  }
348  }
349  return STATUS_UNSUCCESSFUL;
350 }
351 
352 
353 NTSTATUS
355  OUT IPortFilterWaveCyclic ** OutFilter)
356 {
358 
360 
361  if (!This)
363 
364  This->AddRef();
365 
366  // return result
367  *OutFilter = (IPortFilterWaveCyclic*)This;
368 
369  return STATUS_SUCCESS;
370 }
371 
CPPORT Port[4]
Definition: headless.c:34
#define IOCTL_KS_PROPERTY
Definition: ks.h:150
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
_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
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
IPortPinWaveCyclic ** m_Pins
_Must_inspect_result_ _In_ PFILE_OBJECT _In_ ULONG _In_ ULONG _In_ ULONG OutputBufferLength
Definition: fltkernel.h:1374
STDMETHODIMP_(ULONG) AddRef()
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
STDMETHODIMP QueryInterface(REFIID InterfaceId, PVOID *Interface)
NTSTATUS NewPortPinWaveCyclic(OUT IPortPinWaveCyclic **OutPin)
ULONG PinId
Definition: ks.h:2632
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
NTSTATUS NewPortFilterWaveCyclic(OUT IPortFilterWaveCyclic **OutFilter)
ULONG CurrentPinInstanceCount
Definition: interfaces.hpp:191
long LONG
Definition: pedump.c:60
CPortFilterWaveCyclic(IUnknown *OuterUnknown)
#define STDMETHODIMP
Definition: basetyps.h:43
IPortWaveCyclic * m_Port
KSPIN_FACTORY Factory
Definition: interfaces.hpp:208
IPortPinWaveCyclic * PPORTPINWAVECYCLIC
Definition: interfaces.hpp:797
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
#define STATUS_NOT_FOUND
Definition: shellext.h:67
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
_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
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 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
ULONG PinDescriptorCount
Definition: interfaces.hpp:198
STDMETHODIMP_(ULONG) Release()
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:565
#define UNIMPLEMENTED
Definition: debug.h:114
PKSPROPERTY_SET FilterPropertySet
Definition: interfaces.hpp:210
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
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