IMFMediaBuffer::Lock Method
Gives the caller access to the memory in the buffer, for reading or writing
Syntax
HRESULT Lock(
[out] BYTE **ppbBuffer,
[out] DWORD *pcbMaxLength,
[out] DWORD *pcbCurrentLength
);
Parameter
ppbBuffer [out]
Receives a pointer to the start of the buffer.pcbMaxLength [out]
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.pcbCurrentLength [out]
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.
Rückgabewert
The method returns an HRESULT. Possible values include, but are not limited to, those in the following table.
Rückgabecode | Beschreibung |
---|---|
S_OK | The method succeeded. |
D3DERR_INVALIDCALL | For Direct3D surface buffers, an error occurred when locking the surface. |
MF_E_INVALIDREQUEST | The buffer cannot be locked at this time. |
Hinweise
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 mit Service Pack 2 (SP2) und höher.
- Windows XP Media Center Edition 2005 with KB900325 (Windows XP Media Center Edition 2005) and KB925766 (Oktober 2006 Updaterollup für Windows XP Media Center Edition) installed.
Anforderungen
Mindestens unterstützter Client |
Windows Vista |
Mindestens unterstützter Server |
Windows Server 2008 |
Header |
Mfobjects.h (include Mfidl.h) |
Bibliothek |
Mfuuid.lib |