@@ -991,6 +991,8 @@ namespace lsl {
991991 * @param chunk A vector to hold the multiplexed (Sample 1 Channel 1,
992992 * S1C2, S2C1, S2C2, S3C1, S3C2, ...) samples
993993 * @param timestamps A vector to hold the timestamps or nullptr
994+ * @param timeout Time to wait for the first sample. The default value of 0.0 will not wait
995+ * for data to arrive, pulling only samples already received.
994996 * @param append (True:) Append data or (false:) clear them first
995997 * @return True if some data was obtained.
996998 * @throws lost_error (if the stream source has been lost).
@@ -1003,12 +1005,16 @@ namespace lsl {
10031005 chunk.clear ();
10041006 if (timestamps) timestamps->clear ();
10051007 }
1008+ std::vector<T> sample;
1009+ double ts;
1010+ if ((ts = pull_sample (sample, timeout)) == 0.0 ) return false ;
1011+ chunk.insert (chunk.end (), sample.begin (), sample.end ());
1012+ if (timestamps) timestamps->push_back (ts);
10061013 const auto target = samples_available ();
10071014 chunk.reserve (chunk.size () + target * this ->channel_count );
10081015 if (timestamps)
10091016 timestamps->reserve (timestamps->size () + target);
1010- std::vector<T> sample;
1011- while (double ts = pull_sample (sample, timeout)) {
1017+ while ((ts = pull_sample (sample, 0.0 )) != 0.0 ) {
10121018#if __cplusplus > 199711L || _MSC_VER >= 1900
10131019 chunk.insert (chunk.end (),
10141020 std::make_move_iterator (sample.begin ()),
@@ -1018,7 +1024,7 @@ namespace lsl {
10181024#endif
10191025 if (timestamps) timestamps->push_back (ts);
10201026 }
1021- return !chunk. empty () ;
1027+ return true ;
10221028 }
10231029
10241030 /* *
0 commit comments