Skip to content

Commit

Permalink
add dequeue timeout for openhd
Browse files Browse the repository at this point in the history
  • Loading branch information
Consti10 committed Sep 14, 2023
1 parent 6f5f1a4 commit c63b02e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/WBStreamTx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ void WBStreamTx::loop_process_data() {
if(options.dequeue_thread_max_realtime){
SchedulingHelper::setThreadParamsMaxRealtime();
}
static constexpr std::int64_t timeout_usecs=100*1000;
const std::int64_t timeout_usecs=std::chrono::duration_cast<std::chrono::microseconds>(options.dequeue_timeout).count();
if(options.enable_fec){
std::shared_ptr<EnqueuedBlock> frame= nullptr;
while (m_process_data_thread_run){
Expand Down Expand Up @@ -159,6 +159,10 @@ void WBStreamTx::loop_process_data() {
m_queue_time_calculator.reset();
}
process_enqueued_packet(*packet);
}else{
if(options.dequeue_timeout_cb){
options.dequeue_timeout_cb(*this);
}
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions src/WBStreamTx.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
*/
class WBStreamTx {
public:
typedef std::function<void(WBStreamTx& self)> DEQUEUE_TIMEOUT_CB;
struct Options {
// needs to match the radio port of the corresponding rx
uint8_t radio_port = 0;
Expand All @@ -45,6 +46,10 @@ class WBStreamTx {
std::shared_ptr<spdlog::logger> opt_console=nullptr;
// set sched_param = max realtime on the thread that dequeues and injects the packets
bool dequeue_thread_max_realtime= true;
// Dirty, for openhd - function that is called from the dequeue thread every time the
// de-queueing of a packet timed out (no packet was fed for timeout ms)
std::chrono::microseconds dequeue_timeout=std::chrono::milliseconds(100);
DEQUEUE_TIMEOUT_CB dequeue_timeout_cb= nullptr;
};
WBStreamTx(std::shared_ptr<WBTxRx> txrx,Options options,std::shared_ptr<RadiotapHeaderHolder> radiotap_header_holder);
WBStreamTx(const WBStreamTx&) = delete;
Expand Down

0 comments on commit c63b02e

Please sign in to comment.