Skip to content

Commit 9cadd15

Browse files
committed
Merge branch 'master' into dev-speedy
2 parents d0f62d4 + 47028c9 commit 9cadd15

24 files changed

+358
-170
lines changed

CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,6 @@ if (UNIX)
139139
target_compile_features(lslboost PUBLIC cxx_std_11 cxx_lambda_init_captures)
140140
else () # WIN32
141141
target_sources(lslboost PRIVATE
142-
lslboost/libs/serialization/src/codecvt_null.cpp
143142
lslboost/libs/thread/src/win32/thread.cpp
144143
lslboost/libs/thread/src/win32/tss_dll.cpp
145144
lslboost/libs/thread/src/win32/tss_pe.cpp

include/lsl/inlet.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,9 @@ extern LIBLSL_C_API unsigned long lsl_pull_chunk_buf(lsl_inlet in, char **data_b
273273
*/
274274
extern LIBLSL_C_API uint32_t lsl_samples_available(lsl_inlet in);
275275

276+
/// Drop all queued not-yet pulled samples, return the nr of dropped samples
277+
extern LIBLSL_C_API uint32_t lsl_inlet_flush(lsl_inlet in);
278+
276279
/**
277280
* Query whether the clock was potentially reset since the last call to lsl_was_clock_reset().
278281
*

include/lsl_cpp.h

Lines changed: 41 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -750,8 +750,7 @@ class stream_outlet {
750750
}
751751

752752
/** Push a chunk of multiplexed samples into the outlet. Single timestamp provided.
753-
* IMPORTANT: Note that the provided buffer size is measured in channel values (e.g., floats)
754-
* rather than in samples.
753+
* @warning The provided buffer size is measured in channel values (e.g., floats), not samples.
755754
* @param buffer A buffer of channel values holding the data for zero or more successive samples
756755
* to send.
757756
* @param buffer_elements The number of channel values (of type T) in the buffer. Must be a
@@ -760,8 +759,8 @@ class stream_outlet {
760759
* local_clock(); if omitted, the current time is used. The time stamps of other samples are
761760
* automatically derived based on the sampling rate of the stream.
762761
* @param pushthrough Whether to push the chunk through to the receivers instead of buffering it
763-
* with subsequent samples. Note that the chunk_size, if specified at outlet construction, takes
764-
* precedence over the pushthrough flag.
762+
* with subsequent samples. Note that the stream_outlet() constructur parameter @p chunk_size,
763+
* if specified at outlet construction, takes precedence over the pushthrough flag.
765764
*/
766765
void push_chunk_multiplexed(const float *buffer, std::size_t buffer_elements,
767766
double timestamp = 0.0, bool pushthrough = true) {
@@ -802,7 +801,7 @@ class stream_outlet {
802801
}
803802

804803
/** Push a chunk of multiplexed samples into the outlet. One timestamp per sample is provided.
805-
* IMPORTANT: Note that the provided buffer size is measured in channel values (e.g., floats)
804+
* @warning Note that the provided buffer size is measured in channel values (e.g., floats)
806805
* rather than in samples.
807806
* @param data_buffer A buffer of channel values holding the data for zero or more successive
808807
* samples to send.
@@ -932,8 +931,8 @@ class stream_outlet {
932931
* (see Network Connectivity in the LSL wiki).
933932
* This is the default mechanism used by the browsing programs and the recording program.
934933
* @param wait_time The waiting time for the operation, in seconds, to search for streams.
935-
* Warning: If this is too short (<0.5s) only a subset (or none) of the
936-
* outlets that are present on the network may be returned.
934+
* If this is too short (<0.5s) only a subset (or none) of the outlets that are present on the
935+
* network may be returned.
937936
* @return A vector of stream info objects (excluding their desc field), any of which can
938937
* subsequently be used to open an inlet. The full info can be retrieve from the inlet.
939938
*/
@@ -996,34 +995,27 @@ inline std::vector<stream_info> resolve_stream(
996995
*/
997996
class stream_inlet {
998997
public:
999-
/** Construct a new stream inlet from a resolved stream info.
1000-
* @param info A resolved stream info object (as coming from one of the resolver functions).
1001-
* Note: the stream_inlet may also be constructed with a fully-specified stream_info,
1002-
* if the desired channel format and count is already known up-front, but this
1003-
is
1004-
* strongly discouraged and should only ever be done if there is no time to
1005-
resolve the
1006-
* stream up-front (e.g., due to limitations in the client program).
1007-
* @param max_buflen Optionally the maximum amount of data to buffer (in seconds if there is a
1008-
nominal
1009-
* sampling rate, otherwise x100 in samples). Recording applications want to
1010-
use a fairly
1011-
* large buffer size here, while real-time applications would only buffer as
1012-
much as
1013-
* they need to perform their next calculation.
1014-
* @param max_chunklen Optionally the maximum size, in samples, at which chunks are transmitted
1015-
* (the default corresponds to the chunk sizes used by the sender).
1016-
* Recording applications can use a generous size here (leaving it to the
1017-
network how
1018-
* to pack things), while real-time applications may want a finer (perhaps
1019-
1-sample) granularity. If left unspecified (=0), the sender determines the chunk granularity.
1020-
* @param recover Try to silently recover lost streams that are recoverable (=those that that
1021-
have a source_id set).
1022-
* In all other cases (recover is false or the stream is not recoverable)
1023-
functions may throw a
1024-
* lost_error if the stream's source is lost (e.g., due to an app or computer
1025-
crash).
1026-
*/
998+
/**
999+
* Construct a new stream inlet from a resolved stream info.
1000+
* @param info A resolved stream info object (as coming from one of the resolver functions).
1001+
* Note: The stream_inlet may also be constructed with a fully-specified stream_info, if the
1002+
* desired channel format and count is already known up-front, but this is strongly discouraged
1003+
* and should only ever be done if there is no time to resolve the stream up-front (e.g., due
1004+
* to limitations in the client program).
1005+
* @param max_buflen Optionally the maximum amount of data to buffer (in seconds if there is a
1006+
* nominal sampling rate, otherwise x100 in samples). Recording applications want to use a
1007+
* fairly large buffer size here, while real-time applications would only buffer as much as
1008+
* they need to perform their next calculation.
1009+
* @param max_chunklen Optionally the maximum size, in samples, at which chunks are transmitted
1010+
* (the default corresponds to the chunk sizes used by the sender).
1011+
* Recording applications can use a generous size here (leaving it to the network how to pack
1012+
* things), while real-time applications may want a finer (perhaps 1-sample) granularity.
1013+
* If left unspecified (=0), the sender determines the chunk granularity.
1014+
* @param recover Try to silently recover lost streams that are recoverable (=those that that
1015+
* have a source_id set).
1016+
* In all other cases (recover is false or the stream is not recoverable) functions may throw a
1017+
* lsl::lost_error if the stream's source is lost (e.g., due to an app or computer crash).
1018+
*/
10271019
stream_inlet(const stream_info &info, int32_t max_buflen = 360, int32_t max_chunklen = 0,
10281020
bool recover = true)
10291021
: channel_count(info.channel_count()),
@@ -1066,7 +1058,7 @@ class stream_inlet {
10661058
/** Subscribe to the data stream.
10671059
* All samples pushed in at the other end from this moment onwards will be queued and
10681060
* eventually be delivered in response to pull_sample() or pull_chunk() calls.
1069-
* Pulling a sample without some preceding open_stream is permitted (the stream will then be
1061+
* Pulling a sample without some preceding open_stream() is permitted (the stream will then be
10701062
* opened implicitly).
10711063
* @param timeout Optional timeout of the operation (default: no timeout).
10721064
* @throws timeout_error (if the timeout expires), or lost_error (if the stream source has been
@@ -1090,19 +1082,18 @@ class stream_inlet {
10901082

10911083
/** Retrieve an estimated time correction offset for the given stream.
10921084
*
1093-
* The first call to this function takes several milliseconds until a reliable first
1094-
* estimate is obtained. Subsequent calls are instantaneous (and rely on periodic background
1095-
* updates). On a well-behaved network, the precision of these estimates should be below 1
1096-
* ms (empirically it is within +/-0.2 ms).
1085+
* The first call to this function takes several milliseconds until a reliable first estimate
1086+
* is obtained. Subsequent calls are instantaneous (and rely on periodic background updates).
1087+
* On a well-behaved network, the precision of these estimates should be below 1 ms
1088+
* (empirically it is within +/-0.2 ms).
1089+
*
10971090
* To get a measure of whether the network is well-behaved, use the extended version
1098-
* time_correction(double*,double*,double)
1099-
* and check uncertainty (which maps to round-trip-time).
1091+
* time_correction(double*,double*,double) and check uncertainty (i.e. the round-trip-time).
11001092
*
11011093
* 0.2 ms is typical of wired networks. 2 ms is typical of wireless networks.
11021094
* The number can be much higher on poor networks.
11031095
*
1104-
* @param timeout Timeout to acquire the first time-correction estimate (default: no
1105-
* timeout).
1096+
* @param timeout Timeout to acquire the first time-correction estimate (default: no timeout).
11061097
* @return The time correction estimate. This is the number that needs to be added to a time
11071098
* stamp that was remotely generated via lsl_local_clock() to map it into the local clock
11081099
* domain of this machine.
@@ -1135,8 +1126,8 @@ class stream_inlet {
11351126
* stamps, which can then be manually synchronized using .time_correction(), and then
11361127
* smoothed/dejittered if desired.<br>
11371128
* This function allows automating these two and possibly more operations.<br>
1138-
* Warning: when you enable this, you will no longer receive or be able to recover the
1139-
* original time stamps.
1129+
* @warning When you enable this, you will no longer receive or be able to recover the original
1130+
* time stamps.
11401131
* @param flags An integer that is the result of bitwise OR'ing one or more options from
11411132
* processing_options_t together (e.g., `post_clocksync|post_dejitter`); the default is to
11421133
* enable all options.
@@ -1376,8 +1367,7 @@ class stream_inlet {
13761367
*
13771368
* This is a high-performance function that performs no memory allocations
13781369
* (useful for very high data rates or on low-powered devices).
1379-
* IMPORTANT: Note that the provided data buffer size is measured in channel values (e.g.,
1380-
* floats) rather than in samples.
1370+
* @warning The provided buffer size is measured in channel values (e.g., floats), not samples.
13811371
* @param data_buffer A pointer to a buffer of data values where the results shall be stored.
13821372
* @param timestamp_buffer A pointer to a buffer of timestamp values where time stamps shall be
13831373
* stored. If this is NULL, no time stamps will be returned.
@@ -1575,6 +1565,9 @@ class stream_inlet {
15751565
*/
15761566
std::size_t samples_available() { return lsl_samples_available(obj); }
15771567

1568+
/// Drop all queued not-yet pulled samples, return the nr of dropped samples
1569+
uint32_t flush() noexcept { return lsl_inlet_flush(obj); }
1570+
15781571
/**
15791572
* Query whether the clock was potentially reset since the last call to was_clock_reset().
15801573
*

lslboost/serialization_objects.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,6 @@
88
#include "libs/serialization/src/extended_type_info.cpp"
99
#include "libs/serialization/src/extended_type_info_typeid.cpp"
1010
#include "libs/serialization/src/void_cast.cpp"
11+
#ifdef _WIN32
12+
#include "lslboost/libs/serialization/src/codecvt_null.cpp"
13+
#endif

src/consumer_queue.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,10 @@ sample_p consumer_queue::pop_sample(double timeout) {
4444
return result;
4545
}
4646

47+
uint32_t consumer_queue::flush() noexcept {
48+
uint32_t n = 0;
49+
while (buffer_.pop()) n++;
50+
return n;
51+
}
52+
4753
bool consumer_queue::empty() { return buffer_.empty(); }

src/consumer_queue.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ class consumer_queue : private lslboost::noncopyable {
3939
*/
4040
sample_p pop_sample(double timeout = FOREVER);
4141

42+
/// Number of available samples
43+
std::size_t read_available() const { return buffer_.read_available(); }
44+
45+
/// Flush the queue, return the number of dropped samples
46+
uint32_t flush() noexcept;
47+
4248
/// Check whether the buffer is empty.
4349
bool empty();
4450

src/data_receiver.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ class data_receiver : public cancellable_registry {
7070
/// Check whether the underlying buffer is empty. This value may be inaccurate.
7171
bool empty() { return sample_queue_.empty(); }
7272

73+
/// Flush the queue, return the number of dropped samples
74+
uint32_t flush() noexcept { return sample_queue_.flush(); }
75+
7376
private:
7477
/// The data reader thread.
7578
void data_thread();

src/lsl_inlet_c.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,10 @@ LIBLSL_C_API uint32_t lsl_samples_available(lsl_inlet in) {
357357
} catch (std::exception &) { return 0; }
358358
}
359359

360+
LIBLSL_C_API uint32_t lsl_inlet_flush(lsl_inlet in) {
361+
return in->flush();
362+
}
363+
360364
LIBLSL_C_API uint32_t lsl_was_clock_reset(lsl_inlet in) {
361365
try {
362366
return (uint32_t)in->was_clock_reset();

src/resolve_attempt_udp.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#include "resolver_impl.h"
44
#include "socket_utils.h"
55
#include <boost/asio/ip/multicast.hpp>
6-
#include <boost/asio/placeholders.hpp>
76
#include <sstream>
87

98
using namespace lsl;

src/resolver_impl.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#include "resolve_attempt_udp.h"
44
#include "socket_utils.h"
55
#include <boost/asio/ip/udp.hpp>
6-
#include <boost/asio/placeholders.hpp>
76
#include <boost/thread/thread_only.hpp>
87
#include <memory>
98

0 commit comments

Comments
 (0)