Microsoft Windows CE 3.0  

IDirectSoundCaptureBuffer::Lock

Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

The IDirectSoundCaptureBuffer::Lockmethod locks the buffer. Locking the buffer returns pointers into the buffer, allowing the application to read or write audio data into that memory.

HRESULT Lock(
DWORD
dwReadCursor
,
DWORD
dwReadBytes
,
LPVOID

*
lplpvAudioPtr1
,
LPDWORD
lpdwAudioBytes1
,
LPVOID

*
lplpvAudioPtr2
,
LPDWORD
lpdwAudioBytes2
,
DWORD
dwFlags
);

Parameters

dwReadCursor
Offset, in bytes, from the start of the buffer to where the lock begins.
dwReadBytes
Size, in bytes, of the portion of the buffer to lock. Note that the capture buffer is conceptually circular.
lplpvAudioPtr1
Address of a pointer to contain the first block of the capture buffer to be locked.
lpdwAudioBytes1
Address of a variable to contain the number of bytes pointed to by the lplpvAudioPtr1parameter. If this value is less than the dwReadBytesparameter, lplpvAudioPtr2will point to a second block of data.
lplpvAudioPtr2
Address of a pointer to contain the second block of the capture buffer to be locked. If the value of this parameter is NULL, the lplpvAudioPtr1parameter points to the entire locked portion of the capture buffer.
lpdwAudioBytes2
Address of a variable to contain the number of bytes pointed to by the lplpvAudioPtr2parameter. If lplpvAudioPtr2is NULL, this value will be 0.
dwFlags
Flags modifying the lock event. This value can be zero or the following flag:
Flag Description
DSCBLOCK_ENTIREBUFFER The dwReadBytesparameter is to be ignored and the entire capture buffer is to be locked.

Return Values

If the method succeeds, the return value is DS_OK.

If the method fails, the return value may be one of the following values:

DSERR_INVALIDPARAM
DSERR_INVALIDCALL

Remarks

This method accepts an offset and a byte count, and returns two read pointers and their associated sizes. Two pointers are required because capture buffers are circular. If the locked bytes do not wrap around the end of the buffer, the second pointer, lplpvAudioBytes2, will be NULL. However, if the bytes do wrap around, then the second pointer will point to the beginning of the buffer.

If the application passes NULL for the lplpvAudioPtr2and lpdwAudioBytes2parameters, DirectSoundCapture will not lock the wraparound portion of the buffer.

The application should read data from the pointers returned by the IDirectSoundCaptureBuffer::Lockmethod and then call the IDirectSoundCaptureBuffer::Unlockmethod to release the buffer back to DirectSoundCapture. The sound buffer should not be locked for long periods of time; if it is, the capture cursor will reach the locked bytes and configuration-dependent audio problems may result.

Requirements

Runs On Versions Defined in Include Link to
Windows CE OS 2.12 or later. Version 2.12 requires DXPAK 1.0 or later. dsound.h   dsound.lib
Note   This API is part of the complete Windows CE OS package as provided by Microsoft. The functionality of a particular platform is determined by the original equipment manufacturer (OEM) and some devices may not support this API.