[fpc-pascal] How to use pipes ?

fredvs fiens at hotmail.com
Wed Feb 1 14:52:36 CET 2017


Hello.

Some more explanation.

With that code, only +- 10 loops are working, after, no more Ouframes... why
?


const
FramesWanted : 640;
PipeBufferSize : 10240;
BufferURL, BufferTemp : tbytes;
BufferFloat : array of float;
...

setlength(BufferURL, PipeBufferSize);
setlength(BufferTemp,  FramesWanted * 2);
setlength(BufferFloat, FramesWanted * 2);
 
CreatePipeHandles(InHandle, OutHandle, PipeBufferSize);
InPipe := TInputPipeStream.Create(InHandle);
OutPipe := TOutputPipeStream.Create(OutHandle);
HandleOP :=  op_test_memory(BufferURL[0],PipeBufferSize, Err);

Outframes := 1;
outst := 1;
outst2 := 0;

// The loop, is it the correct way ?
while Outframes > 0 do
begin
   while (outst2 < FramesWanted)  and (outst > 0)  do
  begin
     outst := InPipe.Read(BufferTemp[0],FramesWanted-outst2);
    if outst > 0 then  for i := 0 to outst -1 do
   BufferURL[i+outst2] := BufferTemp[i] ;
     outst2 := outst2 + outst;
  end;
 
// Outframes > 0 only +- 10 loops, why ?
Outframes := op_read_float(HandleOP,  @Buffer[0], FramesWanted , nil));
... 
end;

Thanks.

Fre;D





-----
Many thanks ;-)
--
View this message in context: http://free-pascal-general.1045716.n5.nabble.com/How-to-use-pipes-tp5727538p5727544.html
Sent from the Free Pascal - General mailing list archive at Nabble.com.



More information about the fpc-pascal mailing list