MIDIPacket = packed record
timeStamp: MIDITimeStamp;
length: UInt16;
data: array [0..255] of Byte;
end;
{$push}
{$PackRecords 4}
MIDIPacket = record
timeStamp: UInt64;
length: UInt16;
data: array [0..255] of Byte;
end;
{$pop}
Setting {$Align 1} for the whole file was not the correct solution. Instead only the two records (MIDIPacket and MIDIPacketList) should have 4 byte alignments instead of 8 byte alignment.https://stackoverflow.com/a/37748973/1037511
Note the #pragma pack(push, 4) above the definition of MIDIPacket in the CoreMIDI.h header file.
Something odd is going on, on my end.It's not wrong or odd, but expected. If you change the sources of FPC packages (and in this case you do)
If I create a midipacket type I my application unit; with pack record 4, then the structure size is correct at 268.
If I use unit MACOSALL; which uses MIDISERVICES definition, then the size is incorrect.
If I modify the MIDIServies definition it still is not correct.
...
So question now is how can I modify midiservices.
I have repeated my comments on the bug tracker. (And I checked the record sizes on my mini Mac)
The pack size is wrong: that is programmer error and not a bug.
Again: midi is a streaming protocol and does not allow slack space. Record packing should be byte aligned. Always.
< RTFM >:D >:D>
What you seem to forget is that natural alignment between 32 and 64 bitness is not equal.
No it is not. It is 1. not 4. Midi is a streaming protocol.
Hi
Thanks everyone for their input.
I managed to rebuild the modification and everythiong is now working correctly.
I have created a bug tracker entry
https://bugs.freepascal.org/view.php?id=35750