ReactOS  0.4.15-dev-3428-g0609db5
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:35
#define IOCTL_KS_PROPERTY
Definition: ks.h:127
IPortWaveRT * m_Port
const uint16_t * PCWSTR
Definition: typedefs.h:57
#define IN
Definition: typedefs.h:39
_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
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
_Must_inspect_result_ _In_ WDFIORESLIST _In_ PIO_RESOURCE_DESCRIPTOR Descriptor
Definition: wdfresource.h:339
IUnknown * PUNKNOWN
Definition: com_apitest.h:45
#define TAG_PORTCLASS
Definition: private.hpp:24
_In_ WDFDPC _In_ BOOLEAN Wait
Definition: wdfdpc.h:167
PVOID AllocateItem(IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes)
Definition: misc.c:30
LONG NTSTATUS
Definition: precomp.h:26
_In_ WDFREQUEST _In_ size_t _In_ size_t InputBufferLength
Definition: wdfio.h:318
BOOL Init(PUSERCONNECT UserCon)
Definition: dllmain.c:385
static BOOL Write(PBYTE Address, PBYTE Data, SIZE_T Size)
Definition: vmhorizon.c:15
STDMETHODIMP_(ULONG) Release()
#define PC_ASSERT(exp)
Definition: private.hpp:26
#define IsEqualGUIDAligned(guid1, guid2)
Definition: wdm.template.h:240
_In_ WDFREQUEST _In_ size_t OutputBufferLength
Definition: wdfio.h:318
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
ULONG PinId
Definition: ks.h:2603
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
#define FALSE
Definition: types.h:117
_In_ PIRP Irp
Definition: csq.h:116
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
#define IoCompleteRequest
Definition: irp.c:1240
Definition: bufpool.h:45
void * PVOID
Definition: retypes.h:9
SUBDEVICE_DESCRIPTOR * m_Descriptor
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:547
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR OutputBuffer
Definition: wdfiotarget.h:859
Status
Definition: gdiplustypes.h:24
IN PLARGE_INTEGER IN ULONG IN BOOLEAN IN ULONG LockKey
Definition: fatprocs.h:2662
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR InputBuffer
Definition: wdfiotarget.h:949
KSDDKAPI NTSTATUS NTAPI KsDispatchInvalidDeviceRequest(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1168
#define ASSERT(a)
Definition: mode.c:44
IN PDCB IN VBO IN ULONG IN BOOLEAN Pin
Definition: fatprocs.h:424
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_PENDING
Definition: ntstatus.h:82
INT POOL_TYPE
Definition: typedefs.h:78
const GUID IID_IUnknown
nsrefcnt Release()
CPortFilterWaveRT(IUnknown *OuterUnknown)
* PFILE_OBJECT
Definition: iotypes.h:1998
ULONG AddRef()
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define InterlockedDecrement
Definition: armddk.h:52
Definition: arc.h:85
_In_ WDFREQUEST _In_ size_t _In_ size_t _In_ ULONG IoControlCode
Definition: wdfio.h:318
NTSTATUS NewPortPinWaveRT(OUT IPortPinWaveRT **OutPin)
Definition: pin_wavert.cpp:694
PDEVICE_OBJECT GetDeviceObjectFromPortWaveRT(PPORTWAVERT iface)
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2793
_In_ BOOLEAN Release
Definition: cdrom.h:920
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
IN PVOID IN PVOID IN USHORT IN USHORT IN PINTERFACE Interface
Definition: pci.h:361
NTSTATUS NTAPI PcValidateConnectRequest(IN PIRP Irp, IN KSPIN_FACTORY *Descriptor, OUT PKSPIN_CONNECT *Connect)
Definition: undoc.cpp:998
Definition: sacdrv.h:268
_In_ PFCB _In_ LONGLONG FileOffset
Definition: cdprocs.h:159
#define NULL
Definition: types.h:112
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:40
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ _Strict_type_match_ POOL_TYPE PoolType
Definition: wdfdevice.h:3810
unsigned int ULONG
Definition: retypes.h:1
#define IO_NO_INCREMENT
Definition: iotypes.h:598
PKSPROPERTY_SET FilterPropertySet
Definition: interfaces.hpp:210
#define STATUS_SUCCESS
Definition: shellext.h:65
virtual ~CPortFilterWaveRT()
#define DPRINT
Definition: sndvol32.h:71
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3128
STDMETHODIMP QueryInterface(REFIID InterfaceId, PVOID *Interface)
KSPIN_DESCRIPTOR * KsPinDescriptor
Definition: interfaces.hpp:200