1
0
Fork 0

send 3 stream_terminated messages during orderly shutdown

This commit is contained in:
Kevin Matz 2022-11-21 17:45:43 -05:00
parent 09dc532984
commit cf1df8d373
1 changed files with 11 additions and 2 deletions

View File

@ -426,6 +426,11 @@ void Universe::tx_loop_()
// run at least 1 loop
bool enable = true;
/// \cite sACN 6.2.6 E1.31 Data Packet: Options - Stream_Terminated
/// Three packets containing this bit ... shall be sent by sources upon terminating
/// sourcing of a universe.
int terminated_resend = 3;
/// > \cite sACN 6.6.1 Transmission Rate
/// >
/// > E1.31 sources shall not transmit packets for a given universe number
@ -456,7 +461,7 @@ void Universe::tx_loop_()
// but it requires this mutex in the sleeping thread.
std::mutex mtx;
while (enable)
while (enable || terminated_resend >= 0)
{
// enforce strict minimum update times
auto elapsed = std::chrono::duration_cast<std::chrono::milliseconds>
@ -471,7 +476,11 @@ void Universe::tx_loop_()
// if shutting down, send stream_terminated in this last update
if (!enable)
provenance_->options.stream_terminated = true;
{
provenance_->options.stream_terminated = true; // set the stream_terminated bit
terminated_resend--; // stream_terminated must be sent 3 times
retransmission_count = 0; // stay throttled up through the termination sequence
}
// see if this is new data or re-transmitting
auto sleep = std::chrono::milliseconds(minimum_update_time);