ReactOS  0.4.15-dev-4594-g505ac65
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 CUnknownImpl<IPortFilterWaveRT>
18 {
19 public:
21 
23  CPortFilterWaveRT(IUnknown *OuterUnknown){}
24  virtual ~CPortFilterWaveRT(){}
25 
26 protected:
27 
28  IPortWaveRT* m_Port;
29  IPortPinWaveRT ** m_Pins;
31 };
32 
34 NTAPI
36  IN REFIID refiid,
37  OUT PVOID* Output)
38 {
39  if (IsEqualGUIDAligned(refiid, IID_IIrpTarget) ||
41  {
42  *Output = PVOID(PUNKNOWN(this));
43  PUNKNOWN(*Output)->AddRef();
44  return STATUS_SUCCESS;
45  }
46  else if (IsEqualGUIDAligned(refiid, IID_IPort))
47  {
49  PUNKNOWN(*Output)->AddRef();
50  return STATUS_SUCCESS;
51  }
52 
53  return STATUS_UNSUCCESSFUL;
54 }
55 
57 NTAPI
58 CPortFilterWaveRT::NewIrpTarget(
59  OUT struct IIrpTarget **OutTarget,
60  IN PCWSTR Name,
64  IN PIRP Irp,
65  IN KSOBJECT_CREATE *CreateObject)
66 {
68  IPortPinWaveRT * Pin;
69  PKSPIN_CONNECT ConnectDetails;
70 
71 #if 0
72  ASSERT(m_Port);
74  ASSERT(m_Pins);
75 #endif
76 
77  DPRINT("CPortFilterWaveRT::NewIrpTarget entered\n");
78 
79  // let's verify the connection request
81  if (!NT_SUCCESS(Status))
82  {
83  return STATUS_UNSUCCESSFUL;
84  }
85 
86  if (m_Pins[ConnectDetails->PinId] && m_Descriptor->Factory.Instances[ConnectDetails->PinId].CurrentPinInstanceCount)
87  {
88  // release existing instance
89  PC_ASSERT(0);
90  m_Pins[ConnectDetails->PinId]->Close(DeviceObject, NULL);
91  }
92 
93  // now create the pin
95  if (!NT_SUCCESS(Status))
96  {
97  return Status;
98  }
99 
100  // initialize the pin
101  Status = Pin->Init(m_Port, this, ConnectDetails, &m_Descriptor->Factory.KsPinDescriptor[ConnectDetails->PinId], GetDeviceObjectFromPortWaveRT(m_Port));
102  if (!NT_SUCCESS(Status))
103  {
104  Pin->Release();
105  return Status;
106  }
107 
108  // release existing pin
109  if (m_Pins[ConnectDetails->PinId])
110  {
111  m_Pins[ConnectDetails->PinId]->Release();
112  }
113  // store pin
114  m_Pins[ConnectDetails->PinId] = Pin;
115 
116  // store result
117  *OutTarget = (IIrpTarget*)Pin;
118 
119  // increment current instance count
121 
122  return Status;
123 }
124 
125 NTSTATUS
126 NTAPI
129  IN PIRP Irp)
130 {
131  PIO_STACK_LOCATION IoStack;
133 
135 
136  if (IoStack->Parameters.DeviceIoControl.IoControlCode != IOCTL_KS_PROPERTY)
137  {
138  DPRINT("Unhandled function %lx Length %x\n", IoStack->Parameters.DeviceIoControl.IoControlCode, IoStack->Parameters.DeviceIoControl.InputBufferLength);
139 
140  Irp->IoStatus.Status = STATUS_SUCCESS;
141 
143  return STATUS_SUCCESS;
144  }
145 
147  if (Status != STATUS_PENDING)
148  {
149  Irp->IoStatus.Status = Status;
150  DPRINT("Result %x Length %u\n", Status, Irp->IoStatus.Information);
152  }
153  return Status;
154 }
155 
156 NTSTATUS
157 NTAPI
160  IN PIRP Irp)
161 {
163 }
164 
165 NTSTATUS
166 NTAPI
169  IN PIRP Irp)
170 {
172 }
173 
174 NTSTATUS
175 NTAPI
178  IN PIRP Irp)
179 {
181 }
182 
183 NTSTATUS
184 NTAPI
187  IN PIRP Irp)
188 {
189  Irp->IoStatus.Status = STATUS_SUCCESS;
190  Irp->IoStatus.Information = 0;
192 
193  return STATUS_UNSUCCESSFUL;
194 }
195 
196 NTSTATUS
197 NTAPI
198 CPortFilterWaveRT::QuerySecurity(
200  IN PIRP Irp)
201 {
203 }
204 
205 NTSTATUS
206 NTAPI
207 CPortFilterWaveRT::SetSecurity(
209  IN PIRP Irp)
210 {
212 }
213 
214 BOOLEAN
215 NTAPI
216 CPortFilterWaveRT::FastDeviceIoControl(
218  IN BOOLEAN Wait,
224  OUT PIO_STATUS_BLOCK StatusBlock,
226 {
227  return FALSE;
228 }
229 
230 BOOLEAN
231 NTAPI
232 CPortFilterWaveRT::FastRead(
235  IN ULONG Length,
236  IN BOOLEAN Wait,
237  IN ULONG LockKey,
238  IN PVOID Buffer,
239  OUT PIO_STATUS_BLOCK StatusBlock,
241 {
242  return FALSE;
243 }
244 
245 BOOLEAN
246 NTAPI
247 CPortFilterWaveRT::FastWrite(
248 
251  IN ULONG Length,
252  IN BOOLEAN Wait,
253  IN ULONG LockKey,
254  IN PVOID Buffer,
255  OUT PIO_STATUS_BLOCK StatusBlock,
257 {
258  return FALSE;
259 }
260 
261 NTSTATUS
262 NTAPI
264  IN IPortWaveRT* Port)
265 {
266  ISubdevice * ISubDevice;
269 
270  m_Port = Port;
271 
272  // get our private interface
273  Status = m_Port->QueryInterface(IID_ISubdevice, (PVOID*)&ISubDevice);
274  if (!NT_SUCCESS(Status))
275  return STATUS_UNSUCCESSFUL;
276 
277  // get the subdevice descriptor
278  Status = ISubDevice->GetDescriptor(&Descriptor);
279 
280  // release subdevice interface
281  ISubDevice->Release();
282 
283  if (!NT_SUCCESS(Status))
284  return STATUS_UNSUCCESSFUL;
285 
286  // save descriptor
288 
289  // allocate pin array
290  m_Pins = (IPortPinWaveRT**)AllocateItem(NonPagedPool, Descriptor->Factory.PinDescriptorCount * sizeof(IPortPinWaveRT*), TAG_PORTCLASS);
291 
292  if (!m_Pins)
293  return STATUS_UNSUCCESSFUL;
294 
295  // increment reference count
296  Port->AddRef();
297 
298  return STATUS_SUCCESS;
299 }
300 
301 NTSTATUS
303  OUT IPortFilterWaveRT ** OutFilter)
304 {
306 
308  if (!This)
310 
311  This->AddRef();
312 
313  // return result
314  *OutFilter = (CPortFilterWaveRT*)This;
315 
316  return STATUS_SUCCESS;
317 }
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
#define PC_ASSERT(exp)
Definition: private.hpp:26
#define IsEqualGUIDAligned(guid1, guid2)
Definition: wdm.template.h:235
_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
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
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:676
PDEVICE_OBJECT GetDeviceObjectFromPortWaveRT(PPORTWAVERT iface)
__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
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
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