Share via


IWMReaderCallbackAdvanced::AllocateForStream method (wmsdkidl.h)

[The feature associated with this page, Windows Media Format 11 SDK, is a legacy feature. It has been superseded by Source Reader and Sink Writer. Source Reader and Sink Writer have been optimized for Windows 10 and Windows 11. Microsoft strongly recommends that new code use Source Reader and Sink Writer instead of Windows Media Format 11 SDK, when possible. Microsoft suggests that existing code that uses the legacy APIs be rewritten to use the new APIs if possible.]

The AllocateForStream method allocates user-created buffers for stream samples delivered to IWMReaderCallbackAdvanced::OnStreamSample. For more information about allocating your own buffers, see User Allocated Sample Support.

Syntax

HRESULT AllocateForStream(
  [in]  WORD       wStreamNum,
  [in]  DWORD      cbBuffer,
  [out] INSSBuffer **ppBuffer,
  [in]  void       *pvContext
);

Parameters

[in] wStreamNum

WORD containing the stream number.

[in] cbBuffer

Size of the buffer, in bytes.

[out] ppBuffer

If the method succeeds, returns a pointer to a pointer to an INSSBuffer interface.

[in] pvContext

Generic pointer, for use by the application. This pointer is the context pointer given to the IWMReader::Start method.

Return value

To use this method, you must implement it in your application. You can return whatever HRESULT error codes are appropriate to your implementation. For more information about the HRESULT error codes included for use by the Windows Media Format SDK, see Error Codes.

Remarks

Stream numbers are in the range of 1 through 63.

An extended version of this method called AllocateForStreamEx exists in the IWMReaderAllocatorEx interface.

When allocating buffers, you can use whatever logic suits your application. Typically, applications initialize a pool of buffers for the file or a pool of buffers for each stream or output. When the application is done with a sample, the buffer is put back into the pool for use.

You can determine the size needed to hold the largest sample of a stream by calling IWMReaderAdvanced::GetMaxStreamSampleSize. This is the size you should make the samples in the pool used for the output.

When you allocate a sample in your implementation of this method, you should call INSSBuffer::SetLength to set the length of the buffer to the length passed by the reader in the cbBuffer parameter. If you do not set the current length on the buffer, the reader may encounter an error.

Requirements

Requirement Value
Minimum supported client Windows 2000 Professional [desktop apps only],Windows Media Format 7 SDK, or later versions of the SDK
Minimum supported server Windows 2000 Server [desktop apps only]
Target Platform Windows
Header wmsdkidl.h (include Wmsdk.h)

See also

IWMReaderCallbackAdvanced Interface