ReactOS 0.4.15-dev-8096-ga0eec98
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#define NDEBUG
12#include <debug.h>
13
14class CPortWaveRT : public CUnknownImpl<IPortWaveRT, IPortEvents, ISubdevice>
15{
16public:
18
22 CPortWaveRT(IUnknown *OuterUnknown) {}
23 virtual ~CPortWaveRT() {}
24
25protected:
26
35 IPortFilterWaveRT * m_Filter;
36
37 friend PMINIPORTWAVERT GetWaveRTMiniport(IN IPortWaveRT* iface);
39};
40
42{
43 {
45 0x6994AD04, 0x93EF, 0x11D0, {0xA3, 0xCC, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96}
46 },
47 {
49 0x65E8773EL, 0x8F56, 0x11D0, {0xA3, 0xB9, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96}
50 },
51 {
53 0x65E8773DL, 0x8F56, 0x11D0, {0xA3, 0xB9, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96}
54 }
55};
56
59
60KSPROPERTY_SET WaveRTPropertySet[] =
61{
62 {
64 sizeof(PortFilterWaveRTTopologySet) / sizeof(KSPROPERTY_ITEM),
65 (const KSPROPERTY_ITEM*)&PortFilterWaveRTTopologySet,
66 0,
67 NULL
68 },
69 {
71 sizeof(PortFilterWaveRTPinSet) / sizeof(KSPROPERTY_ITEM),
72 (const KSPROPERTY_ITEM*)&PortFilterWaveRTPinSet,
73 0,
74 NULL
75 }
76};
77
78//KSEVENTSETID_LoopedStreaming, Type = KSEVENT_LOOPEDSTREAMING_POSITION
79//KSEVENTSETID_Connection, Type = KSEVENT_CONNECTION_ENDOFSTREAM,
80
81//---------------------------------------------------------------
82// IPortEvents
83//
84
85void
87CPortWaveRT::AddEventToEventList(
88 IN PKSEVENT_ENTRY EventEntry)
89{
91}
92
93void
95CPortWaveRT::GenerateEventList(
97 IN ULONG EventId,
98 IN BOOL PinEvent,
99 IN ULONG PinId,
100 IN BOOL NodeEvent,
101 IN ULONG NodeId)
102{
104}
105
106//---------------------------------------------------------------
107// IUnknown interface functions
108//
109
111NTAPI
113 IN REFIID refiid,
115{
117
118 if (IsEqualGUIDAligned(refiid, IID_IPortWaveRT) ||
120 {
121 *Output = PVOID(PPORTWAVERT(this));
122 PUNKNOWN(*Output)->AddRef();
123 return STATUS_SUCCESS;
124 }
125 else if (IsEqualGUIDAligned(refiid, IID_IPortEvents))
126 {
127 *Output = PVOID(PPORTEVENTS(this));
128 PUNKNOWN(*Output)->AddRef();
129 return STATUS_SUCCESS;
130 }
131 else if (IsEqualGUIDAligned(refiid, IID_ISubdevice))
132 {
133 *Output = PVOID(PSUBDEVICE(this));
134 PUNKNOWN(*Output)->AddRef();
135 return STATUS_SUCCESS;
136 }
137 else if (IsEqualGUIDAligned(refiid, IID_IPortClsVersion))
138 {
140 }
141 else if (IsEqualGUIDAligned(refiid, IID_IDrmPort) ||
142 IsEqualGUIDAligned(refiid, IID_IDrmPort2))
143 {
144 return NewIDrmPort((PDRMPORT2*)Output);
145 }
146 else if (IsEqualGUIDAligned(refiid, IID_IUnregisterSubdevice))
147 {
149 }
150 else if (IsEqualGUIDAligned(refiid, IID_IUnregisterPhysicalConnection))
151 {
153 }
154
156 {
157 DPRINT("IPortWaveRT_fnQueryInterface no interface!!! iface %S\n", GuidString.Buffer);
159 }
160
161 return STATUS_UNSUCCESSFUL;
162}
163//---------------------------------------------------------------
164// IPort interface functions
165//
166
168NTAPI
169CPortWaveRT::GetDeviceProperty(
170 IN DEVICE_REGISTRY_PROPERTY DeviceRegistryProperty,
174{
176
177 if (!m_bInitialized)
178 {
179 DPRINT("IPortWaveRT_fnNewRegistryKey called w/o initialized\n");
180 return STATUS_UNSUCCESSFUL;
181 }
182
184}
185
187NTAPI
188CPortWaveRT::Init(
190 IN PIRP Irp,
191 IN PUNKNOWN UnknownMiniport,
192 IN PUNKNOWN UnknownAdapter OPTIONAL,
194{
195 IMiniportWaveRT * Miniport;
198 PPOWERNOTIFY PowerNotify;
199
200 DPRINT("IPortWaveRT_Init entered %p\n", this);
202
203 if (m_bInitialized)
204 {
205 DPRINT("IPortWaveRT_Init called again\n");
206 return STATUS_SUCCESS;
207 }
208
209 Status = UnknownMiniport->QueryInterface(IID_IMiniportWaveRT, (PVOID*)&Miniport);
210 if (!NT_SUCCESS(Status))
211 {
212 DPRINT("IPortWaveRT_Init called with invalid IMiniport adapter\n");
214 }
215
216 // Initialize port object
217 m_pMiniport = Miniport;
221
222 // increment reference on miniport adapter
223 Miniport->AddRef();
224
225 Status = Miniport->Init(UnknownAdapter, ResourceList, this);
226 if (!NT_SUCCESS(Status))
227 {
228 DPRINT("IMiniportWaveRT_Init failed with %x\n", Status);
229 Miniport->Release();
231 return Status;
232 }
233
234 // get the miniport device descriptor
235 Status = Miniport->GetDescription(&m_pDescriptor);
236 if (!NT_SUCCESS(Status))
237 {
238 DPRINT("failed to get description\n");
239 Miniport->Release();
241 return Status;
242 }
243
244 // create the subdevice descriptor
246 3,
248 0,
249 NULL,
250 2,
252 0,
253 0,
254 0,
255 NULL,
256 0,
257 NULL,
259
260 if (!NT_SUCCESS(Status))
261 {
262 DPRINT("PcCreateSubdeviceDescriptor failed with %x\n", Status);
263 Miniport->Release();
265 return Status;
266 }
267
268 // check if it supports IPinCount interface
269 Status = UnknownMiniport->QueryInterface(IID_IPinCount, (PVOID*)&PinCount);
270 if (NT_SUCCESS(Status))
271 {
272 // store IPinCount interface
274 }
275
276 // does the Miniport adapter support IPowerNotify interface*/
277 Status = UnknownMiniport->QueryInterface(IID_IPowerNotify, (PVOID*)&PowerNotify);
278 if (NT_SUCCESS(Status))
279 {
280 // store reference
281 m_pPowerNotify = PowerNotify;
282 }
283
284 // increment reference on resource list
286
287 DPRINT("IPortWaveRT successfully initialized\n");
288 return STATUS_SUCCESS;
289}
290
292NTAPI
293CPortWaveRT::NewRegistryKey(
294 OUT PREGISTRYKEY *OutRegistryKey,
295 IN PUNKNOWN OuterUnknown OPTIONAL,
296 IN ULONG RegistryKeyType,
301{
303
304 if (!m_bInitialized)
305 {
306 DPRINT("IPortWaveRT_fnNewRegistryKey called w/o initialized\n");
307 return STATUS_UNSUCCESSFUL;
308 }
309 return PcNewRegistryKey(OutRegistryKey, OuterUnknown, RegistryKeyType, DesiredAccess, m_pDeviceObject, (ISubdevice*)this, ObjectAttributes, CreateOptions, Disposition);
310}
311//---------------------------------------------------------------
312// ISubdevice interface
313//
314
316NTAPI
317CPortWaveRT::NewIrpTarget(
318 OUT struct IIrpTarget **OutTarget,
319 IN PCWSTR Name,
323 IN PIRP Irp,
324 IN KSOBJECT_CREATE *CreateObject)
325{
327 IPortFilterWaveRT * Filter;
328
329 DPRINT("ISubDevice_NewIrpTarget this %p\n", this);
330
331 if (m_Filter)
332 {
333 *OutTarget = (IIrpTarget*)m_Filter;
334 return STATUS_SUCCESS;
335 }
336
338 if (!NT_SUCCESS(Status))
339 {
340 return Status;
341 }
342
343 Status = Filter->Init(this);
344 if (!NT_SUCCESS(Status))
345 {
346 Filter->Release();
347 return Status;
348 }
349
350 *OutTarget = (IIrpTarget*)Filter;
352 return Status;
353}
354
356NTAPI
357CPortWaveRT::ReleaseChildren()
358{
360 return STATUS_UNSUCCESSFUL;
361}
362
364NTAPI
365CPortWaveRT::GetDescriptor(
367{
369
371
372 DPRINT("ISubDevice_GetDescriptor this %p desc %p\n", this, m_SubDeviceDescriptor);
373 return STATUS_SUCCESS;
374}
375
377NTAPI
378CPortWaveRT::DataRangeIntersection(
379 IN ULONG PinId,
380 IN PKSDATARANGE DataRange,
381 IN PKSDATARANGE MatchingDataRange,
383 OUT PVOID ResultantFormat OPTIONAL,
384 OUT PULONG ResultantFormatLength)
385{
386 DPRINT("ISubDevice_DataRangeIntersection this %p\n", this);
387
388 if (m_pMiniport)
389 {
390 return m_pMiniport->DataRangeIntersection (PinId, DataRange, MatchingDataRange, OutputBufferLength, ResultantFormat, ResultantFormatLength);
391 }
392
393 return STATUS_UNSUCCESSFUL;
394}
395
397NTAPI
398CPortWaveRT::PowerChangeNotify(
400{
401 if (m_pPowerNotify)
402 {
403 m_pPowerNotify->PowerChangeNotify(PowerState);
404 }
405
406 return STATUS_SUCCESS;
407}
408
410NTAPI
411CPortWaveRT::PinCount(
412 IN ULONG PinId,
413 IN OUT PULONG FilterNecessary,
414 IN OUT PULONG FilterCurrent,
415 IN OUT PULONG FilterPossible,
416 IN OUT PULONG GlobalCurrent,
417 IN OUT PULONG GlobalPossible)
418{
419 if (m_pPinCount)
420 {
421 m_pPinCount->PinCount(PinId, FilterNecessary, FilterCurrent, FilterPossible, GlobalCurrent, GlobalPossible);
422 return STATUS_SUCCESS;
423 }
424
425 // FIXME
426 // scan filter descriptor
427
428 return STATUS_UNSUCCESSFUL;
429}
430
434 IN IPortWaveRT* iface)
435{
436 CPortWaveRT * This = (CPortWaveRT *)iface;
437 return This->m_pMiniport;
438}
439
442 PPORTWAVERT iface)
443{
444 CPortWaveRT * This = (CPortWaveRT *)iface;
445 return This->m_pDeviceObject;
446}
447
448//---------------------------------------------------------------
449// IPortWaveRT constructor
450//
451
454 OUT PPORT* OutPort)
455{
458
460 if (!Port)
462
463 Status = Port->QueryInterface(IID_IPort, (PVOID*)OutPort);
464
465 if (!NT_SUCCESS(Status))
466 {
467 delete Port;
468 }
469
470 DPRINT("NewPortWaveRT %p Status %u\n", Port, Status);
471 return Status;
472}
IPortWaveRT * PPORTWAVERT
Definition: interfaces.hpp:681
ISubdevice * PSUBDEVICE
Definition: interfaces.hpp:307
LONG NTSTATUS
Definition: precomp.h:26
#define STDMETHODIMP
Definition: basetyps.h:43
const GUID IID_IUnknown
#define UNIMPLEMENTED
Definition: debug.h:118
BOOL m_bInitialized
Definition: port_wavert.cpp:27
friend PMINIPORTWAVERT GetWaveRTMiniport(IN IPortWaveRT *iface)
PRESOURCELIST m_pResourceList
Definition: port_wavert.cpp:30
CPortWaveRT(IUnknown *OuterUnknown)
Definition: port_wavert.cpp:22
STDMETHODIMP QueryInterface(REFIID InterfaceId, PVOID *Interface)
PPOWERNOTIFY m_pPowerNotify
Definition: port_wavert.cpp:32
friend PDEVICE_OBJECT GetDeviceObjectFromPortWaveRT(PPORTWAVERT iface)
PPINCOUNT m_pPinCount
Definition: port_wavert.cpp:31
PMINIPORTWAVERT m_pMiniport
Definition: port_wavert.cpp:29
PDEVICE_OBJECT m_pDeviceObject
Definition: port_wavert.cpp:28
PPCFILTER_DESCRIPTOR m_pDescriptor
Definition: port_wavert.cpp:33
virtual ~CPortWaveRT()
Definition: port_wavert.cpp:23
IPortFilterWaveRT * m_Filter
Definition: port_wavert.cpp:35
PSUBDEVICE_DESCRIPTOR m_SubDeviceDescriptor
Definition: port_wavert.cpp:34
IUnknown * PUNKNOWN
Definition: com_apitest.h:45
NTSTATUS NTAPI NewIUnregisterPhysicalConnection(OUT PUNREGISTERPHYSICALCONNECTION *OutConnection)
Definition: connection.cpp:124
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
_In_ PIRP Irp
Definition: csq.h:116
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define DEFINE_KSPROPERTY_PINPROPOSEDATAFORMAT(PinSet, PropGeneral, PropInstances, PropIntersection)
Definition: precomp.h:20
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:264
NTSTATUS NewIDrmPort(OUT PDRMPORT2 *OutPort)
Definition: drm_port.cpp:122
IN CINT OUT PVOID IN ULONG OUT PULONG ReturnLength
Definition: dumpinfo.c:43
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
#define NonPagedPool
Definition: env_spec_w32.h:307
unsigned int BOOL
Definition: ntddk_ex.h:94
NTSTATUS NewPortFilterWaveRT(OUT IPortFilterWaveRT **OutFilter)
_Must_inspect_result_ _In_opt_ PFLT_FILTER Filter
Definition: fltkernel.h:1801
Status
Definition: gdiplustypes.h:25
CPPORT Port[4]
Definition: headless.c:35
@ Unknown
Definition: i8042prt.h:114
NTSYSAPI NTSTATUS WINAPI RtlStringFromGUID(REFGUID, PUNICODE_STRING)
ULONG AddRef()
HRESULT QueryInterface([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
nsrefcnt AddRef()
nsrefcnt Release()
#define KSPROPSETID_Pin
Definition: ks.h:617
#define DEFINE_KSPROPERTY_TOPOLOGYSET(TopologySet, Handler)
Definition: ks.h:2663
struct _KSEVENT_ENTRY * PKSEVENT_ENTRY
Definition: ks.h:2101
#define KSPROPSETID_Topology
Definition: ks.h:842
static PWSTR GuidString
Definition: apphelp.c:93
_In_ ACCESS_MASK _In_ POBJECT_ATTRIBUTES _Reserved_ ULONG _In_opt_ PUNICODE_STRING _In_ ULONG _Out_opt_ PULONG Disposition
Definition: cmfuncs.h:56
ULONG ACCESS_MASK
Definition: nt_native.h:40
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
static BOOL Set
Definition: pageheap.c:10
NTSTATUS NTAPI IoGetDeviceProperty(IN PDEVICE_OBJECT DeviceObject, IN DEVICE_REGISTRY_PROPERTY DeviceProperty, IN ULONG BufferLength, OUT PVOID PropertyBuffer, OUT PULONG ResultLength)
Definition: pnpmgr.c:1382
PMINIPORTWAVERT GetWaveRTMiniport(IN IPortWaveRT *iface)
NTSTATUS NewPortWaveRT(OUT PPORT *OutPort)
static GUID InterfaceGuids[3]
Definition: port_wavert.cpp:41
PDEVICE_OBJECT GetDeviceObjectFromPortWaveRT(PPORTWAVERT iface)
KSPROPERTY_SET WaveRTPropertySet[]
Definition: port_wavert.cpp:60
IRegistryKey * PREGISTRYKEY
Definition: portcls.h:1009
IMiniportWaveRT * PMINIPORTWAVERT
Definition: portcls.h:1983
IPinCount * PPINCOUNT
Definition: portcls.h:2091
IResourceList * PRESOURCELIST
Definition: portcls.h:442
IPortEvents * PPORTEVENTS
Definition: portcls.h:2121
IUnregisterSubdevice * PUNREGISTERSUBDEVICE
Definition: portcls.h:635
IPortClsVersion * PPORTCLSVERSION
Definition: portcls.h:2263
IUnregisterPhysicalConnection * PUNREGISTERPHYSICALCONNECTION
Definition: portcls.h:677
IDrmPort2 * PDRMPORT2
Definition: portcls.h:2228
IPowerNotify * PPOWERNOTIFY
Definition: portcls.h:2059
IPort * PPORT
Definition: portcls.h:1105
NTSTATUS NTAPI PinPropertyHandler(IN PIRP Irp, IN PKSIDENTIFIER Request, IN OUT PVOID Data)
NTSTATUS NTAPI NewIUnregisterSubdevice(OUT PUNREGISTERSUBDEVICE *OutDevice)
Definition: unregister.cpp:119
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:717
#define PC_ASSERT_IRQL_EQUAL(x)
Definition: private.hpp:31
NTSTATUS NewPortClsVersion(OUT PPORTCLSVERSION *OutVersion)
Definition: version.cpp:66
NTSTATUS NTAPI TopologyPropertyHandler(IN PIRP Irp, IN PKSIDENTIFIER Request, IN OUT PVOID Data)
#define TAG_PORTCLASS
Definition: private.hpp:24
#define PC_ASSERT(exp)
Definition: private.hpp:26
#define REFIID
Definition: guiddef.h:118
@ Output
Definition: arc.h:85
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:73
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68
_In_ const GUID _In_ ULONG PinCount
Definition: strmini.h:505
uint32_t * PULONG
Definition: typedefs.h:59
const uint16_t * PCWSTR
Definition: typedefs.h:57
INT POOL_TYPE
Definition: typedefs.h:78
#define NTAPI
Definition: typedefs.h:36
void * PVOID
Definition: typedefs.h:50
#define IN
Definition: typedefs.h:39
uint32_t ULONG
Definition: typedefs.h:59
#define OUT
Definition: typedefs.h:40
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_Must_inspect_result_ _In_ WDFDEVICE _In_ ULONG _In_ ACCESS_MASK DesiredAccess
Definition: wdfdevice.h:2658
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ _Strict_type_match_ POOL_TYPE PoolType
Definition: wdfdevice.h:3815
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ ULONG _Out_ PVOID PropertyBuffer
Definition: wdfdevice.h:4437
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG BufferLength
Definition: wdfdevice.h:3771
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_ WDF_DEVICE_POWER_STATE PowerState
Definition: wdfdevice.h:3034
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID _Out_ PINTERFACE Interface
Definition: wdffdo.h:465
_In_ WDFREQUEST _In_ size_t OutputBufferLength
Definition: wdfio.h:320
_Must_inspect_result_ _In_opt_ WDFKEY _In_ PCUNICODE_STRING _In_ ACCESS_MASK _In_ ULONG CreateOptions
Definition: wdfregistry.h:118
_Must_inspect_result_ _In_ WDFIORESREQLIST _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFIORESLIST * ResourceList
Definition: wdfresource.h:309
_Must_inspect_result_ _In_ WDFIORESLIST _In_ PIO_RESOURCE_DESCRIPTOR Descriptor
Definition: wdfresource.h:342
#define IsEqualGUIDAligned(guid1, guid2)
Definition: wdm.template.h:235
DEVICE_REGISTRY_PROPERTY
Definition: iotypes.h:1194