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

José Mejuto joshyfun at gmail.com
Tue Dec 13 14:05:16 CET 2016


El 13/12/2016 a las 0:48, fredvs escribió:

> IMO, the problem does not come from PortAudio but from
> TFileStream.WriteBuffer that does not have enough RAM for writing.
> But maybe I do not catch something :-(

Hello,

In your code you were writing from uos to TMemoryStream (RAM) and when 
finished copy everything to TFileStream (Disk), so instead the 
TMemoryStream use a TFileStream and skip the last copy. Of course you 
may need to rewrite file header when the process is finished.

Currently (pseudo code):

TMemoryStream.Create;
while Recording do begin
   TMemoryStream.Write(AudioBuffer);
end;
TFileStream.Create;
TFileStream.CopyFrom(TMemoryStream);
TFileStream.Free;
TMemoryStream.Free;

So change it by:

TFileStream.Create;
while Recording do begin
   TFileStream.Write(AudioBuffer);
end;
// Here you may need to rewrite file header (if any).
TFileStream.Free;


-- 




More information about the fpc-pascal mailing list