Closed cboulay closed 2 years ago
Disabling the transfer_samples_thread
leads to errors on the inlet at chunk boundaries on line https://github.com/sccn/liblsl/blob/cboulay/outlet_sync/src/data_receiver.cpp#L317-L318 . If I leave the do-nothing thread in place then it seems to work fine. :shrug:
Note to self: disable synchronous-write-mode when data format is string or when byte order is not default.
Thanks @tstenner for pointing out that the transfer_samples_thread
becomes the sole owner of the client_session
. Without the thread we would need the client_session
to exist elsewhere. Maybe in a container with the socket? I don't know yet.
Rebased on #146 which was recently rebased on #155. Still a little work to do here.
I made some changes based on your suggestions. However, the multiple-client code is probably still broken. I had to deprioritize that due to time constraints. I hope to get back to this soon.
I discovered that outlet.have_consumers
doesn't work properly in sync mode.
Closing in favour of #170
This implements a code path that allows for synchronous (blocked) calls to
push_*
by setting an outlet constructor argumentdo_async
tofalse
or0
. In this path,liblsl
performs 0 (zero) copies on the data, compared to the 2 copies performed wen doing asynchronous writing. This can have dramatic speed / CPU usage improvements when using high bandwidth data (18%->5% in one of my tests).Note that this contains some commits from the
double_buflen
branch. Currently the only relevant commit to examine is c64aeb9.Some concerns:
push_*
depends on how many consumers are added. This can lead to unpredictable user experience unless the user application callspush_*
from a non-interactive thread.transfer_samples_thread
but this did not work out. So now we have a thread doing nothing. I will try again.do_async
flag on the very newlsl_create_outlet_ex
C method, and preserved the API of the existinglsl_create_outlet
method.#include <asio/buffer.hpp>
for private memberstd::vector<asio::const_buffer> sync_buffs_
. A future revision should change this tostd::vector<const_buffer_p>
defined elsewhere.push_buffers_directly(std::vector<buffer_type> buffers, double timestamp, std::vector<std::size_t> frame_indices)
whereframe_indices
gives the indices inbuffers
that start a new frame (frame := multi-channel sample). The goal is to enable the user to push discontiguous frames (e.g., disabled channels still allocated in device buffer) without first copying to a contiguous frame. I'm not sure I actually need this.