[fpc-pascal] Pipe vs Memory buffer.

Michael Van Canneyt michael at freepascal.org
Wed Jan 25 23:32:45 CET 2017



On Wed, 25 Jan 2017, fredvs wrote:

> Hello
>
> In a C method:
>
> OP_WARN_UNUSED_RESULT OggOpusFile *op_test_memory(const unsigned char
> *_data,
> size_t _size,int *_error);
>
> translated in Pascal with this:
>
> var
> op_test_memory: function(const _data; const size: cuint; out error: cint):
> TOggOpusFile;
>
> How to use a pipe for _data ?
>
> The pipe is a TInputPipeStream.
>
> Using this does not work:
> pipein was created and linked to a url.
>
> var
> pipein :TInputPipeStream; /
> PipeBufferSize := $4000;
> ...
> op_test_memory(pointer(InPipe),PipeBufferSize, Err);
>
> The error is -129 which is a null pointer or other generic internal error.

That will never work.

OP_WARN_UNUSED_RESULT OggOpusFile *op_test_memory(const unsigned char *_data, size_t _size,int *_error);

expects a memory buffer; you cannot pass it a stream.

Michael.



More information about the fpc-pascal mailing list