KSPROPERTY_AUDIO_WAVERT_CURRENT_WRITE_POSITION

The KSPROPERTY_AUDIO_WAVERT_CURRENT_WRITE_POSITION property request specifies the current write position of the WaveRT buffer in bytes. The offload driver can use this write position information to know how much valid data is in the WaveRT buffer.

Usage Summary Table

Get Set Target Property descriptor type Property value type

No

Yes

Node via Pin instance

KSP_NODE

ULONG

Return Value

The KSPROPERTY_AUDIO_WAVERT_CURRENT_WRITE_POSITION property request returns STATUS_SUCCESS to indicate that it has completed successfully. Otherwise, the request returns an appropriate error status code.

Remarks

To better understand how to interpret the information provided by this property request, assume a circular buffer of size n bytes. The initial write position, before any data is written, is 0. Data is written to the buffer in chunks that are a multiple of WAVEFORMATEX.nBlockAlign bytes.

For example, the buffer might contain 20 ms of 16-bit PCM stereo data, sampled at 48000 Hz. So based on the description for the nBlockAlign member of the WAVEFORMATEX structure, in this example nBlockAlign = 2 * 16 / 8 = 4 bytes. This means that the length of the buffer would be 48000 * 20 / 1000 = 960 frames, or 960 * 4 = 3840 bytes.

The first Set request will specify the number of bytes were written to the buffer. And since the “write position” is expressed in bytes, a value of 1920 would specify half the buffer size, whereas a value of 3840 would indicate the full buffer size. To determine the number of new bytes written, for making subsequent Set requests, the following pseudo code shows how the calculation is performed:

if new write position > old write position:
     bytes written = new write position – old write position
if new write position < old write position, we’ve wrapped:
     bytes written = (new write position + buffer size) – old write position
if new write position = old write position, we’ve had a glitch
     log a "duplicate write position" glitch event

Requirements

Version

Windows 8

Header

Ksmedia.h

See also

WAVEFORMATEX