ReactOS  0.4.15-dev-4603-gb922b6d
filter_dmus.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_dmus.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 CPortFilterDMus : public CUnknownImpl<IPortFilterDMus>
18 {
19 public:
21 
23  CPortFilterDMus(IUnknown *OuterUnknown){}
24  virtual ~CPortFilterDMus(){}
25 
26 protected:
27  IPortDMus* m_Port;
28  IPortPinDMus ** m_Pins;
30 };
31 
33 NTAPI
35  IN REFIID refiid,
36  OUT PVOID* Output)
37 {
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 CPortFilterDMus::NewIrpTarget(
59  OUT struct IIrpTarget **OutTarget,
60  IN PCWSTR Name,
64  IN PIRP Irp,
65  IN KSOBJECT_CREATE *CreateObject)
66 {
68  IPortPinDMus * Pin;
69  PKSPIN_CONNECT ConnectDetails;
70 
74 
75  DPRINT("CPortFilterDMus::NewIrpTarget entered\n");
76 
77  // let's verify the connection request
79  if (!NT_SUCCESS(Status))
80  {
81  return STATUS_UNSUCCESSFUL;
82  }
83 
84  if (m_Pins[ConnectDetails->PinId] && m_Descriptor->Factory.Instances[ConnectDetails->PinId].CurrentPinInstanceCount)
85  {
86  // release existing instance
87  PC_ASSERT(0);
88  }
89 
90  // now create the pin
92  if (!NT_SUCCESS(Status))
93  {
94  return Status;
95  }
96 
97  // initialize the pin
98  Status = Pin->Init(m_Port, this, ConnectDetails, &m_Descriptor->Factory.KsPinDescriptor[ConnectDetails->PinId], DeviceObject);
99  if (!NT_SUCCESS(Status))
100  {
101  Pin->Release();
102  return Status;
103  }
104 
105  // store pin
106  m_Pins[ConnectDetails->PinId] = Pin;
107 
108  // store result
109  *OutTarget = (IIrpTarget*)Pin;
110 
111  // increment current instance count
113 
114  return Status;
115 }
116 
117 NTSTATUS
118 NTAPI
121  IN PIRP Irp)
122 {
123  PIO_STACK_LOCATION IoStack;
125 
127 
128  if (IoStack->Parameters.DeviceIoControl.IoControlCode != IOCTL_KS_PROPERTY)
129  {
130  DPRINT("Unhandled function %lx Length %x\n", IoStack->Parameters.DeviceIoControl.IoControlCode, IoStack->Parameters.DeviceIoControl.InputBufferLength);
131 
132  Irp->IoStatus.Status = STATUS_SUCCESS;
133 
135  return STATUS_SUCCESS;
136  }
137 
139  if (Status != STATUS_PENDING)
140  {
141  Irp->IoStatus.Status = Status;
142  DPRINT("Result %x Length %u\n", Status, Irp->IoStatus.Information);
144  }
145  return Status;
146 }
147 
148 NTSTATUS
149 NTAPI
152  IN PIRP Irp)
153 {
155 }
156 
157 NTSTATUS
158 NTAPI
161  IN PIRP Irp)
162 {
164 }
165 
166 NTSTATUS
167 NTAPI
170  IN PIRP Irp)
171 {
173 }
174 
175 NTSTATUS
176 NTAPI
179  IN PIRP Irp)
180 {
181  Irp->IoStatus.Status = STATUS_SUCCESS;
182  Irp->IoStatus.Information = 0;
184 
185  return STATUS_UNSUCCESSFUL;
186 }
187 
188 NTSTATUS
189 NTAPI
190 CPortFilterDMus::QuerySecurity(
192  IN PIRP Irp)
193 {
195 }
196 
197 NTSTATUS
198 NTAPI
199 CPortFilterDMus::SetSecurity(
201  IN PIRP Irp)
202 {
204 }
205 
206 BOOLEAN
207 NTAPI
208 CPortFilterDMus::FastDeviceIoControl(
210  IN BOOLEAN Wait,
216  OUT PIO_STATUS_BLOCK StatusBlock,
218 {
219  return FALSE;
220 }
221 
222 BOOLEAN
223 NTAPI
224 CPortFilterDMus::FastRead(
227  IN ULONG Length,
228  IN BOOLEAN Wait,
229  IN ULONG LockKey,
230  IN PVOID Buffer,
231  OUT PIO_STATUS_BLOCK StatusBlock,
233 {
235  return FALSE;
236 }
237 
238 BOOLEAN
239 NTAPI
240 CPortFilterDMus::FastWrite(
243  IN ULONG Length,
244  IN BOOLEAN Wait,
245  IN ULONG LockKey,
246  IN PVOID Buffer,
247  OUT PIO_STATUS_BLOCK StatusBlock,
249 {
251  return FALSE;
252 }
253 
254 NTSTATUS
255 NTAPI
257  IN IPortDMus* Port)
258 {
259  ISubdevice * ISubDevice;
261 
262  m_Port = Port;
263 
264  // get our private interface
265  Status = m_Port->QueryInterface(IID_ISubdevice, (PVOID*)&ISubDevice);
266  if (!NT_SUCCESS(Status))
267  return STATUS_UNSUCCESSFUL;
268 
269  // get the subdevice descriptor
270  Status = ISubDevice->GetDescriptor(&m_Descriptor);
271 
272  // release subdevice interface
273  ISubDevice->Release();
274 
275  if (!NT_SUCCESS(Status))
276  return STATUS_UNSUCCESSFUL;
277 
278  // allocate pin array
279  m_Pins = (IPortPinDMus**)AllocateItem(NonPagedPool, m_Descriptor->Factory.PinDescriptorCount * sizeof(IPortPinDMus*), TAG_PORTCLASS);
280 
281  if (!m_Pins)
282  return STATUS_UNSUCCESSFUL;
283 
284  // increment reference count
285  Port->AddRef();
286 
287  return STATUS_SUCCESS;
288 }
289 
290 
291 NTSTATUS
292 NTAPI
293 CPortFilterDMus::FreePin(
294  IN struct IPortPinDMus* Pin)
295 {
296  ULONG Index;
297 
299  {
300  if (m_Pins[Index] == Pin)
301  {
302  m_Pins[Index]->Release();
303  m_Pins[Index] = NULL;
304  return STATUS_SUCCESS;
305  }
306  }
307  return STATUS_UNSUCCESSFUL;
308 }
309 
310 VOID
311 NTAPI
312 CPortFilterDMus::NotifyPins()
313 {
314  ULONG Index;
315 
316  DPRINT("Notifying %u pins\n", m_Descriptor->Factory.PinDescriptorCount);
317 
319  {
320  m_Pins[Index]->Notify();
321  }
322 }
323 
324 
325 NTSTATUS
327  OUT PPORTFILTERDMUS * OutFilter)
328 {
330 
332  if (!This)
334 
335  This->AddRef();
336 
337  // return result
338  *OutFilter = (CPortFilterDMus*)This;
339 
340  return STATUS_SUCCESS;
341 }
342 
343 
CPortFilterDMus(IUnknown *OuterUnknown)
Definition: filter_dmus.cpp:23
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
IPortFilterDMus * PPORTFILTERDMUS
Definition: interfaces.hpp:837
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
IUnknown * PUNKNOWN
Definition: com_apitest.h:45
#define TAG_PORTCLASS
Definition: private.hpp:24
_In_ WDFDPC _In_ BOOLEAN Wait
Definition: wdfdpc.h:167
IPortDMus * m_Port
Definition: filter_dmus.cpp:27
PVOID AllocateItem(IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes)
Definition: misc.c:30
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NewPortFilterDMus(OUT PPORTFILTERDMUS *OutFilter)
SUBDEVICE_DESCRIPTOR * m_Descriptor
Definition: filter_dmus.cpp:29
_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
#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
_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
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
IPortPinDMus ** m_Pins
Definition: filter_dmus.cpp:28
INT POOL_TYPE
Definition: typedefs.h:78
_In_ WDFCOLLECTION _In_ ULONG Index
const GUID IID_IUnknown
nsrefcnt Release()
virtual ~CPortFilterDMus()
Definition: filter_dmus.cpp:24
* PFILE_OBJECT
Definition: iotypes.h:1998
ULONG AddRef()
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
STDMETHODIMP QueryInterface(REFIID InterfaceId, PVOID *Interface)
Definition: filter_dmus.cpp:34
Definition: arc.h:85
_In_ WDFREQUEST _In_ size_t _In_ size_t _In_ ULONG IoControlCode
Definition: wdfio.h:318
__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
ULONG PinDescriptorCount
Definition: interfaces.hpp:198
#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
NTSTATUS NewPortPinDMus(OUT IPortPinDMus **OutPin)
Definition: pin_dmus.cpp:616
unsigned int ULONG
Definition: retypes.h:1
#define IO_NO_INCREMENT
Definition: iotypes.h:598
#define UNIMPLEMENTED
Definition: debug.h:115
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
KSPIN_DESCRIPTOR * KsPinDescriptor
Definition: interfaces.hpp:200