Skip to content

Commit dc35dc7

Browse files
committed
added persistence buffer to audio rpc packer
1 parent 9492862 commit dc35dc7

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/framework/audio/common/rpc/rpcpacker.h

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -590,19 +590,30 @@ class RpcPacker
590590
template<class ... Types>
591591
static ByteArray pack(const Options& opt, const Types&... args)
592592
{
593-
return msgpack::pack(opt, args ...);
593+
ByteArray ba;
594+
595+
// clear but keep capacity
596+
buffer.clear();
597+
// makes sense if the reserve is greater than the current capacity
598+
buffer.reserve(std::max(opt.rezerveSize, DEFAULT_CAPACITY));
599+
msgpack::pack(buffer, args ...);
600+
601+
return ByteArray(&buffer[0], buffer.size());
594602
}
595603

596604
template<class ... Types>
597605
static ByteArray pack(const Types&... args)
598606
{
599-
return msgpack::pack(args ...);
607+
return RpcPacker::pack(Options {}, args ...);
600608
}
601609

602610
template<class ... Types>
603611
static bool unpack(const ByteArray& data, Types&... args)
604612
{
605613
return msgpack::unpack(data, args ...);
606614
}
615+
616+
static constexpr size_t DEFAULT_CAPACITY = 1024 * 200;
617+
static inline std::vector<uint8_t> buffer = {};
607618
};
608619
}

0 commit comments

Comments
 (0)