I'm writing a source filter for directshow
. The intel Media SDK H.264 Encoder requires ALLOCATOR_PROPERTIES->cBuffer > 1
.
when in DoBufferProcessingLoop
I get the buffer using GetDeliveryBuffer(&pSample, NULL, NULL, 0)
Do I need to do anything to make sure I get the next buffer, and I'm not overwriting the previous buffer?
I noticed the pSample->AddRef()
in the sample encoder. Do I have to do something similar when I GetdeliveryBuffer
or in FillBuffer
?
The buffer won't be reused until the only reference to the buffer is the reference from its owning memory allocator.
This means that in DoBufferProcessingLoop
you get clean buffer, you do your thing filling it, then you pass it downstream. Then the magic continues and finally the buffer is ready for reuse when it is discarded or presented, and is not being used by anybody else. You don't need to do anything to ensure this, it happens on its own.