The IDirectSoundCaptureBuffer::Lock method 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
);
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
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 lplpvAudioPtr2 and lpdwAudioBytes2 parameters, DirectSoundCapture will not lock the wraparound portion of the buffer.
The application should read data from the pointers returned by the IDirectSoundCaptureBuffer::Lock method and then call the IDirectSoundCaptureBuffer::Unlock method 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.
Windows NT/2000: Requires Windows 2000.
Windows 95/98: Requires Windows 95 or later. Available as a redistributable for Windows 95.
Header: Declared in dsound.h.
Import Library: Use dsound.lib.