[fpc-pascal] TFileStream.WriteBuffer() and RAM used ?

José Mejuto joshyfun at gmail.com
Sat Dec 10 16:43:48 CET 2016

El 09/12/2016 a las 12:15, fredvs escribió:
> Hello.
> Thanks Michael for answer.
>> What happens with the buffer in which you had data, this we do not know.
> Here is the schema of recording:


You working schema for recording is memory related, you must transform 
it in a static approach based in expected requirements. In other words, 
you are about to write a WAVE, in a regular PC you can grab it directly 
to the TFileStream from InputBuffer, if you are in a very low power 
device you can use a doble buffer and if your requirements are a low 
power PC with very high bitrate spike you must swap to threading model 
(but it is overkill for almost anything nowadays).

It you don't want to directly write to TFileStream use the double 
buffer, let the audio grabber write in a block of memory while you dump 
the other one to TFileStream. It is quite difficult to show an example 
because I do not known the API you are using to grab the audio, most of 
them work with callbacks, some blocks execution, and others uses Windows 
events. If execution in API is blocking your thread I'm quite sure there 
is another one that do not block it.


More information about the fpc-pascal mailing list