ReactOS  0.4.14-dev-55-g2da92ac
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 IPortWaveRTStreamInit
18 {
19 public:
21 
23  {
25  return m_Ref;
26  }
28  {
30 
31  if (!m_Ref)
32  {
33  delete this;
34  return 0;
35  }
36  return m_Ref;
37  }
39  CPortWaveRTStreamInit(IUnknown *OuterUnknown) {}
41 
42 protected:
44 
45 };
46 
48 NTAPI
50  IN REFIID refiid,
51  OUT PVOID* Output)
52 {
53 
54  DPRINT("IPortWaveRTStream_fnQueryInterface entered\n");
55 
56  if (IsEqualGUIDAligned(refiid, IID_IPortWaveRTStream) ||
58  {
59  *Output = PVOID(PPORTWAVERTSTREAM(this));
60  PUNKNOWN(*Output)->AddRef();
61  return STATUS_SUCCESS;
62  }
63  return STATUS_UNSUCCESSFUL;
64 }
65 
66 
67 PMDL
68 NTAPI
69 CPortWaveRTStreamInit::AllocatePagesForMdl(
72 {
74 }
75 
76 PMDL
77 NTAPI
78 CPortWaveRTStreamInit::AllocateContiguousPagesForMdl(
79  IN PHYSICAL_ADDRESS LowAddress,
82 {
83  PMDL Mdl;
84  PVOID Buffer;
86 
88  if (!Buffer)
89  {
90  DPRINT("MmAllocateContiguousMemorySpecifyCache failed\n");
91  return NULL;
92  }
93 
95 
97 
99  if (!Mdl)
100  {
101  DPRINT("MmAllocatePagesForMdl failed\n");
102  return NULL;
103  }
104 
105  if (MmGetMdlByteCount(Mdl) < TotalBytes)
106  {
107  DPRINT("ByteCount %u Required %u\n", MmGetMdlByteCount(Mdl), TotalBytes);
108  MmFreePagesFromMdl(Mdl);
109  ExFreePool(Mdl);
110  return NULL;
111  }
112 
113  DPRINT("Result %p\n", Mdl);
114  return Mdl;
115 }
116 
117 PVOID
118 NTAPI
119 CPortWaveRTStreamInit::MapAllocatedPages(
122 {
124 }
125 
126 VOID
127 NTAPI
128 CPortWaveRTStreamInit::UnmapAllocatedPages(
131 {
133 }
134 
135 VOID
136 NTAPI
137 CPortWaveRTStreamInit::FreePagesFromMdl(
139 {
142 }
143 
144 ULONG
145 NTAPI
146 CPortWaveRTStreamInit::GetPhysicalPagesCount(
148 {
150 }
151 
153 NTAPI
154 CPortWaveRTStreamInit::GetPhysicalPageAddress(
157  IN ULONG Index)
158 {
159  PVOID Buffer;
160  ULONG Pages;
161  PHYSICAL_ADDRESS Result, Addr;
162 
164  if (Pages <= Index)
165  {
166  DPRINT("OutOfBounds: Pages %u Index %u\n", Pages, Index);
168  }
169 
171 
173  Address->QuadPart = Addr.QuadPart;
174  Result.QuadPart = (ULONG_PTR)Address;
175 
176  return Result;
177 }
178 
179 
180 NTSTATUS
182  PPORTWAVERTSTREAM *OutStream)
183 {
186  if (!This)
188 
189  Status = This->QueryInterface(IID_IPortWaveRTStream, (PVOID*)OutStream);
190 
191  if (!NT_SUCCESS(Status))
192  {
193  delete This;
194  return Status;
195  }
196 
197  *OutStream = (PPORTWAVERTSTREAM)This;
198  return Status;
199 }
IPortWaveRTStream * PPORTWAVERTSTREAM
Definition: portcls.h:1791
#define IN
Definition: typedefs.h:38
#define REFIID
Definition: guiddef.h:118
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ BOOLEAN Release
Definition: classpnp.h:929
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)
STDMETHODIMP_(ULONG) Release()
#define IsEqualGUIDAligned(guid1, guid2)
Definition: wdm.template.h:233
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
_Inout_ PMDL MemoryDescriptorList
Definition: mmfuncs.h:406
long LONG
Definition: pedump.c:60
VOID NTAPI MmUnmapLockedPages(IN PVOID BaseAddress, IN PMDL Mdl)
Definition: mdlsup.c:841
VOID NTAPI MmFreePagesFromMdl(IN PMDL Mdl)
Definition: mdlsup.c:568
#define STDMETHODIMP
Definition: basetyps.h:43
smooth NULL
Definition: ftsmooth.c:416
_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
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
void * PVOID
Definition: retypes.h:9
#define ADDRESS_AND_SIZE_TO_SPAN_PAGES(_Va, _Size)
IN PVOID IN PVOID IN USHORT IN USHORT IN PINTERFACE Interface
Definition: pci.h:359
NTSYSAPI ULONGLONG WINAPI RtlConvertUlongToLargeInteger(ULONG)
Definition: largeint.c:47
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID * BaseAddress
Definition: mmfuncs.h:404
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
const GUID IID_IUnknown
static const UCHAR Index[8]
Definition: usbohci.c:18
ULONG AddRef()
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define InterlockedDecrement
Definition: armddk.h:52
Definition: arc.h:85
#define PAGE_SIZE
Definition: env_spec_w32.h:49
Status
Definition: gdiplustypes.h:24
ULONG_PTR SIZE_T
Definition: typedefs.h:78
#define InterlockedIncrement
Definition: armddk.h:53
PVOID NTAPI MmMapLockedPagesSpecifyCache(IN PMDL Mdl, IN KPROCESSOR_MODE AccessMode, IN MEMORY_CACHING_TYPE CacheType, IN PVOID BaseAddress, IN ULONG BugCheckOnFailure, IN MM_PAGE_PRIORITY Priority)
Definition: mdlsup.c:664
_Must_inspect_result_ _In_ PHYSICAL_ADDRESS HighAddress
Definition: mmfuncs.h:226
STDMETHODIMP QueryInterface(REFIID InterfaceId, PVOID *Interface)
#define MmGetMdlByteCount(_Mdl)
CPortWaveRTStreamInit(IUnknown *OuterUnknown)
static ULONG WINAPI AddRef(IStream *iface)
Definition: clist.c:90
VOID NTAPI MmFreeContiguousMemorySpecifyCache(IN PVOID BaseAddress, IN SIZE_T NumberOfBytes, IN MEMORY_CACHING_TYPE CacheType)
Definition: contmem.c:661
#define OUT
Definition: typedefs.h:39
unsigned int ULONG
Definition: retypes.h:1
#define ULONG_PTR
Definition: config.h:101
PHYSICAL_ADDRESS NTAPI MmGetPhysicalAddress(IN PVOID Address)
Definition: stubs.c:682
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
enum _MEMORY_CACHING_TYPE MEMORY_CACHING_TYPE
return STATUS_SUCCESS
Definition: btrfs.c:2966
PMDL NTAPI MmAllocatePagesForMdl(IN PHYSICAL_ADDRESS LowAddress, IN PHYSICAL_ADDRESS HighAddress, IN PHYSICAL_ADDRESS SkipBytes, IN SIZE_T TotalBytes)
Definition: mdlsup.c:493
STDMETHODIMP_(ULONG) AddRef()
#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:112
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:569