Re: [fpc-pascal] How to use pipes ?

2017-02-01 Thread fredvs
Huh, sorry to monopolize but... I get it. ;-) Changing the built-in read-callback method with this: function OpusReadCB(stream: Pointer; var buffer; nbytes: cint): cint; cdecl; begin if nbytes<>0 then result := TInputPipeStream(stream^).read(Buffer, nbytes) else result := 0; end; Do

Re: [fpc-pascal] How to use pipes ?

2017-02-01 Thread fredvs
Re-hello. Some more news: OK, I make work a other method: op_open_callbacks(InPipe, op_callbacks, BufferURL[0], PipeBufferSize, err); This method use a named pipe and can be use of the box with Andrew's THttpgetter. No need to do complicated conversion of pipe into buffer. op_callbacks does

Re: [fpc-pascal] How to use pipes ?

2017-02-01 Thread fredvs
Hello Jose. >The fact that op_read_float is zero is not an error, simply the amount of samples read by opus engine is zero Exactly. I know that isnot a error otherwise OutFrames < 0. >simply the amount of samples read by opus engine is zero. Exactly too and this because my conversion pipe into

Re: [fpc-pascal] question about fphttpclient

2017-02-01 Thread Michael Van Canneyt
On Wed, 1 Feb 2017, Ched wrote: Dear All, I use with great success (and pleasure!) the unit fphttpclient under winxp, mageia and raspbian with some code like WITH TFPHTTPCLIENT.CREATE(NIL) DO BEGIN REP:=GET(REQ); FREE; END; after having defined REQ (+initialisation with some

[fpc-pascal] question about fphttpclient

2017-02-01 Thread Ched
Dear All, I use with great success (and pleasure!) the unit fphttpclient under winxp, mageia and raspbian with some code like WITH TFPHTTPCLIENT.CREATE(NIL) DO BEGIN REP:=GET(REQ); FREE; END; after having defined REQ (+initialisation with some url) and REP as ansistring's. T

Re: [fpc-pascal] destructor

2017-02-01 Thread Nitorami
As I understand this: It may sometimes well be necessary to write your own destructor to clean up. But if you do this, don't call it foo; call it destructor and override it: destructor destroy; override; In your own destructor method, don't forget to call inherited in the end. -- View this me

Re: [fpc-pascal] for loop vs while loop

2017-02-01 Thread Nitorami
Just a note - I learned that for very short "for" loops it may be even a bit faster to count downwards (to zero) rather than upwards if possible, because the comparison to zero is very effiicient. Not sure though whether that still makes a difference on modern processors. -- View this message in

Re: [fpc-pascal] How to use pipes ?

2017-02-01 Thread José Mejuto
El 01/02/2017 a las 19:55, fredvs escribió: Outframes := op_read_float(HandleOP, @Buffer[0], FramesWanted , nil); if Outframes = 0 then exit; Hello, if OutFrames < 0 then exit; The fact that op_read_float is zero is not an error, simply the amount of samples read by opus engine is zero, ma

Re: [fpc-pascal] How to use pipes ?

2017-02-01 Thread fredvs
Ho Andrew, nice to read you. ;-) I battle hard to use your Thttpgetter for Opus, like you did for mpg123. The difference with mpg123 is that Opus needs a buffer (mpg123 a named pipe). I am nearly sure that the problem comes from my code to get the buffer from the pipe: while (outst2 < FramesW

Re: [fpc-pascal] How to use pipes ?

2017-02-01 Thread Andrew Haines
On 02/01/2017 08:52 AM, fredvs wrote: Hello. Some more explanation. With that code, only +- 10 loops are working, after, no more Ouframes... why ? Where is it stopping? It may be that you are asking for more bytes than are available and it is blocking waiting for more data. Or the opposite

Re: [fpc-pascal] How to use pipes ?

2017-02-01 Thread fredvs
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, FramesWa

Re: [fpc-pascal] How to use pipes ?

2017-02-01 Thread fredvs
Many thanks Mattias. Huh, and about bytesavailable ? See here: CreatePipeHandles(InHandle, OutHandle, PipeBufferSize); InPipe := TInputPipeStream.Create(InHandle); OutPipe := TOutputPipeStream.Create(OutHandle); httpget := TThreadHttpGetter.Create(url, OutPipe); // is length ok ? setlength(B

Re: [fpc-pascal] How to use pipes ?

2017-02-01 Thread Mattias Gaertner
On Wed, 1 Feb 2017 05:02:05 -0700 (MST) fredvs wrote: > Hello. > > I have done lot of search on internet about pipes without success. > Even for Delphi. no demo nor explanation. > The same in fpc wki page. > > For example, how to use bytesavailable with pipes ? http://wiki.freepascal.org/Execu

Re: [fpc-pascal] for loop vs while loop

2017-02-01 Thread Jürgen Hestermann
Am 2017-02-01 um 12:49 schrieb Graeme Geldenhuys: > Just curious (been in a discussion with somebody else). Is there a > performance difference between a FOR loop and a WHILE loop? > Not sure if it will make a difference, but the usage is with three > nested loops, iterating over some 300,000 plus

Re: [fpc-pascal] for loop vs while loop

2017-02-01 Thread Graeme Geldenhuys
On 2017-02-01 12:12, Mattias Gaertner wrote: > Yes, for-loop calculates the end value only once. Ah, thanks for that. Seems so obvious now. :) Regards, Graeme ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi

Re: [fpc-pascal] for loop vs while loop

2017-02-01 Thread Mattias Gaertner
On Wed, 1 Feb 2017 11:49:34 + Graeme Geldenhuys wrote: > Hi, > > Just curious (been in a discussion with somebody else). Is there a > performance difference between a FOR loop and a WHILE loop? Yes, for-loop calculates the end value only once. > Not sure if it will make a difference, but

[fpc-pascal] How to use pipes ?

2017-02-01 Thread fredvs
Hello. I have done lot of search on internet about pipes without success. Even for Delphi. no demo nor explanation. The same in fpc wki page. For example, how to use bytesavailable with pipes ? In: CreatePipeHandles(InHandle, OutHandle, APipeBufferSize); InPipe.Read(Bufferout[0],BPipeBufferSi

[fpc-pascal] for loop vs while loop

2017-02-01 Thread Graeme Geldenhuys
Hi, Just curious (been in a discussion with somebody else). Is there a performance difference between a FOR loop and a WHILE loop? Not sure if it will make a difference, but the usage is with three nested loops, iterating over some 300,000 plus data points in total. Regards, Graeme _