[DUG] Pointers help
Ross Levis
ross at stationplaylist.com
Sun Nov 5 14:18:40 NZDT 2017
I'm writing data to an Indy IOHandler by moving the data from a
TMemoryStream.Memory to a TIDBytes (array of byte) before writing it as I
cannot find how to do it otherwise.
This works...
AudioMS: TMemoryStream;
Buffer: TIdBytes; // array of byte
MemPos: PByte;
....
MemPos := AudioMS.Memory;
Inc(MemPos,FromPos);
ToPos := Player.AudioMS.Position;
SetLength(Buffer,ToPos-FromPos);
Move(MemPos^,Buffer[0],Length(Buffer));
IOHandler.WriteDirect(Buffer);
FromPos := ToPos;
But there has to be a better way of writing direct from the AudioMS.Memory
and getting rid of the Move operation.
I've tried the following but produces pointer errors or access violations.
IOHandler.WriteDirect(TIdBytes(MemPos),ToPos-FromPos);
Also tried...
IOHandler.WriteDirect(TIdBytes(MemPos^),ToPos-FromPos);
There is a IOHandler.Write function that supports TStream but the memory
stream is being appended to in a separate thread so I can't go changing the
Position I want to access the data from.
How should it be done?
Cheers,
Ross.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://listserver.123.net.nz/pipermail/delphi/attachments/20171105/3683a825/attachment.html
More information about the Delphi
mailing list