Theory behind audio source block sizes

Sebastian Dröge sebastian at centricular.com
Tue Feb 19 08:46:50 UTC 2019


On Tue, 2019-02-19 at 00:36 -0800, Casey Waldren wrote:
> Given an audio source that produces audio in N byte chunks, and a
> downstream element that consumes chunks of N*4 bytes, what is the
> best way to link these elements?
> 
> I have encountered this problem with a plugin that transforms audio
> from 4 to 2 channels. Gstreamer seems to lack docs on the topic of
> block sizes, so I feel like I have missed some important knowledge
> about how audio sources are supposed to operate.
> 
> I could change the audio source to produce these fixed sized blocks,
> or the downstream element to accept smaller blocks and accumulate
> them, e.g. with a GstAdapter. This seems brittle and sounds like a
> general purpose plugin should be provided for this purpose. Is that
> audiobuffersplit, or is there some other technique? 

The correct solution here is to use e.g. a GstAdapter in the downstream
element to be able to accept any block size. audio/x-raw caps require
nothing from the block size of buffers (other than being the same
amount of samples for each channel), and the size of buffers can also
change between buffer and buffer.
Generally, it's a bug in an element if it can't handle raw audio
buffers of arbitrary size.


An alternative would be to define a different caps for this that would
allow negotiating a specific block size and elements using those caps
would then ensure to only produce/consume buffers of that size.

-- 
Sebastian Dröge, Centricular Ltd · https://www.centricular.com

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 963 bytes
Desc: This is a digitally signed message part
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20190219/ff3d2eb0/attachment.sig>


More information about the gstreamer-devel mailing list