ReactOS  0.4.15-dev-4917-g934e521
port_wavertstream.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_wavertstream.cpp
5  * PURPOSE: WaveRTStream helper object
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 CPortWaveRTStreamInit : public CUnknownImpl<IPortWaveRTStreamInit>
18 {
19 public:
21 
23  CPortWaveRTStreamInit(IUnknown *OuterUnknown) {}
25 
26 };
27 
29 NTAPI
31  IN REFIID refiid,
32  OUT PVOID* Output)
33 {
34 
35  DPRINT("IPortWaveRTStream_fnQueryInterface entered\n");
36 
37  if (IsEqualGUIDAligned(refiid, IID_IPortWaveRTStream) ||
39  {
40  *Output = PVOID(PPORTWAVERTSTREAM(this));
41  PUNKNOWN(*Output)->AddRef();
42  return STATUS_SUCCESS;
43  }
44  return STATUS_UNSUCCESSFUL;
45 }
46 
47 
48 PMDL
49 NTAPI
50 CPortWaveRTStreamInit::AllocatePagesForMdl(
53 {
55 }
56 
57 PMDL
58 NTAPI
59 CPortWaveRTStreamInit::AllocateContiguousPagesForMdl(
60  IN PHYSICAL_ADDRESS LowAddress,
63 {
64  PMDL Mdl;
65  PVOID Buffer;
67 
69  if (!Buffer)
70  {
71  DPRINT("MmAllocateContiguousMemorySpecifyCache failed\n");
72  return NULL;
73  }
74 
76 
78 
80  if (!Mdl)
81  {
82  DPRINT("MmAllocatePagesForMdl failed\n");
83  return NULL;
84  }
85 
87  {
88  DPRINT("ByteCount %u Required %u\n", MmGetMdlByteCount(Mdl), TotalBytes);
90  ExFreePool(Mdl);
91  return NULL;
92  }
93 
94  DPRINT("Result %p\n", Mdl);
95  return Mdl;
96 }
97 
98 PVOID
99 NTAPI
100 CPortWaveRTStreamInit::MapAllocatedPages(
103 {
105 }
106 
107 VOID
108 NTAPI
109 CPortWaveRTStreamInit::UnmapAllocatedPages(
112 {
114 }
115 
116 VOID
117 NTAPI
118 CPortWaveRTStreamInit::FreePagesFromMdl(
120 {
123 }
124 
125 ULONG
126 NTAPI
127 CPortWaveRTStreamInit::GetPhysicalPagesCount(
129 {
131 }
132 
134 NTAPI
135 CPortWaveRTStreamInit::GetPhysicalPageAddress(
138  IN ULONG Index)
139 {
140  PVOID Buffer;
141  ULONG Pages;
142  PHYSICAL_ADDRESS Result, Addr;
143 
145  if (Pages <= Index)
146  {
147  DPRINT("OutOfBounds: Pages %u Index %u\n", Pages, Index);
149  }
150 
152 
154  Address->QuadPart = Addr.QuadPart;
155  Result.QuadPart = (ULONG_PTR)Address;
156 
157  return Result;
158 }
159 
160 
161 NTSTATUS
163  PPORTWAVERTSTREAM *OutStream)
164 {
167  if (!This)
169 
170  Status = This->QueryInterface(IID_IPortWaveRTStream, (PVOID*)OutStream);
171 
172  if (!NT_SUCCESS(Status))
173  {
174  delete This;
175  return Status;
176  }
177 
178  *OutStream = (PPORTWAVERTSTREAM)This;
179  return Status;
180 }
IPortWaveRTStream * PPORTWAVERTSTREAM
Definition: portcls.h:1845
#define IN
Definition: typedefs.h:39
#define REFIID
Definition: guiddef.h:118
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
IUnknown * PUNKNOWN
Definition: com_apitest.h:45
#define TAG_PORTCLASS
Definition: private.hpp:24
unsigned char * PUCHAR
Definition: retypes.h:3
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NewPortWaveRTStream(PPORTWAVERTSTREAM *OutStream)
#define MmGetSystemAddressForMdlSafe(_Mdl, _Priority)
#define IsEqualGUIDAligned(guid1, guid2)
Definition: wdm.template.h:235
PVOID NTAPI MmMapLockedPagesSpecifyCache(IN PMDL Mdl, IN KPROCESSOR_MODE AccessMode, IN MEMORY_CACHING_TYPE CacheType, IN PVOID BaseAddress, IN ULONG BugCheckOnFailure, IN ULONG Priority)
Definition: mdlsup.c:660
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
_Inout_ PMDL MemoryDescriptorList
Definition: mmfuncs.h:405
VOID NTAPI MmUnmapLockedPages(IN PVOID BaseAddress, IN PMDL Mdl)
Definition: mdlsup.c:837
VOID NTAPI MmFreePagesFromMdl(IN PMDL Mdl)
Definition: mdlsup.c:564
#define STDMETHODIMP
Definition: basetyps.h:43
_Must_inspect_result_ _In_ PHYSICAL_ADDRESS _In_ PHYSICAL_ADDRESS _In_opt_ PHYSICAL_ADDRESS _In_ MEMORY_CACHING_TYPE CacheType
Definition: mmfuncs.h:214
static WCHAR Address[46]
Definition: ping.c:68
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
Definition: bufpool.h:45
void * PVOID
Definition: retypes.h:9
#define ADDRESS_AND_SIZE_TO_SPAN_PAGES(_Va, _Size)
Status
Definition: gdiplustypes.h:24
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID * BaseAddress
Definition: mmfuncs.h:404
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_In_ WDFCOLLECTION _In_ ULONG Index
const GUID IID_IUnknown
ULONG AddRef()
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
Definition: arc.h:85
#define PAGE_SIZE
Definition: env_spec_w32.h:49
ULONG_PTR SIZE_T
Definition: typedefs.h:80
NTSYSAPI ULONGLONG WINAPI RtlConvertUlongToLargeInteger(ULONG)
Definition: largeint.c:47
IN PVOID IN PVOID IN USHORT IN USHORT IN PINTERFACE Interface
Definition: pci.h:361
_Must_inspect_result_ _In_ PHYSICAL_ADDRESS HighAddress
Definition: mmfuncs.h:226
STDMETHODIMP QueryInterface(REFIID InterfaceId, PVOID *Interface)
#define MmGetMdlByteCount(_Mdl)
CPortWaveRTStreamInit(IUnknown *OuterUnknown)
#define NULL
Definition: types.h:112
_In_ WDFDEVICE _In_ PVOID _In_opt_ PMDL Mdl
VOID NTAPI MmFreeContiguousMemorySpecifyCache(IN PVOID BaseAddress, IN SIZE_T NumberOfBytes, IN MEMORY_CACHING_TYPE CacheType)
Definition: contmem.c:666
#define OUT
Definition: typedefs.h:40
unsigned int ULONG
Definition: retypes.h:1
#define ULONG_PTR
Definition: config.h:101
PHYSICAL_ADDRESS NTAPI MmGetPhysicalAddress(IN PVOID Address)
Definition: stubs.c:685
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:71
enum _MEMORY_CACHING_TYPE MEMORY_CACHING_TYPE
PMDL NTAPI MmAllocatePagesForMdl(IN PHYSICAL_ADDRESS LowAddress, IN PHYSICAL_ADDRESS HighAddress, IN PHYSICAL_ADDRESS SkipBytes, IN SIZE_T TotalBytes)
Definition: mdlsup.c:489
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
_Must_inspect_result_ _In_ PHYSICAL_ADDRESS _In_ PHYSICAL_ADDRESS _In_ SIZE_T TotalBytes
Definition: mmfuncs.h:226
LONGLONG QuadPart
Definition: typedefs.h:114
PVOID NTAPI MmAllocateContiguousMemorySpecifyCache(IN SIZE_T NumberOfBytes, IN PHYSICAL_ADDRESS LowestAcceptableAddress OPTIONAL, IN PHYSICAL_ADDRESS HighestAcceptableAddress, IN PHYSICAL_ADDRESS BoundaryAddressMultiple OPTIONAL, IN MEMORY_CACHING_TYPE CacheType OPTIONAL)
Definition: contmem.c:574