aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2020-06-23 15:45:53 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2020-06-23 15:45:53 +0200
commit2623b2736cef540aea937a7d48ba52e10f962198 (patch)
tree1e07a637b9d7d1914493708a1ef8b56ce2642723
parent0d15b12426f85916f5c896f844590df02442d6c6 (diff)
downloadODR-EDI2EDI-2623b2736cef540aea937a7d48ba52e10f962198.tar.gz
ODR-EDI2EDI-2623b2736cef540aea937a7d48ba52e10f962198.tar.bz2
ODR-EDI2EDI-2623b2736cef540aea937a7d48ba52e10f962198.zip
Update common code
-rw-r--r--lib/Socket.cpp7
-rw-r--r--lib/Socket.h4
-rw-r--r--lib/edi/common.cpp2
-rw-r--r--lib/edi/common.hpp2
4 files changed, 10 insertions, 5 deletions
diff --git a/lib/Socket.cpp b/lib/Socket.cpp
index 159de7e..bc1b179 100644
--- a/lib/Socket.cpp
+++ b/lib/Socket.cpp
@@ -2,7 +2,7 @@
Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Her Majesty the
Queen in Right of Canada (Communications Research Center Canada)
- Copyright (C) 2019
+ Copyright (C) 2020
Matthias P. Braendli, matthias.braendli@mpb.li
http://www.opendigitalradio.org
@@ -932,6 +932,11 @@ void TCPSendClient::sendall(const std::vector<uint8_t>& buffer)
}
m_queue.push(buffer);
+
+ if (m_queue.size() > MAX_QUEUE_SIZE) {
+ vector<uint8_t> discard;
+ m_queue.try_pop(discard);
+ }
}
void TCPSendClient::process()
diff --git a/lib/Socket.h b/lib/Socket.h
index 84def40..8c6f8a9 100644
--- a/lib/Socket.h
+++ b/lib/Socket.h
@@ -2,7 +2,7 @@
Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Her Majesty the
Queen in Right of Canada (Communications Research Center Canada)
- Copyright (C) 2019
+ Copyright (C) 2020
Matthias P. Braendli, matthias.braendli@mpb.li
http://www.opendigitalradio.org
@@ -311,7 +311,7 @@ class TCPSendClient {
bool m_is_connected = false;
TCPSocket m_sock;
- static constexpr size_t MAX_QUEUE_SIZE = 1024;
+ static constexpr size_t MAX_QUEUE_SIZE = 512;
ThreadsafeQueue<std::vector<uint8_t> > m_queue;
std::atomic<bool> m_running;
std::string m_exception_data;
diff --git a/lib/edi/common.cpp b/lib/edi/common.cpp
index d8a37e3..3005802 100644
--- a/lib/edi/common.cpp
+++ b/lib/edi/common.cpp
@@ -67,7 +67,7 @@ time_t frame_timestamp_t::to_unix_epoch() const
return 946684800 + seconds - utco;
}
-double frame_timestamp_t::diff_ms(const frame_timestamp_t& other) const
+double frame_timestamp_t::diff_s(const frame_timestamp_t& other) const
{
const double lhs = (double)seconds + (tsta / 16384000.0);
const double rhs = (double)other.seconds + (other.tsta / 16384000.0);
diff --git a/lib/edi/common.hpp b/lib/edi/common.hpp
index c149421..498b28a 100644
--- a/lib/edi/common.hpp
+++ b/lib/edi/common.hpp
@@ -41,7 +41,7 @@ struct frame_timestamp_t {
std::time_t to_unix_epoch() const;
std::chrono::system_clock::time_point to_system_clock() const;
- double diff_ms(const frame_timestamp_t& other) const;
+ double diff_s(const frame_timestamp_t& other) const;
frame_timestamp_t& operator+=(const std::chrono::milliseconds& ms);