From b2a457411f56ed63781bc4c456c96c2145c27aa9 Mon Sep 17 00:00:00 2001 From: myd7349 Date: Wed, 28 Jan 2026 22:12:48 +0800 Subject: [PATCH 1/2] Fix lsl_get_channel_bytes to return 0 for cft_string as documented --- src/stream_info_impl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/stream_info_impl.cpp b/src/stream_info_impl.cpp index 887911ef..9c680db5 100644 --- a/src/stream_info_impl.cpp +++ b/src/stream_info_impl.cpp @@ -243,7 +243,7 @@ bool query_cache::matches_query(const xml_document &doc, const std::string &quer } int stream_info_impl::channel_bytes() const { - const int channel_format_sizes[] = {0, sizeof(float), sizeof(double), sizeof(std::string), + const int channel_format_sizes[] = {0, sizeof(float), sizeof(double), 0, sizeof(int32_t), sizeof(int16_t), sizeof(int8_t), 8}; return channel_format_sizes[channel_format_]; } From 2a8e4272209c1e4b9251dd70550fd880ba8c2961 Mon Sep 17 00:00:00 2001 From: Chadwick Boulay Date: Tue, 16 Jun 2026 23:02:43 -0400 Subject: [PATCH 2/2] test: update tcpserver string endian case for zero-size string channels With channel_bytes() now returning 0 for cft_string, the server no longer volunteers an endian conversion for string streams (value size 0), so it advertises its own host byte order instead of echoing the client's. The string length-prefixes are byte-swapped on the receiving side instead. Assert the host byte order here; the float case still covers actual binary endian conversion. Co-Authored-By: Claude Opus 4.8 (1M context) --- testing/int/tcpserver.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/testing/int/tcpserver.cpp b/testing/int/tcpserver.cpp index 6444139f..f984c5b2 100644 --- a/testing/int/tcpserver.cpp +++ b/testing/int/tcpserver.cpp @@ -3,6 +3,7 @@ #include "send_buffer.h" #include "stream_info_impl.h" #include "tcp_server.h" +#include "util/endian.hpp" #include #include #include @@ -138,10 +139,15 @@ TEST_CASE("tcpserver", "[network]") { cmp_binstr(expected, received_pattern); })); + // String channels report a per-channel value size of 0 (channel_bytes() == 0), so the server + // performs no endian conversion and advertises its own (host) byte order regardless of the + // client's request. Any needed swapping of the string length-prefixes happens on the receiving + // side instead (see tcpserver_float for the actual binary endian-conversion test). send_request(ctx, ep, asio::buffer("LSL:streamfeed/199 \nNative-byte-order:4321\r\n\r\n"), with_read_callback("endian", [](const std::string &res) { REQUIRE(res.substr(0, 14) == "LSL/110 200 OK"); - REQUIRE(res.find("Byte-Order: 4321") != std::string::npos); + REQUIRE(res.find("Byte-Order: " + std::to_string(static_cast(lsl::LSL_BYTE_ORDER))) != + std::string::npos); })); send_request(ctx, ep, asio::buffer("LSL:streamfeed\n0 0\r\n"),