ReactOS  0.4.15-dev-4869-g35a816a
port_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/port_wavert.cpp
5  * PURPOSE: WaveRT Port Driver
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 CPortWaveRT : public CUnknownImpl<IPortWaveRT, IPortEvents, ISubdevice>
18 {
19 public:
21 
25  CPortWaveRT(IUnknown *OuterUnknown) {}
26  virtual ~CPortWaveRT() {}
27 
28 protected:
29 
38  IPortFilterWaveRT * m_Filter;
39 
40  friend PMINIPORTWAVERT GetWaveRTMiniport(IN IPortWaveRT* iface);
42 };
43 
44 static GUID InterfaceGuids[3] =
45 {
46  {
48  0x6994AD04, 0x93EF, 0x11D0, {0xA3, 0xCC, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96}
49  },
50  {
52  0x65E8773EL, 0x8F56, 0x11D0, {0xA3, 0xB9, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96}
53  },
54  {
56  0x65E8773DL, 0x8F56, 0x11D0, {0xA3, 0xB9, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96}
57  }
58 };
59 
60 DEFINE_KSPROPERTY_TOPOLOGYSET(PortFilterWaveRTTopologySet, TopologyPropertyHandler);
62 
63 KSPROPERTY_SET WaveRTPropertySet[] =
64 {
65  {
67  sizeof(PortFilterWaveRTTopologySet) / sizeof(KSPROPERTY_ITEM),
68  (const KSPROPERTY_ITEM*)&PortFilterWaveRTTopologySet,
69  0,
70  NULL
71  },
72  {
74  sizeof(PortFilterWaveRTPinSet) / sizeof(KSPROPERTY_ITEM),
75  (const KSPROPERTY_ITEM*)&PortFilterWaveRTPinSet,
76  0,
77  NULL
78  }
79 };
80 
81 //KSEVENTSETID_LoopedStreaming, Type = KSEVENT_LOOPEDSTREAMING_POSITION
82 //KSEVENTSETID_Connection, Type = KSEVENT_CONNECTION_ENDOFSTREAM,
83 
84 
85 
86 //---------------------------------------------------------------
87 // IPortEvents
88 //
89 
90 void
91 NTAPI
92 CPortWaveRT::AddEventToEventList(
93  IN PKSEVENT_ENTRY EventEntry)
94 {
96 }
97 
98 
99 void
100 NTAPI
101 CPortWaveRT::GenerateEventList(
102  IN GUID* Set OPTIONAL,
103  IN ULONG EventId,
104  IN BOOL PinEvent,
105  IN ULONG PinId,
106  IN BOOL NodeEvent,
107  IN ULONG NodeId)
108 {
110 }
111 
112 //---------------------------------------------------------------
113 // IUnknown interface functions
114 //
115 
116 NTSTATUS
117 NTAPI
119  IN REFIID refiid,
120  OUT PVOID* Output)
121 {
123 
124  if (IsEqualGUIDAligned(refiid, IID_IPortWaveRT) ||
126  {
127  *Output = PVOID(PPORTWAVERT(this));
128  PUNKNOWN(*Output)->AddRef();
129  return STATUS_SUCCESS;
130  }
131  else if (IsEqualGUIDAligned(refiid, IID_IPortEvents))
132  {
133  *Output = PVOID(PPORTEVENTS(this));
134  PUNKNOWN(*Output)->AddRef();
135  return STATUS_SUCCESS;
136  }
137  else if (IsEqualGUIDAligned(refiid, IID_ISubdevice))
138  {
139  *Output = PVOID(PSUBDEVICE(this));
140  PUNKNOWN(*Output)->AddRef();
141  return STATUS_SUCCESS;
142  }
143  else if (IsEqualGUIDAligned(refiid, IID_IPortClsVersion))
144  {
146  }
147  else if (IsEqualGUIDAligned(refiid, IID_IDrmPort) ||
148  IsEqualGUIDAligned(refiid, IID_IDrmPort2))
149  {
150  return NewIDrmPort((PDRMPORT2*)Output);
151  }
152  else if (IsEqualGUIDAligned(refiid, IID_IUnregisterSubdevice))
153  {
155  }
156  else if (IsEqualGUIDAligned(refiid, IID_IUnregisterPhysicalConnection))
157  {
159  }
160 
162  {
163  DPRINT("IPortWaveRT_fnQueryInterface no interface!!! iface %S\n", GuidString.Buffer);
165  }
166 
167  return STATUS_UNSUCCESSFUL;
168 }
169 //---------------------------------------------------------------
170 // IPort interface functions
171 //
172 
173 NTSTATUS
174 NTAPI
175 CPortWaveRT::GetDeviceProperty(
176  IN DEVICE_REGISTRY_PROPERTY DeviceRegistryProperty,
180 {
182 
183  if (!m_bInitialized)
184  {
185  DPRINT("IPortWaveRT_fnNewRegistryKey called w/o initialized\n");
186  return STATUS_UNSUCCESSFUL;
187  }
188 
190 }
191 
192 NTSTATUS
193 NTAPI
196  IN PIRP Irp,
197  IN PUNKNOWN UnknownMiniport,
198  IN PUNKNOWN UnknownAdapter OPTIONAL,
200 {
201  IMiniportWaveRT * Miniport;
204  PPOWERNOTIFY PowerNotify;
205 
206  DPRINT("IPortWaveRT_Init entered %p\n", this);
208 
209  if (m_bInitialized)
210  {
211  DPRINT("IPortWaveRT_Init called again\n");
212  return STATUS_SUCCESS;
213  }
214 
215  Status = UnknownMiniport->QueryInterface(IID_IMiniportWaveRT, (PVOID*)&Miniport);
216  if (!NT_SUCCESS(Status))
217  {
218  DPRINT("IPortWaveRT_Init called with invalid IMiniport adapter\n");
220  }
221 
222  // Initialize port object
223  m_pMiniport = Miniport;
227 
228  // increment reference on miniport adapter
229  Miniport->AddRef();
230 
231  Status = Miniport->Init(UnknownAdapter, ResourceList, this);
232  if (!NT_SUCCESS(Status))
233  {
234  DPRINT("IMiniportWaveRT_Init failed with %x\n", Status);
235  Miniport->Release();
237  return Status;
238  }
239 
240 
241  // get the miniport device descriptor
242  Status = Miniport->GetDescription(&m_pDescriptor);
243  if (!NT_SUCCESS(Status))
244  {
245  DPRINT("failed to get description\n");
246  Miniport->Release();
248  return Status;
249  }
250 
251  // create the subdevice descriptor
253  3,
255  0,
256  NULL,
257  2,
259  0,
260  0,
261  0,
262  NULL,
263  0,
264  NULL,
265  m_pDescriptor);
266 
267  if (!NT_SUCCESS(Status))
268  {
269  DPRINT("PcCreateSubdeviceDescriptor failed with %x\n", Status);
270  Miniport->Release();
272  return Status;
273  }
274 
275  // check if it supports IPinCount interface
276  Status = UnknownMiniport->QueryInterface(IID_IPinCount, (PVOID*)&PinCount);
277  if (NT_SUCCESS(Status))
278  {
279  // store IPinCount interface
281  }
282 
283  // does the Miniport adapter support IPowerNotify interface*/
284  Status = UnknownMiniport->QueryInterface(IID_IPowerNotify, (PVOID*)&PowerNotify);
285  if (NT_SUCCESS(Status))
286  {
287  // store reference
288  m_pPowerNotify = PowerNotify;
289  }
290 
291  // increment reference on resource list
292  ResourceList->AddRef();
293 
294 
295  DPRINT("IPortWaveRT successfully initialized\n");
296  return STATUS_SUCCESS;
297 }
298 
299 
300 NTSTATUS
301 NTAPI
302 CPortWaveRT::NewRegistryKey(
303  OUT PREGISTRYKEY *OutRegistryKey,
304  IN PUNKNOWN OuterUnknown OPTIONAL,
305  IN ULONG RegistryKeyType,
310 {
312 
313  if (!m_bInitialized)
314  {
315  DPRINT("IPortWaveRT_fnNewRegistryKey called w/o initialized\n");
316  return STATUS_UNSUCCESSFUL;
317  }
318  return PcNewRegistryKey(OutRegistryKey, OuterUnknown, RegistryKeyType, DesiredAccess, m_pDeviceObject, (ISubdevice*)this, ObjectAttributes, CreateOptions, Disposition);
319 }
320 //---------------------------------------------------------------
321 // ISubdevice interface
322 //
323 
324 NTSTATUS
325 NTAPI
326 CPortWaveRT::NewIrpTarget(
327  OUT struct IIrpTarget **OutTarget,
328  IN PCWSTR Name,
332  IN PIRP Irp,
333  IN KSOBJECT_CREATE *CreateObject)
334 {
336  IPortFilterWaveRT * Filter;
337 
338  DPRINT("ISubDevice_NewIrpTarget this %p\n", this);
339 
340  if (m_Filter)
341  {
342  *OutTarget = (IIrpTarget*)m_Filter;
343  return STATUS_SUCCESS;
344  }
345 
346 
348  if (!NT_SUCCESS(Status))
349  {
350  return Status;
351  }
352 
353  Status = Filter->Init(this);
354  if (!NT_SUCCESS(Status))
355  {
356  Filter->Release();
357  return Status;
358  }
359 
360  *OutTarget = (IIrpTarget*)Filter;
361  m_Filter = Filter;
362  return Status;
363 }
364 
365 NTSTATUS
366 NTAPI
367 CPortWaveRT::ReleaseChildren()
368 {
370  return STATUS_UNSUCCESSFUL;
371 }
372 
373 NTSTATUS
374 NTAPI
377 {
379 
381 
382  DPRINT("ISubDevice_GetDescriptor this %p desc %p\n", this, m_SubDeviceDescriptor);
383  return STATUS_SUCCESS;
384 }
385 
386 NTSTATUS
387 NTAPI
388 CPortWaveRT::DataRangeIntersection(
389  IN ULONG PinId,
390  IN PKSDATARANGE DataRange,
391  IN PKSDATARANGE MatchingDataRange,
393  OUT PVOID ResultantFormat OPTIONAL,
394  OUT PULONG ResultantFormatLength)
395 {
396  DPRINT("ISubDevice_DataRangeIntersection this %p\n", this);
397 
398  if (m_pMiniport)
399  {
400  return m_pMiniport->DataRangeIntersection (PinId, DataRange, MatchingDataRange, OutputBufferLength, ResultantFormat, ResultantFormatLength);
401  }
402 
403  return STATUS_UNSUCCESSFUL;
404 }
405 
406 NTSTATUS
407 NTAPI
408 CPortWaveRT::PowerChangeNotify(
410 {
411  if (m_pPowerNotify)
412  {
413  m_pPowerNotify->PowerChangeNotify(PowerState);
414  }
415 
416  return STATUS_SUCCESS;
417 }
418 
419 NTSTATUS
420 NTAPI
422  IN ULONG PinId,
423  IN OUT PULONG FilterNecessary,
424  IN OUT PULONG FilterCurrent,
425  IN OUT PULONG FilterPossible,
426  IN OUT PULONG GlobalCurrent,
427  IN OUT PULONG GlobalPossible)
428 {
429  if (m_pPinCount)
430  {
431  m_pPinCount->PinCount(PinId, FilterNecessary, FilterCurrent, FilterPossible, GlobalCurrent, GlobalPossible);
432  return STATUS_SUCCESS;
433  }
434 
435  // FIXME
436  // scan filter descriptor
437 
438  return STATUS_UNSUCCESSFUL;
439 }
440 
444  IN IPortWaveRT* iface)
445 {
446  CPortWaveRT * This = (CPortWaveRT *)iface;
447  return This->m_pMiniport;
448 }
449 
452  PPORTWAVERT iface)
453 {
454  CPortWaveRT * This = (CPortWaveRT *)iface;
455  return This->m_pDeviceObject;
456 }
457 
458 //---------------------------------------------------------------
459 // IPortWaveRT constructor
460 //
461 
462 
463 NTSTATUS
465  OUT PPORT* OutPort)
466 {
467  CPortWaveRT * Port;
469 
471  if (!Port)
473 
474  Status = Port->QueryInterface(IID_IPort, (PVOID*)OutPort);
475 
476  if (!NT_SUCCESS(Status))
477  {
478  delete Port;
479  }
480 
481  DPRINT("NewPortWaveRT %p Status %u\n", Port, Status);
482  return Status;
483 }
484 
DEVICE_REGISTRY_PROPERTY
Definition: iotypes.h:1194
IPortEvents * PPORTEVENTS
Definition: portcls.h:2119
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
IPortFilterWaveRT * m_Filter
Definition: port_wavert.cpp:38
PPCFILTER_DESCRIPTOR m_pDescriptor
Definition: port_wavert.cpp:36
IN CINT OUT PVOID IN ULONG OUT PULONG ReturnLength
Definition: dumpinfo.c:39
static PWSTR GuidString
Definition: apphelp.c:93
NTSTATUS NTAPI PinPropertyHandler(IN PIRP Irp, IN PKSIDENTIFIER Request, IN OUT PVOID Data)
CPPORT Port[4]
Definition: headless.c:35
const uint16_t * PCWSTR
Definition: typedefs.h:57
#define IN
Definition: typedefs.h:39
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG BufferLength
Definition: wdfdevice.h:3767
IPortWaveRT * PPORTWAVERT
Definition: interfaces.hpp:681
_Must_inspect_result_ _In_ WDFDEVICE _In_ ULONG _In_ ACCESS_MASK DesiredAccess
Definition: wdfdevice.h:2654
#define REFIID
Definition: guiddef.h:118
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_Must_inspect_result_ _In_ WDFIORESLIST _In_ PIO_RESOURCE_DESCRIPTOR Descriptor
Definition: wdfresource.h:339
BOOL m_bInitialized
Definition: port_wavert.cpp:30
IPinCount * PPINCOUNT
Definition: portcls.h:2090
#define TRUE
Definition: types.h:120
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
IUnknown * PUNKNOWN
Definition: com_apitest.h:45
#define TAG_PORTCLASS
Definition: private.hpp:24
LONG NTSTATUS
Definition: precomp.h:26
return pList GetDescriptor(Index)
PRESOURCELIST m_pResourceList
Definition: port_wavert.cpp:33
IUnregisterSubdevice * PUNREGISTERSUBDEVICE
Definition: portcls.h:633
BOOL Init(PUSERCONNECT UserCon)
Definition: dllmain.c:385
_In_ const GUID _In_ ULONG PinCount
Definition: strmini.h:504
virtual ~CPortWaveRT()
Definition: port_wavert.cpp:26
_Must_inspect_result_ _In_ WDFIORESREQLIST _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFIORESLIST * ResourceList
Definition: wdfresource.h:304
_In_ ACCESS_MASK _In_ POBJECT_ATTRIBUTES _Reserved_ ULONG _In_opt_ PUNICODE_STRING _In_ ULONG _Out_opt_ PULONG Disposition
Definition: cmfuncs.h:50
IMiniportWaveRT * PMINIPORTWAVERT
Definition: portcls.h:1981
static BOOL Set
Definition: pageheap.c:10
#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
DEFINE_KSPROPERTY_TOPOLOGYSET(PortFilterWaveRTTopologySet, TopologyPropertyHandler)
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
DEFINE_KSPROPERTY_PINPROPOSEDATAFORMAT(PortFilterWaveRTPinSet, PinPropertyHandler, PinPropertyHandler, PinPropertyHandler)
#define L(x)
Definition: ntvdm.h:50
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
NTSTATUS NewPortWaveRT(OUT PPORT *OutPort)
#define FALSE
Definition: types.h:117
_In_ PIRP Irp
Definition: csq.h:116
unsigned int BOOL
Definition: ntddk_ex.h:94
_Must_inspect_result_ _In_opt_ PFLT_FILTER Filter
Definition: fltkernel.h:1801
NTSTATUS NewPortFilterWaveRT(OUT IPortFilterWaveRT **OutFilter)
#define STDMETHODIMP
Definition: basetyps.h:43
IPort * PPORT
Definition: portcls.h:1103
NTSTATUS NTAPI PcCreateSubdeviceDescriptor(OUT SUBDEVICE_DESCRIPTOR **OutSubdeviceDescriptor, IN ULONG InterfaceCount, IN GUID *InterfaceGuids, IN ULONG IdentifierCount, IN KSIDENTIFIER *Identifier, IN ULONG FilterPropertiesCount, IN KSPROPERTY_SET *FilterProperties, IN ULONG Unknown1, IN ULONG Unknown2, IN ULONG PinPropertiesCount, IN KSPROPERTY_SET *PinProperties, IN ULONG EventSetCount, IN KSEVENT_SET *EventSet, IN PPCFILTER_DESCRIPTOR FilterDescription)
Definition: undoc.cpp:730
PDEVICE_OBJECT m_pDeviceObject
Definition: port_wavert.cpp:31
NTSTATUS NTAPI IoGetDeviceProperty(IN PDEVICE_OBJECT DeviceObject, IN DEVICE_REGISTRY_PROPERTY DeviceProperty, IN ULONG BufferLength, OUT PVOID PropertyBuffer, OUT PULONG ResultLength)
Definition: pnpmgr.c:1952
void * PVOID
Definition: retypes.h:9
PPINCOUNT m_pPinCount
Definition: port_wavert.cpp:34
friend PDEVICE_OBJECT GetDeviceObjectFromPortWaveRT(PPORTWAVERT iface)
IUnregisterPhysicalConnection * PUNREGISTERPHYSICALCONNECTION
Definition: portcls.h:675
#define KSPROPSETID_Topology
Definition: ks.h:842
Status
Definition: gdiplustypes.h:24
CPortWaveRT(IUnknown *OuterUnknown)
Definition: port_wavert.cpp:25
IRegistryKey * PREGISTRYKEY
Definition: portcls.h:1009
IDrmPort2 * PDRMPORT2
Definition: portcls.h:2226
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
INT POOL_TYPE
Definition: typedefs.h:78
const GUID IID_IUnknown
nsrefcnt Release()
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
NTSTATUS NTAPI TopologyPropertyHandler(IN PIRP Irp, IN PKSIDENTIFIER Request, IN OUT PVOID Data)
#define PC_ASSERT_IRQL_EQUAL(x)
Definition: private.hpp:31
ULONG AddRef()
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
KSPROPERTY_SET WaveRTPropertySet[]
Definition: port_wavert.cpp:63
NTSTATUS NTAPI PcNewRegistryKey(OUT PREGISTRYKEY *OutRegistryKey, IN PUNKNOWN OuterUnknown OPTIONAL, IN ULONG RegistryKeyType, IN ACCESS_MASK DesiredAccess, IN PVOID DeviceObject OPTIONAL, IN PVOID SubDevice OPTIONAL, IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, IN ULONG CreateOptions OPTIONAL, OUT PULONG Disposition OPTIONAL)
Definition: registry.cpp:268
Definition: arc.h:85
friend PMINIPORTWAVERT GetWaveRTMiniport(IN IPortWaveRT *iface)
NTSTATUS NTAPI NewIUnregisterSubdevice(OUT PUNREGISTERSUBDEVICE *OutDevice)
Definition: unregister.cpp:122
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ ULONG _Out_ PVOID PropertyBuffer
Definition: wdfdevice.h:4431
STDMETHODIMP QueryInterface(REFIID InterfaceId, PVOID *Interface)
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
PDEVICE_OBJECT GetDeviceObjectFromPortWaveRT(PPORTWAVERT iface)
PPOWERNOTIFY m_pPowerNotify
Definition: port_wavert.cpp:35
_Must_inspect_result_ _In_opt_ WDFKEY _In_ PCUNICODE_STRING _In_ ACCESS_MASK _In_ ULONG CreateOptions
Definition: wdfregistry.h:112
IResourceList * PRESOURCELIST
Definition: portcls.h:442
ISubdevice * PSUBDEVICE
Definition: interfaces.hpp:305
IN PVOID IN PVOID IN USHORT IN USHORT IN PINTERFACE Interface
Definition: pci.h:361
static GUID InterfaceGuids[3]
Definition: port_wavert.cpp:44
NTSTATUS NewPortClsVersion(OUT PPORTCLSVERSION *OutVersion)
Definition: version.cpp:71
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_ WDF_DEVICE_POWER_STATE PowerState
Definition: wdfdevice.h:3032
NTSYSAPI NTSTATUS WINAPI RtlStringFromGUID(REFGUID, PUNICODE_STRING)
#define KSPROPSETID_Pin
Definition: ks.h:617
unsigned int * PULONG
Definition: retypes.h:1
PMINIPORTWAVERT GetWaveRTMiniport(IN IPortWaveRT *iface)
PSUBDEVICE_DESCRIPTOR m_SubDeviceDescriptor
Definition: port_wavert.cpp:37
#define NULL
Definition: types.h:112
HRESULT QueryInterface([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
IPowerNotify * PPOWERNOTIFY
Definition: portcls.h:2057
#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 UNIMPLEMENTED
Definition: debug.h:115
NTSTATUS NTAPI NewIUnregisterPhysicalConnection(OUT PUNREGISTERPHYSICALCONNECTION *OutConnection)
Definition: connection.cpp:128
struct _KSEVENT_ENTRY * PKSEVENT_ENTRY
Definition: ks.h:2101
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:71
NTSTATUS NewIDrmPort(OUT PDRMPORT2 *OutPort)
Definition: drm_port.cpp:125
PMINIPORTWAVERT m_pMiniport
Definition: port_wavert.cpp:32
nsrefcnt AddRef()
ULONG ACCESS_MASK
Definition: nt_native.h:40
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68
IPortClsVersion * PPORTCLSVERSION
Definition: portcls.h:2263