ReactOS 0.4.15-dev-7907-g95bf896
rtstream.cpp File Reference
#include "rtminiport.h"
#include "rtstream.h"
Include dependency graph for rtstream.cpp:

Go to the source code of this file.

Macros

#define STR_MODULENAME   "AC97 RT Stream: "
 

Functions

NTSTATUS CreateAC97MiniportWaveRTStream (OUT CAC97MiniportWaveRTStream **RTStream)
 
 STDMETHODIMP_ (NTSTATUS) CAC97MiniportWaveRTStream
 
_Use_decl_annotations_ STDMETHODIMP_ (VOID) CAC97MiniportWaveRTStream
 

Macro Definition Documentation

◆ STR_MODULENAME

#define STR_MODULENAME   "AC97 RT Stream: "

Definition at line 11 of file rtstream.cpp.

Function Documentation

◆ CreateAC97MiniportWaveRTStream()

NTSTATUS CreateAC97MiniportWaveRTStream ( OUT CAC97MiniportWaveRTStream **  RTStream)

Definition at line 37 of file rtstream.cpp.

41{
42 PAGED_CODE ();
43
44 DOUT (DBG_PRINT, ("[CreateAC97MiniportWaveRTStream]"));
45
46 //
47 // This is basically like the macro at stdunk with the change that we
48 // don't cast to interface unknown but to interface CAC97MiniportWaveRTStream.
49 //
51 if (*RTStream)
52 {
53 (*RTStream)->AddRef ();
54 return STATUS_SUCCESS;
55 }
56
58}
#define PAGED_CODE()
#define NULL
Definition: types.h:112
#define DOUT(lvl, strings)
Definition: debug.h:82
#define NonPagedPool
Definition: env_spec_w32.h:307
#define STATUS_SUCCESS
Definition: shellext.h:65
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _In_ _Strict_type_match_ POOL_TYPE _In_opt_ ULONG PoolTag
Definition: wdfmemory.h:164
#define DBG_PRINT(ppi, ch, level)
Definition: win32kdebug.h:168

◆ STDMETHODIMP_() [1/2]

STDMETHODIMP_ ( NTSTATUS  )

Definition at line 187 of file rtstream.cpp.

195{
196 PAGED_CODE ();
197
198 //
199 // Make sure complete samples fit into the buffer.
200 //
201 if( size <= size % (NumberOfChannels * 2) )
202 {
203 return STATUS_UNSUCCESSFUL;
204 }
205 size -= size % (NumberOfChannels * 2);
206
207 //
208 // Validate that we're going to actually allocate a real amount of memory.
209 //
210 if (0 == size)
211 {
212 DOUT (DBG_WARNING, ("Zero byte memory allocation attempted."));
213 return STATUS_UNSUCCESSFUL;
214 }
215
216 //
217 // Allocate the buffer.
218 // The AC97 has problems playing 6ch data on page breaks (a page is 4096 bytes
219 // and doesn't contain complete samples of 6ch 16bit audio data). We therefore
220 // allocate contiguous memory that fits complete 6ch 16bit samples, however,
221 // contiguous memory is a lot more expensive to get and you might not get it
222 // at all. Useing non-contiguous memory (AllocatePagesForMdl) is therefore much
223 // better if your HW does support it. It is highly recommended to build future
224 // HW so that it can map a variable amount of pages, that it can cycle through
225 // the scatter gather list automatically and that it handles that case where
226 // samples are "split" between 2 pages.
227 //
229 PHYSICAL_ADDRESS high;
230
231 low.QuadPart = 0;
232 high.HighPart = 0, high.LowPart = MAXULONG;
233 PMDL audioBufferMdl = PortStream->AllocateContiguousPagesForMdl (low, high, size);
234
235 //
236 // Check if the allocation was successful.
237 //
238 if (!audioBufferMdl)
239 {
240 DOUT (DBG_WARNING, ("[AllocateAudioBuffer] Can not allocate RT buffer."));
241 return STATUS_UNSUCCESSFUL;
242 }
243
244 //
245 // We got our memory. Program the BDL (scatter gather list) now.
246 //
247 //
248 // Note that when you use AllocatePagesForMdl that you might get less memory
249 // back. In this case you need to check the byte count of the Mdl and continue
250 // with that size.
251 //
252
253 //
254 // Store the information for portcls so that the buffer can be mapped to
255 // the client.
256 //
257 *userModeBuffer = audioBufferMdl;
258 *bufferSize = size;
259 *bufferOffset = 0;
260 *cacheType = MmCached;
261
262 //
263 // Program the BDL
264 //
265 for (UINT loop = 0; loop < MAX_BDL_ENTRIES; loop++)
266 {
267 BDList[loop].dwPtrToPhyAddress = PortStream->GetPhysicalPageAddress (audioBufferMdl, 0).LowPart;
268 BDList[loop].wLength = (WORD)size/2;
269 if ((loop == MAX_BDL_ENTRIES / 2) || (loop == MAX_BDL_ENTRIES - 1))
270 BDList[loop].wPolicyBits = IOC_ENABLE;
271 else
272 BDList[loop].wPolicyBits = 0;
273 }
274
275 return STATUS_SUCCESS;
276}
const int DBG_WARNING
Definition: debug.h:18
unsigned short WORD
Definition: ntddk_ex.h:93
size_t bufferSize
GLsizeiptr size
Definition: glext.h:5919
const USHORT IOC_ENABLE
Definition: ichreg.h:103
unsigned int UINT
Definition: ndis.h:50
const int MAX_BDL_ENTRIES
Definition: rtstream.h:24
#define MAXULONG
Definition: typedefs.h:251
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
LONGLONG QuadPart
Definition: typedefs.h:114
ULONG LowPart
Definition: typedefs.h:106
@ MmCached
Definition: mmtypes.h:130

◆ STDMETHODIMP_() [2/2]

_Use_decl_annotations_ STDMETHODIMP_ ( VOID  )

Definition at line 287 of file rtstream.cpp.

292{
293 PAGED_CODE ();
294
296
297 //
298 // Just delete the MDL that was allocated with AllocateContiguousPagesForMdl.
299 //
300 if (NULL != Mdl)
301 {
302 PortStream->FreePagesFromMdl (Mdl);
303 }
304}
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
_In_ WDFDEVICE _In_ PVOID _In_opt_ PMDL Mdl