BBuffer¶
A BBuffer references a chunk of shared memory where media data
can be passed between applications and nodes. The control header for these
buffers is passed through the use of a safer IPC mechanism, but the actual
data these headers represent typically require a high data rate, and for
the sake of maximizing performance, shared memory is the method by which
the buffers are managed.
BBuffers originate at some BBufferProducer, which
has a BBufferGroup that acts as a source of
BBuffers (see
BBufferConsumer::SetOutputBuffersFor()). BBuffers
are sent through all participating nodes, possibly being sent down a long
chain—much like a bucket brigade—until finally the node arrives at a node
that chooses not to pass along the BBuffer any further, at
which the buffer’s Recycle() function is called to
return the buffer to the BBufferGroup’s store, where it gets
reused by another batch of data.
An application or custom node can set up BBuffers that
reference a specific area of memory, such as a low-level driver buffer, a
BBitmap, or a BDirectWindow’s area of a frame
buffer. This ability can provide for great optimization by avoiding
unnecessary copy operations.
The BSmallBuffer class, derived from BBuffer, is
used for very small buffers; they don’t go in BBufferGroups,
and get handled specially to optimize performance.
Warning
BBuffer should never be subclassed, since they’re mostly owned
and managed by the Media Server. Even if you create your own
BBuffer, once you’ve called
BBufferConsumer::SetOutputBuffersFor(), the “same” buffer
received back by your BBufferConsumer may actually be another
instance of the BBuffer class.