ReactOS  0.4.15-dev-4922-ge8ccc85
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 CUnknownImpl<IPortFilterWavePci>
18 {
19 public:
21 
23  CPortFilterWavePci(IUnknown *OuterUnknown){}
24  virtual ~CPortFilterWavePci(){}
25 
26 protected:
27  IPortWavePci* m_Port;
28  IPortPinWavePci ** m_Pins;
30 };
31 
33 NTAPI
35 
36  IN REFIID refiid,
37  OUT PVOID* Output)
38 {
39 
40  if (IsEqualGUIDAligned(refiid, IID_IIrpTarget) ||
42  {
43  *Output = PVOID(PUNKNOWN(this));
44  PUNKNOWN(*Output)->AddRef();
45  return STATUS_SUCCESS;
46  }
47  else if (IsEqualGUIDAligned(refiid, IID_IPort))
48  {
50  PUNKNOWN(*Output)->AddRef();
51  return STATUS_SUCCESS;
52  }
53 
54  return STATUS_UNSUCCESSFUL;
55 }
56 
58 NTAPI
59 CPortFilterWavePci::NewIrpTarget(
60  OUT struct IIrpTarget **OutTarget,
61  IN PCWSTR Name,
65  IN PIRP Irp,
66  IN KSOBJECT_CREATE *CreateObject)
67 {
69  IPortPinWavePci * Pin;
70  PKSPIN_CONNECT ConnectDetails;
71 
72 #if 0
73  ASSERT(m_Port);
75  ASSERT(m_Pins);
76 #endif
77 
78  DPRINT("CPortFilterWavePci::NewIrpTarget entered\n");
79 
80  // let's verify the connection request
82  if (!NT_SUCCESS(Status))
83  {
84  return STATUS_UNSUCCESSFUL;
85  }
86 
87  if (m_Pins[ConnectDetails->PinId] &&
89  {
90  // no available instance
91  return STATUS_UNSUCCESSFUL;
92  }
93 
94 
95  // now create the pin
97  if (!NT_SUCCESS(Status))
98  {
99  return Status;
100  }
101 
102  // initialize the pin
103  Status = Pin->Init(m_Port, this, ConnectDetails, &m_Descriptor->Factory.KsPinDescriptor[ConnectDetails->PinId], GetDeviceObjectFromPortWavePci(m_Port));
104  if (!NT_SUCCESS(Status))
105  {
106  Pin->Release();
107  return Status;
108  }
109 
110  // store pin
111  m_Pins[ConnectDetails->PinId] = Pin;
112 
113  // store result
114  *OutTarget = (IIrpTarget*)Pin;
115 
116  // increment current instance count
118 
119  return Status;
120 }
121 
122 NTSTATUS
123 NTAPI
126  IN PIRP Irp)
127 {
128  PIO_STACK_LOCATION IoStack;
130 
132 
133  if (IoStack->Parameters.DeviceIoControl.IoControlCode != IOCTL_KS_PROPERTY)
134  {
135  DPRINT("Unhandled function %lx Length %x\n", IoStack->Parameters.DeviceIoControl.IoControlCode, IoStack->Parameters.DeviceIoControl.InputBufferLength);
136 
137  Irp->IoStatus.Status = STATUS_SUCCESS;
138 
140  return STATUS_SUCCESS;
141  }
142 
144  if (Status != STATUS_PENDING)
145  {
146  Irp->IoStatus.Status = Status;
147  DPRINT("Result %x Length %u\n", Status, Irp->IoStatus.Information);
149  }
150  return Status;
151 }
152 
153 NTSTATUS
154 NTAPI
157  IN PIRP Irp)
158 {
160 }
161 
162 NTSTATUS
163 NTAPI
166  IN PIRP Irp)
167 {
169 }
170 
171 NTSTATUS
172 NTAPI
175  IN PIRP Irp)
176 {
178 }
179 
180 NTSTATUS
181 NTAPI
184  IN PIRP Irp)
185 {
186  Irp->IoStatus.Status = STATUS_SUCCESS;
187  Irp->IoStatus.Information = 0;
189 
190  return STATUS_UNSUCCESSFUL;
191 }
192 
193 NTSTATUS
194 NTAPI
195 CPortFilterWavePci::QuerySecurity(
197  IN PIRP Irp)
198 {
200 }
201 
202 NTSTATUS
203 NTAPI
204 CPortFilterWavePci::SetSecurity(
206  IN PIRP Irp)
207 {
209 }
210 
211 BOOLEAN
212 NTAPI
213 CPortFilterWavePci::FastDeviceIoControl(
215  IN BOOLEAN Wait,
221  OUT PIO_STATUS_BLOCK StatusBlock,
223 {
224  return FALSE;
225 }
226 
227 BOOLEAN
228 NTAPI
229 CPortFilterWavePci::FastRead(
232  IN ULONG Length,
233  IN BOOLEAN Wait,
234  IN ULONG LockKey,
235  IN PVOID Buffer,
236  OUT PIO_STATUS_BLOCK StatusBlock,
238 {
239  return FALSE;
240 }
241 
242 BOOLEAN
243 NTAPI
244 CPortFilterWavePci::FastWrite(
247  IN ULONG Length,
248  IN BOOLEAN Wait,
249  IN ULONG LockKey,
250  IN PVOID Buffer,
251  OUT PIO_STATUS_BLOCK StatusBlock,
253 {
254  return FALSE;
255 }
256 
257 NTSTATUS
258 NTAPI
260  IN IPortWavePci* Port)
261 {
262  ISubdevice * ISubDevice;
265 
266  m_Port = Port;
267 
268  // get our private interface
269  Status = m_Port->QueryInterface(IID_ISubdevice, (PVOID*)&ISubDevice);
270  if (!NT_SUCCESS(Status))
271  return STATUS_UNSUCCESSFUL;
272 
273  // get the subdevice descriptor
274  Status = ISubDevice->GetDescriptor(&Descriptor);
275 
276  // release subdevice interface
277  ISubDevice->Release();
278 
279  if (!NT_SUCCESS(Status))
280  return STATUS_UNSUCCESSFUL;
281 
282  // save descriptor
284 
285  // allocate pin array
286  m_Pins = (IPortPinWavePci**)AllocateItem(NonPagedPool, Descriptor->Factory.PinDescriptorCount * sizeof(IPortPinWavePci*), TAG_PORTCLASS);
287 
288  if (!m_Pins)
289  return STATUS_UNSUCCESSFUL;
290 
291  // increment reference count
292  Port->AddRef();
293 
294  return STATUS_SUCCESS;
295 }
296 
297 NTSTATUS
298 NTAPI
299 CPortFilterWavePci::FreePin(
300  IN struct IPortPinWavePci* Pin)
301 {
302  ULONG Index;
303 
305  {
306  if (m_Pins[Index] == Pin)
307  {
309  m_Pins[Index] = NULL;
310  return STATUS_SUCCESS;
311  }
312  }
313  return STATUS_UNSUCCESSFUL;
314 }
315 
316 
317 NTSTATUS
319  OUT IPortFilterWavePci ** OutFilter)
320 {
322 
324  if (!This)
326 
327  This->AddRef();
328 
329  // return result
330  *OutFilter = (IPortFilterWavePci*)This;
331 
332  return STATUS_SUCCESS;
333 }
CPPORT Port[4]
Definition: headless.c:35
#define IOCTL_KS_PROPERTY
Definition: ks.h:127
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
IPortPinWavePci ** m_Pins
#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
STDMETHODIMP QueryInterface(REFIID InterfaceId, PVOID *Interface)
_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
#define IsEqualGUIDAligned(guid1, guid2)
Definition: wdm.template.h:235
_In_ WDFREQUEST _In_ size_t OutputBufferLength
Definition: wdfio.h:318
IPortWavePci * m_Port
_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
#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
ULONG MaxFilterInstanceCount
Definition: interfaces.hpp:189
void * PVOID
Definition: retypes.h:9
_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
_In_ WDFCOLLECTION _In_ ULONG Index
const GUID IID_IUnknown
nsrefcnt Release()
CPortFilterWavePci(IUnknown *OuterUnknown)
* PFILE_OBJECT
Definition: iotypes.h:1998
ULONG AddRef()
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
Definition: arc.h:85
_In_ WDFREQUEST _In_ size_t _In_ size_t _In_ ULONG IoControlCode
Definition: wdfio.h:318
NTSTATUS NewPortFilterWavePci(OUT IPortFilterWavePci **OutFilter)
SUBDEVICE_DESCRIPTOR * m_Descriptor
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2793
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
NTSTATUS NewPortPinWavePci(OUT IPortPinWavePci **OutPin)
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
ULONG PinDescriptorCount
Definition: interfaces.hpp:198
#define NULL
Definition: types.h:112
virtual ~CPortFilterWavePci()
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
#define DPRINT
Definition: sndvol32.h:71
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3128
PDEVICE_OBJECT GetDeviceObjectFromPortWavePci(IPortWavePci *iface)
KSPIN_DESCRIPTOR * KsPinDescriptor
Definition: interfaces.hpp:200