Skip to content

Commit 85d7239

Browse files
committed
Further tweak to Chunks examples.
1 parent b044b49 commit 85d7239

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

examples/ReceiveDataInChunks.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,20 @@
44

55

66
int main(int argc, char **argv) {
7+
std::cout << "ReceiveDataInChunks" << std::endl;
8+
std::cout << "ReceiveDataInChunks StreamName max_buflen" << std::endl;
9+
710
try {
811

912
std::string name{argc > 1 ? argv[1] : "MyAudioStream"};
13+
int32_t max_buflen = argc > 2 ? std::stol(argv[2]) : 360;
1014
// resolve the stream of interest & make an inlet
11-
lsl::stream_inlet inlet(lsl::resolve_stream("name", name).at(0));
15+
lsl::stream_inlet inlet(lsl::resolve_stream("name", name).at(0), max_buflen);
1216

1317
inlet.flush();
1418

15-
double starttime = lsl::local_clock(), next_display = starttime + 1;
19+
double starttime = lsl::local_clock(), next_display = starttime + 1,
20+
next_reset = starttime + 10;
1621

1722
// and retrieve the chunks
1823
uint64_t k = 0, num_samples = 0;
@@ -29,7 +34,13 @@ int main(int argc, char **argv) {
2934
std::cout << num_samples / (now - starttime) << " samples/sec" << std::endl;
3035
next_display = now + 1;
3136
}
37+
if (now > next_reset) { std::cout << "Resetting counters..." << std::endl;
38+
starttime = now;
39+
next_reset = now + 10;
40+
num_samples = 0;
41+
}
3242
}
43+
3344
}
3445

3546
} catch (std::exception &e) { std::cerr << "Got an exception: " << e.what() << std::endl; }

0 commit comments

Comments
 (0)