sccn / liblsl

C++ lsl library for multi-modal time-synched data transmission over the local network
Other
108 stars 63 forks source link

Force max_buflen * srate to be at least 1 #121

Closed cboulay closed 3 years ago

cboulay commented 3 years ago

Very low rate streams combined with smallish max_buflen will give a queue size that gets truncated to 0. The result was a stream that kept disconnecting (at least that's what the log said). Here we + 1 to round up.

For situations where 0 < (nominal_srate() * max_buflen) % 1 < 0.5 , this PR actually gives you a queue length that's longer and less accurate (by 1) than before the change. For the rest of the situations, this is now more accurate. In sum, this is arguably better because it errs on the more conservative side (larger queue).

I started off using std::max(1, {old result}), which is closest to preserving old behaviour and just catching this error case, but it's probably a bit heavy to #include<algorithm> for such a simple fix.

cboulay commented 3 years ago

Closing and reopening to trigger CI checks.