ALTE DOCUMENTE
|
||||||||||
Buffering
Following buffer processing methods possible:
In-place
Immediate
Block buffering
Filter processes data in-place a 626e45g t buffer received with process() call. Therefore, upstream must provide a buffer that can be safely changed. This allows to avoid data copy from one buffer to another so speed up processing.
If output data size must be larger than input data size, data is processed from input buffer to private output buffer and returned immediately. If filter cannot store all processed data into its output buffer, it produces several output chunks. This method does not produce processing lag.
To operate filter requires block of data that is processed at once. So filter copies input data to internal buffer until buffer fills up and only after this output chunk is produced. Also it may hold some amount of data at buffer to process next block. This method produces lag. Also this method requires flushing to release data locked at internal buffer to correctly finish the stream.
Filters may use different processing methods for different input formats. For example mixer does inplace processing if output number of channels is less or equal to input number of channels (faster) and uses immediate buffering otherwise.
When filter receives big buffer it may require step-by-step processing. So it may produce several output chunks. After filter produces first one it still have to have access to input buffer to produce next one. Therefore, we must not alter input buffer until filter processes all input data. After filter processed all data it switches to an empty state.
Even in-place filters may change output format
Even in-place filters may reduce output data size
Filter may hold reference to input buffer until it become empty. So empty filter state must guarantee that we do not use external buffers anymore.
Sources must provide buffers that can be safely changed.
Buffers that are passed to process() must not be altered until filter become empty
|