Gives the caller access to the memory in the buffer, for reading or writing
HRESULT Lock( BYTE **ppbBuffer, DWORD *pcbMaxLength, DWORD *pcbCurrentLength );
Receives a pointer to the start of the buffer.
Receives the maximum amount of data that can be written to the buffer. This parameter can be NULL. The same value is returned by the IMFMediaBuffer::GetMaxLength method.
Receives the length of the valid data in the buffer, in bytes. This parameter can be NULL. The same value is returned by the IMFMediaBuffer::GetCurrentLength method.
The method returns an HRESULT. Possible values include, but are not limited to, those in the following table.
||The method succeeded.|
||For Direct3D surface buffers, an error occurred when locking the surface.|
||The buffer cannot be locked at this time.|
This method gives the caller access to the entire buffer, up to the maximum size returned in the pcbMaxLength parameter. The value returned in pcbCurrentLength is the size of any valid data already in the buffer, which might be less than the total buffer size.
The pointer returned in ppbBuffer is guaranteed to be valid, and can safely be accessed across the entire buffer for as long as the lock is held. When you are done accessing the buffer, call IMFMediaBuffer::Unlock to unlock the buffer. You must call Unlock once for each call to Lock. After you unlock the buffer, the pointer returned in ppbBuffer is no longer valid, and should not be used. Generally, it is best to call Lock only when you need to access the buffer memory, and not earlier.
Locking the buffer does not prevent other threads from calling Lock, so you should not rely on this method to synchronize threads.
This method does not allocate any memory, or transfer ownership of the memory to the caller. Do not release or free the memory; the media buffer will free the memory when the media buffer is destroyed.
If you modify the contents of the buffer, update the current length by calling IMFMediaBuffer::SetCurrentLength.
If the buffer supports the IMF2DBuffer interface, you should use the IMF2DBuffer::Lock2D method to lock the buffer. For 2-D buffers, the Lock2D method is more efficient than the Lock method. If the buffer is locked using Lock2D, the Lock method might return MF_E_INVALIDREQUEST.
This interface is available on the following platforms if the Windows Media Format 11 SDK redistributable components are installed:
- Windows XP with Service Pack 2 (SP2) and later.
- Windows XP Media Center Edition 2005 with KB900325 (Windows XP Media Center Edition 2005) and KB925766 (October 2006 Update Rollup for Windows XP Media Center Edition) installed.
|Minimum supported client||Windows Vista [desktop apps | UWP apps]|
|Minimum supported server||Windows Server 2008 [desktop apps | UWP apps]|
|Header||mfobjects.h (include Mfidl.h)|