| 871 | |
| 872 | template <typename ParamSerialiser, typename ReturnSerialiser> |
| 873 | void ReplayProxy::Proxied_GetBufferData(ParamSerialiser ¶mser, ReturnSerialiser &retser, |
| 874 | ResourceId buff, uint64_t offset, uint64_t len, |
| 875 | bytebuf &retData) |
| 876 | { |
| 877 | const ReplayProxyPacket expectedPacket = eReplayProxy_GetBufferData; |
| 878 | ReplayProxyPacket packet = eReplayProxy_GetBufferData; |
| 879 | |
| 880 | { |
| 881 | BEGIN_PARAMS(); |
| 882 | SERIALISE_ELEMENT(buff); |
| 883 | SERIALISE_ELEMENT(offset); |
| 884 | SERIALISE_ELEMENT(len); |
| 885 | END_PARAMS(); |
| 886 | } |
| 887 | |
| 888 | { |
| 889 | REMOTE_EXECUTION(); |
| 890 | if(paramser.IsReading() && !paramser.IsErrored() && !m_IsErrored) |
| 891 | m_Remote->GetBufferData(buff, offset, len, retData); |
| 892 | } |
| 893 | |
| 894 | // over-estimate of total uncompressed data written. Since the decompression chain needs to know |
| 895 | // the exact uncompressed size, we over-estimate (to allow for length/padding/etc) and then pad |
| 896 | // to this amount. |
| 897 | uint64_t dataSize = retData.size() + 2 * retser.GetChunkAlignment(); |
| 898 | |
| 899 | { |
| 900 | ReturnSerialiser &ser = retser; |
| 901 | PACKET_HEADER(packet); |
| 902 | SERIALISE_ELEMENT(packet); |
| 903 | SERIALISE_ELEMENT(dataSize); |
| 904 | } |
| 905 | |
| 906 | char empty[128] = {}; |
| 907 | |
| 908 | // lz4 compress |
| 909 | if(retser.IsReading()) |
| 910 | { |
| 911 | ReadSerialiser ser(new StreamReader(new LZ4Decompressor(retser.GetReader(), Ownership::Nothing), |
| 912 | dataSize, Ownership::Stream), |
| 913 | Ownership::Stream); |
| 914 | |
| 915 | SERIALISE_ELEMENT(retData); |
| 916 | |
| 917 | uint64_t offs = ser.GetReader()->GetOffset(); |
| 918 | RDCASSERT(offs <= dataSize, offs, dataSize); |
| 919 | RDCASSERT(dataSize - offs < sizeof(empty), offs, dataSize); |
| 920 | |
| 921 | if(offs < dataSize) |
| 922 | ser.GetReader()->Read(empty, dataSize - offs); |
| 923 | } |
| 924 | else |
| 925 | { |
| 926 | WriteSerialiser ser(new StreamWriter(new LZ4Compressor(retser.GetWriter(), Ownership::Nothing), |
| 927 | Ownership::Stream), |
| 928 | Ownership::Stream); |
| 929 | |
| 930 | SERIALISE_ELEMENT(retData); |
nothing calls this directly
no test coverage detected