The Lock method locks a portion of the buffer. Locking the buffer returns pointers into the buffer, allowing the application to read or write audio data into memory.
HRESULT Lock( DWORD dwOffset, DWORD dwBytes, LPVOID * ppvAudioPtr1, LPDWORD pdwAudioBytes1, LPVOID * ppvAudioPtr2, LPDWORD pdwAudioBytes2, DWORD dwFlags );
Value | Description |
DSCBLOCK_ENTIREBUFFER | Ignore dwBytes and lock the entire capture buffer. |
If the method succeeds, the return value is DS_OK. If the method fails, the return value may be one of the following values:
Return code |
DSERR_INVALIDPARAM |
DSERR_INVALIDCALL |
This method accepts an offset and a byte count, and returns two read pointers and their associated sizes. If the locked portion does not extend to the end of the buffer and wrap to the beginning, the second pointer, ppvAudioBytes2, receives NULL. If the lock does wrap, ppvAudioBytes2 points to the beginning of the buffer.
If the application passes NULL for the ppvAudioPtr2 and pdwAudioBytes2 parameters, the lock extends no further than the end of the buffer and does not wrap.
The application should read data from the pointers returned by this method and then immediately call Unlock. The sound buffer should not remain locked while it is running; if it does, the capture cursor will reach the locked bytes and audio problems may result.
Header: Declared in Dsound.h.
Import Library: Use Dsound3d.dll.