|
5 | 5 | #include "DMDUtil/LevelDMD.h" |
6 | 6 | #include "DMDUtil/RGB24DMD.h" |
7 | 7 |
|
| 8 | +#if defined(_WIN32) || defined(_WIN64) |
| 9 | +#include <winsock2.h> // Windows byte-order functions |
| 10 | +#else |
| 11 | +#include <arpa/inet.h> // Linux/macOS byte-order functions |
| 12 | +#endif |
| 13 | + |
8 | 14 | #if !( \ |
9 | 15 | (defined(__APPLE__) && ((defined(TARGET_OS_IOS) && TARGET_OS_IOS) || (defined(TARGET_OS_TV) && TARGET_OS_TV))) || \ |
10 | 16 | defined(__ANDROID__)) |
@@ -71,6 +77,62 @@ class DMDServerConnector |
71 | 77 |
|
72 | 78 | bool DMD::m_finding = false; |
73 | 79 |
|
| 80 | +void DMD::Update::convertToHostByteOrder() |
| 81 | +{ |
| 82 | + // uint8_t and bool are not converted, as they are already in host byte order. |
| 83 | + mode = static_cast<Mode>(ntohl(static_cast<uint32_t>(mode))); |
| 84 | + layout = static_cast<AlphaNumericLayout>(ntohl(static_cast<uint32_t>(layout))); |
| 85 | + depth = ntohl(depth); |
| 86 | + for (size_t i = 0; i < 256 * 64; i++) |
| 87 | + { |
| 88 | + segData[i] = ntohs(segData[i]); |
| 89 | + } |
| 90 | + for (size_t i = 0; i < 128; i++) |
| 91 | + { |
| 92 | + segData2[i] = ntohs(segData2[i]); |
| 93 | + } |
| 94 | + width = ntohs(width); |
| 95 | + height = ntohs(height); |
| 96 | +} |
| 97 | + |
| 98 | +DMD::Update DMD::Update::toNetworkByteOrder() const |
| 99 | +{ |
| 100 | + // uint8_t and bool are not converted, as they are already in network byte order. |
| 101 | + Update copy = *this; |
| 102 | + copy.mode = static_cast<Mode>(htonl(static_cast<uint32_t>(mode))); |
| 103 | + copy.layout = static_cast<AlphaNumericLayout>(htonl(static_cast<uint32_t>(layout))); |
| 104 | + copy.depth = htonl(depth); |
| 105 | + for (size_t i = 0; i < 256 * 64; i++) |
| 106 | + { |
| 107 | + copy.segData[i] = htons(segData[i]); |
| 108 | + } |
| 109 | + for (size_t i = 0; i < 128; i++) |
| 110 | + { |
| 111 | + copy.segData2[i] = htons(segData2[i]); |
| 112 | + } |
| 113 | + copy.width = htons(width); |
| 114 | + copy.height = htons(height); |
| 115 | + return copy; |
| 116 | +} |
| 117 | + |
| 118 | +void DMD::StreamHeader::convertToHostByteOrder() |
| 119 | +{ |
| 120 | + // uint8_t and char are not converted, as they are already in host byte order. |
| 121 | + mode = static_cast<Mode>(ntohl(static_cast<uint32_t>(mode))); |
| 122 | + width = ntohs(width); |
| 123 | + height = ntohs(height); |
| 124 | + length = ntohl(length); |
| 125 | +} |
| 126 | + |
| 127 | +void DMD::StreamHeader::convertToNetworkByteOrder() |
| 128 | +{ |
| 129 | + // uint8_t and char are not converted, as they are already in network byte order. |
| 130 | + mode = static_cast<Mode>(htonl(static_cast<uint32_t>(mode))); |
| 131 | + width = htons(width); |
| 132 | + height = htons(height); |
| 133 | + length = htonl(length); |
| 134 | +} |
| 135 | + |
74 | 136 | DMD::DMD() |
75 | 137 | { |
76 | 138 | for (uint8_t i = 0; i < DMDUTIL_FRAME_BUFFER_SIZE; i++) |
@@ -622,8 +684,8 @@ void DMD::DmdFrameThread() |
622 | 684 | { |
623 | 685 | char name[DMDUTIL_MAX_NAME_SIZE] = {0}; |
624 | 686 |
|
625 | | - m_dmdFrameReady.load(std::memory_order_acquire); |
626 | | - m_stopFlag.load(std::memory_order_acquire); |
| 687 | + (void)m_dmdFrameReady.load(std::memory_order_acquire); |
| 688 | + (void)m_stopFlag.load(std::memory_order_acquire); |
627 | 689 |
|
628 | 690 | while (true) |
629 | 691 | { |
@@ -666,8 +728,8 @@ void DMD::ZeDMDThread() |
666 | 728 | uint8_t indexBuffer[256 * 64] = {0}; |
667 | 729 | uint8_t renderBuffer[256 * 64 * 3] = {0}; |
668 | 730 |
|
669 | | - m_dmdFrameReady.load(std::memory_order_acquire); |
670 | | - m_stopFlag.load(std::memory_order_acquire); |
| 731 | + (void)m_dmdFrameReady.load(std::memory_order_acquire); |
| 732 | + (void)m_stopFlag.load(std::memory_order_acquire); |
671 | 733 |
|
672 | 734 | Config* const pConfig = Config::GetInstance(); |
673 | 735 | bool showNotColorizedFrames = pConfig->IsShowNotColorizedFrames(); |
@@ -801,8 +863,8 @@ void DMD::SerumThread() |
801 | 863 | uint32_t nextRotation = 0; |
802 | 864 | Update* lastDmdUpdate = nullptr; |
803 | 865 |
|
804 | | - m_dmdFrameReady.load(std::memory_order_acquire); |
805 | | - m_stopFlag.load(std::memory_order_acquire); |
| 866 | + (void)m_dmdFrameReady.load(std::memory_order_acquire); |
| 867 | + (void)m_stopFlag.load(std::memory_order_acquire); |
806 | 868 |
|
807 | 869 | Config* const pConfig = Config::GetInstance(); |
808 | 870 | bool showNotColorizedFrames = pConfig->IsShowNotColorizedFrames(); |
@@ -1024,8 +1086,8 @@ void DMD::PixelcadeDMDThread() |
1024 | 1086 | uint8_t palette[PALETTE_SIZE] = {0}; |
1025 | 1087 | uint16_t rgb565Data[128 * 32] = {0}; |
1026 | 1088 |
|
1027 | | - m_dmdFrameReady.load(std::memory_order_acquire); |
1028 | | - m_stopFlag.load(std::memory_order_acquire); |
| 1089 | + (void)m_dmdFrameReady.load(std::memory_order_acquire); |
| 1090 | + (void)m_stopFlag.load(std::memory_order_acquire); |
1029 | 1091 |
|
1030 | 1092 | Config* const pConfig = Config::GetInstance(); |
1031 | 1093 | bool showNotColorizedFrames = pConfig->IsShowNotColorizedFrames(); |
@@ -1196,8 +1258,8 @@ void DMD::LevelDMDThread() |
1196 | 1258 | uint8_t bufferPosition = 0; |
1197 | 1259 | uint8_t renderBuffer[256 * 64] = {0}; |
1198 | 1260 |
|
1199 | | - m_dmdFrameReady.load(std::memory_order_acquire); |
1200 | | - m_stopFlag.load(std::memory_order_acquire); |
| 1261 | + (void)m_dmdFrameReady.load(std::memory_order_acquire); |
| 1262 | + (void)m_stopFlag.load(std::memory_order_acquire); |
1201 | 1263 |
|
1202 | 1264 | while (true) |
1203 | 1265 | { |
@@ -1243,8 +1305,8 @@ void DMD::RGB24DMDThread() |
1243 | 1305 | uint8_t renderBuffer[256 * 64] = {0}; |
1244 | 1306 | uint8_t rgb24Data[256 * 64 * 3] = {0}; |
1245 | 1307 |
|
1246 | | - m_dmdFrameReady.load(std::memory_order_acquire); |
1247 | | - m_stopFlag.load(std::memory_order_acquire); |
| 1308 | + (void)m_dmdFrameReady.load(std::memory_order_acquire); |
| 1309 | + (void)m_stopFlag.load(std::memory_order_acquire); |
1248 | 1310 |
|
1249 | 1311 | Config* const pConfig = Config::GetInstance(); |
1250 | 1312 | bool showNotColorizedFrames = pConfig->IsShowNotColorizedFrames(); |
@@ -1391,8 +1453,8 @@ void DMD::ConsoleDMDThread() |
1391 | 1453 | uint8_t bufferPosition = 0; |
1392 | 1454 | uint8_t renderBuffer[256 * 64] = {0}; |
1393 | 1455 |
|
1394 | | - m_dmdFrameReady.load(std::memory_order_acquire); |
1395 | | - m_stopFlag.load(std::memory_order_acquire); |
| 1456 | + (void)m_dmdFrameReady.load(std::memory_order_acquire); |
| 1457 | + (void)m_stopFlag.load(std::memory_order_acquire); |
1396 | 1458 |
|
1397 | 1459 | while (true) |
1398 | 1460 | { |
@@ -1504,8 +1566,8 @@ void DMD::DumpDMDTxtThread() |
1504 | 1566 | FILE* f = nullptr; |
1505 | 1567 | std::unordered_set<uint64_t> seenHashes; |
1506 | 1568 |
|
1507 | | - m_dmdFrameReady.load(std::memory_order_acquire); |
1508 | | - m_stopFlag.load(std::memory_order_acquire); |
| 1569 | + (void)m_dmdFrameReady.load(std::memory_order_acquire); |
| 1570 | + (void)m_stopFlag.load(std::memory_order_acquire); |
1509 | 1571 |
|
1510 | 1572 | Config* const pConfig = Config::GetInstance(); |
1511 | 1573 | bool dumpNotColorizedFrames = pConfig->IsDumpNotColorizedFrames(); |
@@ -1656,8 +1718,8 @@ void DMD::DumpDMDRawThread() |
1656 | 1718 | std::chrono::steady_clock::time_point start; |
1657 | 1719 | FILE* f = nullptr; |
1658 | 1720 |
|
1659 | | - m_dmdFrameReady.load(std::memory_order_acquire); |
1660 | | - m_stopFlag.load(std::memory_order_acquire); |
| 1721 | + (void)m_dmdFrameReady.load(std::memory_order_acquire); |
| 1722 | + (void)m_stopFlag.load(std::memory_order_acquire); |
1661 | 1723 |
|
1662 | 1724 | while (true) |
1663 | 1725 | { |
@@ -1730,8 +1792,8 @@ void DMD::PupDMDThread() |
1730 | 1792 | uint8_t palette[192] = {0}; |
1731 | 1793 | char name[DMDUTIL_MAX_NAME_SIZE] = {0}; |
1732 | 1794 |
|
1733 | | - m_dmdFrameReady.load(std::memory_order_acquire); |
1734 | | - m_stopFlag.load(std::memory_order_acquire); |
| 1795 | + (void)m_dmdFrameReady.load(std::memory_order_acquire); |
| 1796 | + (void)m_stopFlag.load(std::memory_order_acquire); |
1735 | 1797 |
|
1736 | 1798 | while (true) |
1737 | 1799 | { |
|
0 commit comments