diff --git a/include/lsl/inlet.h b/include/lsl/inlet.h index 78aa60d90..8335a55ee 100644 --- a/include/lsl/inlet.h +++ b/include/lsl/inlet.h @@ -2,6 +2,8 @@ #include "common.h" #include "types.h" +#include + /// @file inlet.h Stream inlet functions @@ -168,7 +170,7 @@ extern LIBLSL_C_API double lsl_pull_sample_d(lsl_inlet in, double *buffer, int32 extern LIBLSL_C_API double lsl_pull_sample_l(lsl_inlet in, int64_t *buffer, int32_t buffer_elements, double timeout, int32_t *ec); extern LIBLSL_C_API double lsl_pull_sample_i(lsl_inlet in, int32_t *buffer, int32_t buffer_elements, double timeout, int32_t *ec); extern LIBLSL_C_API double lsl_pull_sample_s(lsl_inlet in, int16_t *buffer, int32_t buffer_elements, double timeout, int32_t *ec); -extern LIBLSL_C_API double lsl_pull_sample_c(lsl_inlet in, char *buffer, int32_t buffer_elements, double timeout, int32_t *ec); +extern LIBLSL_C_API double lsl_pull_sample_c(lsl_inlet in, int8_t *buffer, int32_t buffer_elements, double timeout, int32_t *ec); extern LIBLSL_C_API double lsl_pull_sample_str(lsl_inlet in, char **buffer, int32_t buffer_elements, double timeout, int32_t *ec); ///@} @@ -228,13 +230,13 @@ extern LIBLSL_C_API double lsl_pull_sample_v(lsl_inlet in, void *buffer, int32_t * @return data_elements_written Number of channel data elements written to the data buffer. * @{ */ -extern LIBLSL_C_API unsigned long lsl_pull_chunk_f(lsl_inlet in, float *data_buffer, double *timestamp_buffer, unsigned long data_buffer_elements, unsigned long timestamp_buffer_elements, double timeout, int32_t *ec); -extern LIBLSL_C_API unsigned long lsl_pull_chunk_d(lsl_inlet in, double *data_buffer, double *timestamp_buffer, unsigned long data_buffer_elements, unsigned long timestamp_buffer_elements, double timeout, int32_t *ec); -extern LIBLSL_C_API unsigned long lsl_pull_chunk_l(lsl_inlet in, int64_t *data_buffer, double *timestamp_buffer, unsigned long data_buffer_elements, unsigned long timestamp_buffer_elements, double timeout, int32_t *ec); -extern LIBLSL_C_API unsigned long lsl_pull_chunk_i(lsl_inlet in, int32_t *data_buffer, double *timestamp_buffer, unsigned long data_buffer_elements, unsigned long timestamp_buffer_elements, double timeout, int32_t *ec); -extern LIBLSL_C_API unsigned long lsl_pull_chunk_s(lsl_inlet in, int16_t *data_buffer, double *timestamp_buffer, unsigned long data_buffer_elements, unsigned long timestamp_buffer_elements, double timeout, int32_t *ec); -extern LIBLSL_C_API unsigned long lsl_pull_chunk_c(lsl_inlet in, char *data_buffer, double *timestamp_buffer, unsigned long data_buffer_elements, unsigned long timestamp_buffer_elements, double timeout, int32_t *ec); -extern LIBLSL_C_API unsigned long lsl_pull_chunk_str(lsl_inlet in, char **data_buffer, double *timestamp_buffer, unsigned long data_buffer_elements, unsigned long timestamp_buffer_elements, double timeout, int32_t *ec); +extern LIBLSL_C_API size_t lsl_pull_chunk_f(lsl_inlet in, float *data_buffer, double *timestamp_buffer, size_t data_buffer_elements, size_t timestamp_buffer_elements, double timeout, int32_t *ec); +extern LIBLSL_C_API size_t lsl_pull_chunk_d(lsl_inlet in, double *data_buffer, double *timestamp_buffer, size_t data_buffer_elements, size_t timestamp_buffer_elements, double timeout, int32_t *ec); +extern LIBLSL_C_API size_t lsl_pull_chunk_l(lsl_inlet in, int64_t *data_buffer, double *timestamp_buffer, size_t data_buffer_elements, size_t timestamp_buffer_elements, double timeout, int32_t *ec); +extern LIBLSL_C_API size_t lsl_pull_chunk_i(lsl_inlet in, int32_t *data_buffer, double *timestamp_buffer, size_t data_buffer_elements, size_t timestamp_buffer_elements, double timeout, int32_t *ec); +extern LIBLSL_C_API size_t lsl_pull_chunk_s(lsl_inlet in, int16_t *data_buffer, double *timestamp_buffer, size_t data_buffer_elements, size_t timestamp_buffer_elements, double timeout, int32_t *ec); +extern LIBLSL_C_API size_t lsl_pull_chunk_c(lsl_inlet in, int8_t *data_buffer, double *timestamp_buffer, size_t data_buffer_elements, size_t timestamp_buffer_elements, double timeout, int32_t *ec); +extern LIBLSL_C_API size_t lsl_pull_chunk_str(lsl_inlet in, char **data_buffer, double *timestamp_buffer, size_t data_buffer_elements, size_t timestamp_buffer_elements, double timeout, int32_t *ec); ///@} @@ -267,7 +269,7 @@ extern LIBLSL_C_API unsigned long lsl_pull_chunk_str(lsl_inlet in, char **data_b * @return data_elements_written Number of channel data elements written to the data buffer. */ -extern LIBLSL_C_API unsigned long lsl_pull_chunk_buf(lsl_inlet in, char **data_buffer, uint32_t *lengths_buffer, double *timestamp_buffer, unsigned long data_buffer_elements, unsigned long timestamp_buffer_elements, double timeout, int32_t *ec); +extern LIBLSL_C_API size_t lsl_pull_chunk_buf(lsl_inlet in, char **data_buffer, uint32_t *lengths_buffer, double *timestamp_buffer, size_t data_buffer_elements, size_t timestamp_buffer_elements, double timeout, int32_t *ec); /** * Query whether samples are currently available for immediate pickup. diff --git a/include/lsl/outlet.h b/include/lsl/outlet.h index 937fde47b..e0f4b0334 100644 --- a/include/lsl/outlet.h +++ b/include/lsl/outlet.h @@ -2,6 +2,8 @@ #include "./common.h" #include "types.h" +#include + /// @file outlet.h Stream outlet functions /** @defgroup outlet The lsl_outlet object @@ -63,7 +65,7 @@ extern LIBLSL_C_API int32_t lsl_push_sample_d(lsl_outlet out, const double *data extern LIBLSL_C_API int32_t lsl_push_sample_l(lsl_outlet out, const int64_t *data); extern LIBLSL_C_API int32_t lsl_push_sample_i(lsl_outlet out, const int32_t *data); extern LIBLSL_C_API int32_t lsl_push_sample_s(lsl_outlet out, const int16_t *data); -extern LIBLSL_C_API int32_t lsl_push_sample_c(lsl_outlet out, const char *data); +extern LIBLSL_C_API int32_t lsl_push_sample_c(lsl_outlet out, const int8_t *data); extern LIBLSL_C_API int32_t lsl_push_sample_str(lsl_outlet out, const char **data); extern LIBLSL_C_API int32_t lsl_push_sample_v(lsl_outlet out, const void *data); /// @} @@ -77,7 +79,7 @@ extern LIBLSL_C_API int32_t lsl_push_sample_dt(lsl_outlet out, const double *dat extern LIBLSL_C_API int32_t lsl_push_sample_lt(lsl_outlet out, const int64_t *data, double timestamp); extern LIBLSL_C_API int32_t lsl_push_sample_it(lsl_outlet out, const int32_t *data, double timestamp); extern LIBLSL_C_API int32_t lsl_push_sample_st(lsl_outlet out, const int16_t *data, double timestamp); -extern LIBLSL_C_API int32_t lsl_push_sample_ct(lsl_outlet out, const char *data, double timestamp); +extern LIBLSL_C_API int32_t lsl_push_sample_ct(lsl_outlet out, const int8_t *data, double timestamp); extern LIBLSL_C_API int32_t lsl_push_sample_strt(lsl_outlet out, const char **data, double timestamp); extern LIBLSL_C_API int32_t lsl_push_sample_vt(lsl_outlet out, const void *data, double timestamp); /// @} @@ -92,7 +94,7 @@ extern LIBLSL_C_API int32_t lsl_push_sample_dtp(lsl_outlet out, const double *da extern LIBLSL_C_API int32_t lsl_push_sample_ltp(lsl_outlet out, const int64_t *data, double timestamp, int32_t pushthrough); extern LIBLSL_C_API int32_t lsl_push_sample_itp(lsl_outlet out, const int32_t *data, double timestamp, int32_t pushthrough); extern LIBLSL_C_API int32_t lsl_push_sample_stp(lsl_outlet out, const int16_t *data, double timestamp, int32_t pushthrough); -extern LIBLSL_C_API int32_t lsl_push_sample_ctp(lsl_outlet out, const char *data, double timestamp, int32_t pushthrough); +extern LIBLSL_C_API int32_t lsl_push_sample_ctp(lsl_outlet out, const int8_t *data, double timestamp, int32_t pushthrough); extern LIBLSL_C_API int32_t lsl_push_sample_strtp(lsl_outlet out, const char **data, double timestamp, int32_t pushthrough); extern LIBLSL_C_API int32_t lsl_push_sample_vtp(lsl_outlet out, const void *data, double timestamp, int32_t pushthrough); ///@} @@ -126,13 +128,13 @@ extern LIBLSL_C_API int32_t lsl_push_sample_buftp(lsl_outlet out, const char **d * @return Error code of the operation (usually attributed to the wrong data type). * @{ */ -extern LIBLSL_C_API int32_t lsl_push_chunk_f(lsl_outlet out, const float *data, unsigned long data_elements); -extern LIBLSL_C_API int32_t lsl_push_chunk_d(lsl_outlet out, const double *data, unsigned long data_elements); -extern LIBLSL_C_API int32_t lsl_push_chunk_l(lsl_outlet out, const int64_t *data, unsigned long data_elements); -extern LIBLSL_C_API int32_t lsl_push_chunk_i(lsl_outlet out, const int32_t *data, unsigned long data_elements); -extern LIBLSL_C_API int32_t lsl_push_chunk_s(lsl_outlet out, const int16_t *data, unsigned long data_elements); -extern LIBLSL_C_API int32_t lsl_push_chunk_c(lsl_outlet out, const char *data, unsigned long data_elements); -extern LIBLSL_C_API int32_t lsl_push_chunk_str(lsl_outlet out, const char **data, unsigned long data_elements); +extern LIBLSL_C_API int32_t lsl_push_chunk_f(lsl_outlet out, const float *data, size_t data_elements); +extern LIBLSL_C_API int32_t lsl_push_chunk_d(lsl_outlet out, const double *data, size_t data_elements); +extern LIBLSL_C_API int32_t lsl_push_chunk_l(lsl_outlet out, const int64_t *data, size_t data_elements); +extern LIBLSL_C_API int32_t lsl_push_chunk_i(lsl_outlet out, const int32_t *data, size_t data_elements); +extern LIBLSL_C_API int32_t lsl_push_chunk_s(lsl_outlet out, const int16_t *data, size_t data_elements); +extern LIBLSL_C_API int32_t lsl_push_chunk_c(lsl_outlet out, const int8_t *data, size_t data_elements); +extern LIBLSL_C_API int32_t lsl_push_chunk_str(lsl_outlet out, const char **data, size_t data_elements); /// @} /** @copydoc lsl_push_chunk_f @@ -142,13 +144,13 @@ extern LIBLSL_C_API int32_t lsl_push_chunk_str(lsl_outlet out, const char **data * stream. * @{ */ -extern LIBLSL_C_API int32_t lsl_push_chunk_ft(lsl_outlet out, const float *data, unsigned long data_elements, double timestamp); -extern LIBLSL_C_API int32_t lsl_push_chunk_dt(lsl_outlet out, const double *data, unsigned long data_elements, double timestamp); -extern LIBLSL_C_API int32_t lsl_push_chunk_lt(lsl_outlet out, const int64_t *data, unsigned long data_elements, double timestamp); -extern LIBLSL_C_API int32_t lsl_push_chunk_it(lsl_outlet out, const int32_t *data, unsigned long data_elements, double timestamp); -extern LIBLSL_C_API int32_t lsl_push_chunk_st(lsl_outlet out, const int16_t *data, unsigned long data_elements, double timestamp); -extern LIBLSL_C_API int32_t lsl_push_chunk_ct(lsl_outlet out, const char *data, unsigned long data_elements, double timestamp); -extern LIBLSL_C_API int32_t lsl_push_chunk_strt(lsl_outlet out, const char **data, unsigned long data_elements, double timestamp); +extern LIBLSL_C_API int32_t lsl_push_chunk_ft(lsl_outlet out, const float *data, size_t data_elements, double timestamp); +extern LIBLSL_C_API int32_t lsl_push_chunk_dt(lsl_outlet out, const double *data, size_t data_elements, double timestamp); +extern LIBLSL_C_API int32_t lsl_push_chunk_lt(lsl_outlet out, const int64_t *data, size_t data_elements, double timestamp); +extern LIBLSL_C_API int32_t lsl_push_chunk_it(lsl_outlet out, const int32_t *data, size_t data_elements, double timestamp); +extern LIBLSL_C_API int32_t lsl_push_chunk_st(lsl_outlet out, const int16_t *data, size_t data_elements, double timestamp); +extern LIBLSL_C_API int32_t lsl_push_chunk_ct(lsl_outlet out, const int8_t *data, size_t data_elements, double timestamp); +extern LIBLSL_C_API int32_t lsl_push_chunk_strt(lsl_outlet out, const char **data, size_t data_elements, double timestamp); /// @} /** @copydoc lsl_push_chunk_ft @@ -157,25 +159,25 @@ extern LIBLSL_C_API int32_t lsl_push_chunk_strt(lsl_outlet out, const char **dat * precedence over the pushthrough flag. * @{ */ -extern LIBLSL_C_API int32_t lsl_push_chunk_ftp(lsl_outlet out, const float *data, unsigned long data_elements, double timestamp, int32_t pushthrough); -extern LIBLSL_C_API int32_t lsl_push_chunk_dtp(lsl_outlet out, const double *data, unsigned long data_elements, double timestamp, int32_t pushthrough); -extern LIBLSL_C_API int32_t lsl_push_chunk_ltp(lsl_outlet out, const int64_t *data, unsigned long data_elements, double timestamp, int32_t pushthrough); -extern LIBLSL_C_API int32_t lsl_push_chunk_itp(lsl_outlet out, const int32_t *data, unsigned long data_elements, double timestamp, int32_t pushthrough); -extern LIBLSL_C_API int32_t lsl_push_chunk_stp(lsl_outlet out, const int16_t *data, unsigned long data_elements, double timestamp, int32_t pushthrough); -extern LIBLSL_C_API int32_t lsl_push_chunk_ctp(lsl_outlet out, const char *data, unsigned long data_elements, double timestamp, int32_t pushthrough); -extern LIBLSL_C_API int32_t lsl_push_chunk_strtp(lsl_outlet out, const char **data, unsigned long data_elements, double timestamp, int32_t pushthrough); +extern LIBLSL_C_API int32_t lsl_push_chunk_ftp(lsl_outlet out, const float *data, size_t data_elements, double timestamp, int32_t pushthrough); +extern LIBLSL_C_API int32_t lsl_push_chunk_dtp(lsl_outlet out, const double *data, size_t data_elements, double timestamp, int32_t pushthrough); +extern LIBLSL_C_API int32_t lsl_push_chunk_ltp(lsl_outlet out, const int64_t *data, size_t data_elements, double timestamp, int32_t pushthrough); +extern LIBLSL_C_API int32_t lsl_push_chunk_itp(lsl_outlet out, const int32_t *data, size_t data_elements, double timestamp, int32_t pushthrough); +extern LIBLSL_C_API int32_t lsl_push_chunk_stp(lsl_outlet out, const int16_t *data, size_t data_elements, double timestamp, int32_t pushthrough); +extern LIBLSL_C_API int32_t lsl_push_chunk_ctp(lsl_outlet out, const int8_t *data, size_t data_elements, double timestamp, int32_t pushthrough); +extern LIBLSL_C_API int32_t lsl_push_chunk_strtp(lsl_outlet out, const char **data, size_t data_elements, double timestamp, int32_t pushthrough); /// @} /** @copydoc lsl_push_chunk_f * @param timestamps Buffer holding one time stamp for each sample in the data buffer. * @{ */ -extern LIBLSL_C_API int32_t lsl_push_chunk_ftn(lsl_outlet out, const float *data, unsigned long data_elements, const double *timestamps); -extern LIBLSL_C_API int32_t lsl_push_chunk_dtn(lsl_outlet out, const double *data, unsigned long data_elements, const double *timestamps); -extern LIBLSL_C_API int32_t lsl_push_chunk_ltn(lsl_outlet out, const int64_t *data, unsigned long data_elements, const double *timestamps); -extern LIBLSL_C_API int32_t lsl_push_chunk_itn(lsl_outlet out, const int32_t *data, unsigned long data_elements, const double *timestamps); -extern LIBLSL_C_API int32_t lsl_push_chunk_stn(lsl_outlet out, const int16_t *data, unsigned long data_elements, const double *timestamps); -extern LIBLSL_C_API int32_t lsl_push_chunk_ctn(lsl_outlet out, const char *data, unsigned long data_elements, const double *timestamps); -extern LIBLSL_C_API int32_t lsl_push_chunk_strtn(lsl_outlet out, const char **data, unsigned long data_elements, const double *timestamps); +extern LIBLSL_C_API int32_t lsl_push_chunk_ftn(lsl_outlet out, const float *data, size_t data_elements, const double *timestamps); +extern LIBLSL_C_API int32_t lsl_push_chunk_dtn(lsl_outlet out, const double *data, size_t data_elements, const double *timestamps); +extern LIBLSL_C_API int32_t lsl_push_chunk_ltn(lsl_outlet out, const int64_t *data, size_t data_elements, const double *timestamps); +extern LIBLSL_C_API int32_t lsl_push_chunk_itn(lsl_outlet out, const int32_t *data, size_t data_elements, const double *timestamps); +extern LIBLSL_C_API int32_t lsl_push_chunk_stn(lsl_outlet out, const int16_t *data, size_t data_elements, const double *timestamps); +extern LIBLSL_C_API int32_t lsl_push_chunk_ctn(lsl_outlet out, const int8_t *data, size_t data_elements, const double *timestamps); +extern LIBLSL_C_API int32_t lsl_push_chunk_strtn(lsl_outlet out, const char **data, size_t data_elements, const double *timestamps); /// @} /** @copydoc lsl_push_chunk_ftn @@ -184,13 +186,13 @@ extern LIBLSL_C_API int32_t lsl_push_chunk_strtn(lsl_outlet out, const char **da * precedence over the pushthrough flag. * @{ */ -extern LIBLSL_C_API int32_t lsl_push_chunk_ftnp(lsl_outlet out, const float *data, unsigned long data_elements, const double *timestamps, int32_t pushthrough); -extern LIBLSL_C_API int32_t lsl_push_chunk_dtnp(lsl_outlet out, const double *data, unsigned long data_elements, const double *timestamps, int32_t pushthrough); -extern LIBLSL_C_API int32_t lsl_push_chunk_ltnp(lsl_outlet out, const int64_t *data, unsigned long data_elements, const double *timestamps, int32_t pushthrough); -extern LIBLSL_C_API int32_t lsl_push_chunk_itnp(lsl_outlet out, const int32_t *data, unsigned long data_elements, const double *timestamps, int32_t pushthrough); -extern LIBLSL_C_API int32_t lsl_push_chunk_stnp(lsl_outlet out, const int16_t *data, unsigned long data_elements, const double *timestamps, int32_t pushthrough); -extern LIBLSL_C_API int32_t lsl_push_chunk_ctnp(lsl_outlet out, const char *data, unsigned long data_elements, const double *timestamps, int32_t pushthrough); -extern LIBLSL_C_API int32_t lsl_push_chunk_strtnp(lsl_outlet out, const char **data, unsigned long data_elements, const double *timestamps, int32_t pushthrough); +extern LIBLSL_C_API int32_t lsl_push_chunk_ftnp(lsl_outlet out, const float *data, size_t data_elements, const double *timestamps, int32_t pushthrough); +extern LIBLSL_C_API int32_t lsl_push_chunk_dtnp(lsl_outlet out, const double *data, size_t data_elements, const double *timestamps, int32_t pushthrough); +extern LIBLSL_C_API int32_t lsl_push_chunk_ltnp(lsl_outlet out, const int64_t *data, size_t data_elements, const double *timestamps, int32_t pushthrough); +extern LIBLSL_C_API int32_t lsl_push_chunk_itnp(lsl_outlet out, const int32_t *data, size_t data_elements, const double *timestamps, int32_t pushthrough); +extern LIBLSL_C_API int32_t lsl_push_chunk_stnp(lsl_outlet out, const int16_t *data, size_t data_elements, const double *timestamps, int32_t pushthrough); +extern LIBLSL_C_API int32_t lsl_push_chunk_ctnp(lsl_outlet out, const int8_t *data, size_t data_elements, const double *timestamps, int32_t pushthrough); +extern LIBLSL_C_API int32_t lsl_push_chunk_strtnp(lsl_outlet out, const char **data, size_t data_elements, const double *timestamps, int32_t pushthrough); ///@} /** @copybrief lsl_push_chunk_ftp @@ -202,30 +204,30 @@ extern LIBLSL_C_API int32_t lsl_push_chunk_strtnp(lsl_outlet out, const char **d * @param data_elements The number of data values in the data buffer. * Must be a multiple of the channel count. */ -extern LIBLSL_C_API int32_t lsl_push_chunk_buf(lsl_outlet out, const char **data, const uint32_t *lengths, unsigned long data_elements); +extern LIBLSL_C_API int32_t lsl_push_chunk_buf(lsl_outlet out, const char **data, const uint32_t *lengths, size_t data_elements); /** @copydoc lsl_push_chunk_buf @sa lsl_push_chunk_ftp @sa lsl_push_chunk_buf * @param timestamp Optionally the capture time of the most recent sample, in agreement with * lsl_local_clock(); if omitted, the current time is used. * The time stamps of other samples are automatically derived based on the sampling rate of the * stream. */ -extern LIBLSL_C_API int32_t lsl_push_chunk_buft(lsl_outlet out, const char **data, const uint32_t *lengths, unsigned long data_elements, double timestamp); +extern LIBLSL_C_API int32_t lsl_push_chunk_buft(lsl_outlet out, const char **data, const uint32_t *lengths, size_t data_elements, double timestamp); /** @copydoc lsl_push_chunk_buft @sa lsl_push_chunk_ftp @sa lsl_push_chunk_buf * @param pushthrough Whether to push the chunk through to the receivers instead of buffering it * with subsequent samples. Note that the chunk_size, if specified at outlet construction, takes * precedence over the pushthrough flag. */ -extern LIBLSL_C_API int32_t lsl_push_chunk_buftp(lsl_outlet out, const char **data, const uint32_t *lengths, unsigned long data_elements, double timestamp, int32_t pushthrough); +extern LIBLSL_C_API int32_t lsl_push_chunk_buftp(lsl_outlet out, const char **data, const uint32_t *lengths, size_t data_elements, double timestamp, int32_t pushthrough); /** @copydoc lsl_push_chunk_buf @sa lsl_push_chunk_ftp @sa lsl_push_chunk_buf * @param timestamps Buffer holding one time stamp for each sample in the data buffer. */ -extern LIBLSL_C_API int32_t lsl_push_chunk_buftn(lsl_outlet out, const char **data, const uint32_t *lengths, unsigned long data_elements, const double *timestamps); +extern LIBLSL_C_API int32_t lsl_push_chunk_buftn(lsl_outlet out, const char **data, const uint32_t *lengths, size_t data_elements, const double *timestamps); /** @copydoc lsl_push_chunk_buftn @sa lsl_push_chunk_ftp @sa lsl_push_chunk_buf * @param pushthrough Whether to push the chunk through to the receivers instead of buffering it * with subsequent samples. Note that the chunk_size, if specified at outlet construction, takes * precedence over the pushthrough flag. */ -extern LIBLSL_C_API int32_t lsl_push_chunk_buftnp(lsl_outlet out, const char **data, const uint32_t *lengths, unsigned long data_elements, const double *timestamps, int32_t pushthrough); +extern LIBLSL_C_API int32_t lsl_push_chunk_buftnp(lsl_outlet out, const char **data, const uint32_t *lengths, size_t data_elements, const double *timestamps, int32_t pushthrough); /** * Check whether consumers are currently registered. diff --git a/include/lsl_cpp.h b/include/lsl_cpp.h index f249d4596..e28cf1c26 100644 --- a/include/lsl_cpp.h +++ b/include/lsl_cpp.h @@ -477,9 +477,12 @@ class stream_outlet { void push_sample(const int16_t *data, double timestamp = 0.0, bool pushthrough = true) { lsl_push_sample_stp(obj.get(), (data), timestamp, pushthrough); } - void push_sample(const char *data, double timestamp = 0.0, bool pushthrough = true) { + void push_sample(const int8_t *data, double timestamp = 0.0, bool pushthrough = true) { lsl_push_sample_ctp(obj.get(), (data), timestamp, pushthrough); } + void push_sample(const char *data, double timestamp = 0.0, bool pushthrough = true) { + lsl_push_sample_ctp(obj.get(), reinterpret_cast(data), timestamp, pushthrough); + } void push_sample(const std::string *data, double timestamp = 0.0, bool pushthrough = true) { std::vector lengths(channel_count); std::vector pointers(channel_count); @@ -626,7 +629,7 @@ class stream_outlet { const std::vector &buffer, double timestamp = 0.0, bool pushthrough = true) { if (!buffer.empty()) push_chunk_multiplexed( - buffer.data(), static_cast(buffer.size()), timestamp, pushthrough); + buffer.data(), static_cast(buffer.size()), timestamp, pushthrough); } /** Push a chunk of multiplexed data into the outlet. One timestamp per sample is provided. @@ -644,7 +647,7 @@ class stream_outlet { const std::vector ×tamps, bool pushthrough = true) { if (!buffer.empty() && !timestamps.empty()) push_chunk_multiplexed( - buffer.data(), static_cast(buffer.size()), timestamps.data(), pushthrough); + buffer.data(), static_cast(buffer.size()), timestamps.data(), pushthrough); } /** Push a chunk of multiplexed samples into the outlet. Single timestamp provided. @@ -662,27 +665,32 @@ class stream_outlet { */ void push_chunk_multiplexed(const float *buffer, std::size_t buffer_elements, double timestamp = 0.0, bool pushthrough = true) { - lsl_push_chunk_ftp(obj.get(), buffer, static_cast(buffer_elements), timestamp, pushthrough); + lsl_push_chunk_ftp(obj.get(), buffer, static_cast(buffer_elements), timestamp, pushthrough); } void push_chunk_multiplexed(const double *buffer, std::size_t buffer_elements, double timestamp = 0.0, bool pushthrough = true) { - lsl_push_chunk_dtp(obj.get(), buffer, static_cast(buffer_elements), timestamp, pushthrough); + lsl_push_chunk_dtp(obj.get(), buffer, static_cast(buffer_elements), timestamp, pushthrough); } void push_chunk_multiplexed(const int64_t *buffer, std::size_t buffer_elements, double timestamp = 0.0, bool pushthrough = true) { - lsl_push_chunk_ltp(obj.get(), buffer, static_cast(buffer_elements), timestamp, pushthrough); + lsl_push_chunk_ltp(obj.get(), buffer, static_cast(buffer_elements), timestamp, pushthrough); } void push_chunk_multiplexed(const int32_t *buffer, std::size_t buffer_elements, double timestamp = 0.0, bool pushthrough = true) { - lsl_push_chunk_itp(obj.get(), buffer, static_cast(buffer_elements), timestamp, pushthrough); + lsl_push_chunk_itp(obj.get(), buffer, static_cast(buffer_elements), timestamp, pushthrough); } void push_chunk_multiplexed(const int16_t *buffer, std::size_t buffer_elements, double timestamp = 0.0, bool pushthrough = true) { - lsl_push_chunk_stp(obj.get(), buffer, static_cast(buffer_elements), timestamp, pushthrough); + lsl_push_chunk_stp(obj.get(), buffer, static_cast(buffer_elements), timestamp, pushthrough); + } + void push_chunk_multiplexed(const int8_t *buffer, std::size_t buffer_elements, + double timestamp = 0.0, bool pushthrough = true) { + lsl_push_chunk_ctp(obj.get(), buffer, static_cast(buffer_elements), timestamp, pushthrough); } void push_chunk_multiplexed(const char *buffer, std::size_t buffer_elements, double timestamp = 0.0, bool pushthrough = true) { - lsl_push_chunk_ctp(obj.get(), buffer, static_cast(buffer_elements), timestamp, pushthrough); + lsl_push_chunk_ctp(obj.get(), reinterpret_cast(buffer), + static_cast(buffer_elements), timestamp, pushthrough); } void push_chunk_multiplexed(const std::string *buffer, std::size_t buffer_elements, double timestamp = 0.0, bool pushthrough = true) { @@ -694,7 +702,7 @@ class stream_outlet { lengths[k] = (uint32_t)buffer[k].size(); } lsl_push_chunk_buftp(obj.get(), pointers.data(), lengths.data(), - static_cast(buffer_elements), timestamp, pushthrough); + static_cast(buffer_elements), timestamp, pushthrough); } } @@ -713,34 +721,39 @@ class stream_outlet { */ void push_chunk_multiplexed(const float *data_buffer, const double *timestamp_buffer, std::size_t data_buffer_elements, bool pushthrough = true) { - lsl_push_chunk_ftnp(obj.get(), data_buffer, static_cast(data_buffer_elements), + lsl_push_chunk_ftnp(obj.get(), data_buffer, static_cast(data_buffer_elements), (timestamp_buffer), pushthrough); } void push_chunk_multiplexed(const double *data_buffer, const double *timestamp_buffer, std::size_t data_buffer_elements, bool pushthrough = true) { - lsl_push_chunk_dtnp(obj.get(), data_buffer, static_cast(data_buffer_elements), + lsl_push_chunk_dtnp(obj.get(), data_buffer, static_cast(data_buffer_elements), (timestamp_buffer), pushthrough); } void push_chunk_multiplexed(const int64_t *data_buffer, const double *timestamp_buffer, std::size_t data_buffer_elements, bool pushthrough = true) { - lsl_push_chunk_ltnp(obj.get(), data_buffer, static_cast(data_buffer_elements), + lsl_push_chunk_ltnp(obj.get(), data_buffer, static_cast(data_buffer_elements), (timestamp_buffer), pushthrough); } void push_chunk_multiplexed(const int32_t *data_buffer, const double *timestamp_buffer, std::size_t data_buffer_elements, bool pushthrough = true) { - lsl_push_chunk_itnp(obj.get(), data_buffer, static_cast(data_buffer_elements), + lsl_push_chunk_itnp(obj.get(), data_buffer, static_cast(data_buffer_elements), (timestamp_buffer), pushthrough); } void push_chunk_multiplexed(const int16_t *data_buffer, const double *timestamp_buffer, std::size_t data_buffer_elements, bool pushthrough = true) { - lsl_push_chunk_stnp(obj.get(), data_buffer, static_cast(data_buffer_elements), + lsl_push_chunk_stnp(obj.get(), data_buffer, static_cast(data_buffer_elements), (timestamp_buffer), pushthrough); } - void push_chunk_multiplexed(const char *data_buffer, const double *timestamp_buffer, + void push_chunk_multiplexed(const int8_t *data_buffer, const double *timestamp_buffer, std::size_t data_buffer_elements, bool pushthrough = true) { - lsl_push_chunk_ctnp(obj.get(), data_buffer, static_cast(data_buffer_elements), + lsl_push_chunk_ctnp(obj.get(), data_buffer, static_cast(data_buffer_elements), (timestamp_buffer), pushthrough); } + void push_chunk_multiplexed(const char *data_buffer, const double *timestamp_buffer, + std::size_t data_buffer_elements, bool pushthrough = true) { + lsl_push_chunk_ctnp(obj.get(), reinterpret_cast(data_buffer), + static_cast(data_buffer_elements), (timestamp_buffer), pushthrough); + } void push_chunk_multiplexed(const std::string *data_buffer, const double *timestamp_buffer, std::size_t data_buffer_elements, bool pushthrough = true) { @@ -752,7 +765,7 @@ class stream_outlet { lengths[k] = (uint32_t)data_buffer[k].size(); } lsl_push_chunk_buftnp(obj.get(), pointers.data(), lengths.data(), - static_cast(data_buffer_elements), timestamp_buffer, pushthrough); + static_cast(data_buffer_elements), timestamp_buffer, pushthrough); } } @@ -833,7 +846,7 @@ class stream_outlet { */ inline std::vector resolve_streams(double wait_time = 1.0) { lsl_streaminfo buffer[1024]; - int nres = check_error(lsl_resolve_all(buffer, sizeof(buffer) / sizeof(lsl_streaminfo), wait_time)); + int32_t nres = check_error(lsl_resolve_all(buffer, sizeof(buffer) / sizeof(lsl_streaminfo), wait_time)); return std::vector(&buffer[0], &buffer[nres]); } @@ -853,7 +866,7 @@ inline std::vector resolve_streams(double wait_time = 1.0) { inline std::vector resolve_stream(const std::string &prop, const std::string &value, int32_t minimum = 1, double timeout = FOREVER) { lsl_streaminfo buffer[1024]; - int nres = check_error( + int32_t nres = check_error( lsl_resolve_byprop(buffer, sizeof(buffer) / sizeof(lsl_streaminfo), prop.c_str(), value.c_str(), minimum, timeout)); return std::vector(&buffer[0], &buffer[nres]); } @@ -875,7 +888,7 @@ inline std::vector resolve_stream(const std::string &prop, const st inline std::vector resolve_stream( const std::string &pred, int32_t minimum = 1, double timeout = FOREVER) { lsl_streaminfo buffer[1024]; - int nres = + int32_t nres = check_error(lsl_resolve_bypred(buffer, sizeof(buffer) / sizeof(lsl_streaminfo), pred.c_str(), minimum, timeout)); return std::vector(&buffer[0], &buffer[nres]); } @@ -1035,7 +1048,7 @@ class stream_inlet { * .time_correction() to it. * @throws lost_error (if the stream source has been lost). */ - template double pull_sample(T sample[N], double timeout = FOREVER) { + template double pull_sample(T sample[N], double timeout = FOREVER) { return pull_sample(&sample[0], N, timeout); } @@ -1070,6 +1083,10 @@ class stream_inlet { sample.resize(channel_count); return pull_sample(&sample[0], (int32_t)sample.size(), timeout); } + double pull_sample(std::vector &sample, double timeout = FOREVER) { + sample.resize(channel_count); + return pull_sample(&sample[0], (int32_t)sample.size(), timeout); + } double pull_sample(std::vector &sample, double timeout = FOREVER) { sample.resize(channel_count); return pull_sample(&sample[0], (int32_t)sample.size(), timeout); @@ -1121,12 +1138,18 @@ class stream_inlet { check_error(ec); return res; } - double pull_sample(char *buffer, int32_t buffer_elements, double timeout = FOREVER) { + double pull_sample(int8_t *buffer, int32_t buffer_elements, double timeout = FOREVER) { int32_t ec = 0; double res = lsl_pull_sample_c(obj.get(), buffer, buffer_elements, timeout, &ec); check_error(ec); return res; } + double pull_sample(char *buffer, int32_t buffer_elements, double timeout = FOREVER) { + int32_t ec = 0; + double res = lsl_pull_sample_c(obj.get(), reinterpret_cast(buffer), buffer_elements, timeout, &ec); + check_error(ec); + return res; + } double pull_sample(std::string *buffer, int32_t buffer_elements, double timeout = FOREVER) { int32_t ec = 0; if (buffer_elements) { @@ -1271,7 +1294,7 @@ class stream_inlet { double timeout = 0.0) { int32_t ec = 0; std::size_t res = lsl_pull_chunk_f(obj.get(), data_buffer, timestamp_buffer, - (unsigned long)data_buffer_elements, (unsigned long)timestamp_buffer_elements, timeout, + (size_t)data_buffer_elements, (size_t)timestamp_buffer_elements, timeout, &ec); check_error(ec); return res; @@ -1281,7 +1304,7 @@ class stream_inlet { double timeout = 0.0) { int32_t ec = 0; std::size_t res = lsl_pull_chunk_d(obj.get(), data_buffer, timestamp_buffer, - (unsigned long)data_buffer_elements, (unsigned long)timestamp_buffer_elements, timeout, + (size_t)data_buffer_elements, (size_t)timestamp_buffer_elements, timeout, &ec); check_error(ec); return res; @@ -1291,7 +1314,7 @@ class stream_inlet { double timeout = 0.0) { int32_t ec = 0; std::size_t res = lsl_pull_chunk_l(obj.get(), data_buffer, timestamp_buffer, - (unsigned long)data_buffer_elements, (unsigned long)timestamp_buffer_elements, timeout, + (size_t)data_buffer_elements, (size_t)timestamp_buffer_elements, timeout, &ec); check_error(ec); return res; @@ -1301,7 +1324,7 @@ class stream_inlet { double timeout = 0.0) { int32_t ec = 0; std::size_t res = lsl_pull_chunk_i(obj.get(), data_buffer, timestamp_buffer, - (unsigned long)data_buffer_elements, (unsigned long)timestamp_buffer_elements, timeout, + (size_t)data_buffer_elements, (size_t)timestamp_buffer_elements, timeout, &ec); check_error(ec); return res; @@ -1311,16 +1334,26 @@ class stream_inlet { double timeout = 0.0) { int32_t ec = 0; std::size_t res = lsl_pull_chunk_s(obj.get(), data_buffer, timestamp_buffer, - (unsigned long)data_buffer_elements, (unsigned long)timestamp_buffer_elements, timeout, + (size_t)data_buffer_elements, (size_t)timestamp_buffer_elements, timeout, &ec); check_error(ec); return res; } - std::size_t pull_chunk_multiplexed(char *data_buffer, double *timestamp_buffer, + std::size_t pull_chunk_multiplexed(int8_t *data_buffer, double *timestamp_buffer, std::size_t data_buffer_elements, std::size_t timestamp_buffer_elements, double timeout = 0.0) { int32_t ec = 0; std::size_t res = lsl_pull_chunk_c(obj.get(), data_buffer, timestamp_buffer, + static_cast(data_buffer_elements), static_cast(timestamp_buffer_elements), timeout, + &ec); + check_error(ec); + return res; + } + std::size_t pull_chunk_multiplexed(char *data_buffer, double *timestamp_buffer, + std::size_t data_buffer_elements, std::size_t timestamp_buffer_elements, + double timeout = 0.0) { + int32_t ec = 0; + std::size_t res = lsl_pull_chunk_c(obj.get(), reinterpret_cast(data_buffer), timestamp_buffer, static_cast(data_buffer_elements), static_cast(timestamp_buffer_elements), timeout, &ec); check_error(ec); @@ -1334,8 +1367,8 @@ class stream_inlet { std::vector result_strings(data_buffer_elements); std::vector result_lengths(data_buffer_elements); std::size_t num = lsl_pull_chunk_buf(obj.get(), result_strings.data(), result_lengths.data(), - timestamp_buffer, static_cast(data_buffer_elements), - static_cast(timestamp_buffer_elements), timeout, &ec); + timestamp_buffer, static_cast(data_buffer_elements), + static_cast(timestamp_buffer_elements), timeout, &ec); check_error(ec); for (std::size_t k = 0; k < num; k++) { data_buffer[k].assign(result_strings[k], result_lengths[k]); @@ -1473,7 +1506,7 @@ class stream_inlet { */ void smoothing_halftime(float value) { check_error(lsl_smoothing_halftime(obj.get(), value)); } - int get_channel_count() const { return channel_count; } + int32_t get_channel_count() const { return channel_count; } private: // The inlet is a non-copyable object. diff --git a/src/data_receiver.cpp b/src/data_receiver.cpp index 7266c2039..77e55f142 100644 --- a/src/data_receiver.cpp +++ b/src/data_receiver.cpp @@ -112,7 +112,7 @@ double data_receiver::pull_sample_typed(T *buffer, uint32_t buffer_elements, dou return 0.0; } -template double data_receiver::pull_sample_typed(char *, uint32_t, double); +template double data_receiver::pull_sample_typed(int8_t *, uint32_t, double); template double data_receiver::pull_sample_typed(int16_t *, uint32_t, double); template double data_receiver::pull_sample_typed(int32_t *, uint32_t, double); template double data_receiver::pull_sample_typed(int64_t *, uint32_t, double); diff --git a/src/lsl_inlet_c.cpp b/src/lsl_inlet_c.cpp index 4cc20498c..89315989d 100644 --- a/src/lsl_inlet_c.cpp +++ b/src/lsl_inlet_c.cpp @@ -113,7 +113,7 @@ LIBLSL_C_API double lsl_pull_sample_s( } LIBLSL_C_API double lsl_pull_sample_c( - lsl_inlet in, char *buffer, int32_t buffer_elements, double timeout, int32_t *ec) { + lsl_inlet in, int8_t *buffer, int32_t buffer_elements, double timeout, int32_t *ec) { return in->pull_sample_noexcept(buffer, buffer_elements, timeout, (lsl_error_code_t *)ec); } @@ -178,51 +178,51 @@ LIBLSL_C_API double lsl_pull_sample_v( return 0.0; } -LIBLSL_C_API unsigned long lsl_pull_chunk_f(lsl_inlet in, float *data_buffer, - double *timestamp_buffer, unsigned long data_buffer_elements, - unsigned long timestamp_buffer_elements, double timeout, int32_t *ec) { +LIBLSL_C_API size_t lsl_pull_chunk_f(lsl_inlet in, float *data_buffer, + double *timestamp_buffer, size_t data_buffer_elements, + size_t timestamp_buffer_elements, double timeout, int32_t *ec) { return in->pull_chunk_multiplexed_noexcept(data_buffer, timestamp_buffer, data_buffer_elements, timestamp_buffer_elements, timeout, (lsl_error_code_t *)ec); } -LIBLSL_C_API unsigned long lsl_pull_chunk_d(lsl_inlet in, double *data_buffer, - double *timestamp_buffer, unsigned long data_buffer_elements, - unsigned long timestamp_buffer_elements, double timeout, int32_t *ec) { +LIBLSL_C_API size_t lsl_pull_chunk_d(lsl_inlet in, double *data_buffer, + double *timestamp_buffer, size_t data_buffer_elements, + size_t timestamp_buffer_elements, double timeout, int32_t *ec) { return in->pull_chunk_multiplexed_noexcept(data_buffer, timestamp_buffer, data_buffer_elements, timestamp_buffer_elements, timeout, (lsl_error_code_t *)ec); } -LIBLSL_C_API unsigned long lsl_pull_chunk_l(lsl_inlet in, int64_t *data_buffer, - double *timestamp_buffer, unsigned long data_buffer_elements, - unsigned long timestamp_buffer_elements, double timeout, int32_t *ec) { +LIBLSL_C_API size_t lsl_pull_chunk_l(lsl_inlet in, int64_t *data_buffer, + double *timestamp_buffer, size_t data_buffer_elements, + size_t timestamp_buffer_elements, double timeout, int32_t *ec) { return in->pull_chunk_multiplexed_noexcept(data_buffer, timestamp_buffer, data_buffer_elements, timestamp_buffer_elements, timeout, (lsl_error_code_t *)ec); } -LIBLSL_C_API unsigned long lsl_pull_chunk_i(lsl_inlet in, int32_t *data_buffer, - double *timestamp_buffer, unsigned long data_buffer_elements, - unsigned long timestamp_buffer_elements, double timeout, int32_t *ec) { +LIBLSL_C_API size_t lsl_pull_chunk_i(lsl_inlet in, int32_t *data_buffer, + double *timestamp_buffer, size_t data_buffer_elements, + size_t timestamp_buffer_elements, double timeout, int32_t *ec) { return in->pull_chunk_multiplexed_noexcept(data_buffer, timestamp_buffer, data_buffer_elements, timestamp_buffer_elements, timeout, (lsl_error_code_t *)ec); } -LIBLSL_C_API unsigned long lsl_pull_chunk_s(lsl_inlet in, int16_t *data_buffer, - double *timestamp_buffer, unsigned long data_buffer_elements, - unsigned long timestamp_buffer_elements, double timeout, int32_t *ec) { +LIBLSL_C_API size_t lsl_pull_chunk_s(lsl_inlet in, int16_t *data_buffer, + double *timestamp_buffer, size_t data_buffer_elements, + size_t timestamp_buffer_elements, double timeout, int32_t *ec) { return in->pull_chunk_multiplexed_noexcept(data_buffer, timestamp_buffer, data_buffer_elements, timestamp_buffer_elements, timeout, (lsl_error_code_t *)ec); } -LIBLSL_C_API unsigned long lsl_pull_chunk_c(lsl_inlet in, char *data_buffer, - double *timestamp_buffer, unsigned long data_buffer_elements, - unsigned long timestamp_buffer_elements, double timeout, int32_t *ec) { +LIBLSL_C_API size_t lsl_pull_chunk_c(lsl_inlet in, int8_t *data_buffer, + double *timestamp_buffer, size_t data_buffer_elements, + size_t timestamp_buffer_elements, double timeout, int32_t *ec) { return in->pull_chunk_multiplexed_noexcept(data_buffer, timestamp_buffer, data_buffer_elements, timestamp_buffer_elements, timeout, (lsl_error_code_t *)ec); } -LIBLSL_C_API unsigned long lsl_pull_chunk_str(lsl_inlet in, char **data_buffer, - double *timestamp_buffer, unsigned long data_buffer_elements, - unsigned long timestamp_buffer_elements, double timeout, int32_t *ec) { +LIBLSL_C_API size_t lsl_pull_chunk_str(lsl_inlet in, char **data_buffer, + double *timestamp_buffer, size_t data_buffer_elements, + size_t timestamp_buffer_elements, double timeout, int32_t *ec) { if (ec) *ec = lsl_no_error; try { // capture output in a temporary string buffer @@ -249,9 +249,9 @@ LIBLSL_C_API unsigned long lsl_pull_chunk_str(lsl_inlet in, char **data_buffer, return 0; } -LIBLSL_C_API unsigned long lsl_pull_chunk_buf(lsl_inlet in, char **data_buffer, - uint32_t *lengths_buffer, double *timestamp_buffer, unsigned long data_buffer_elements, - unsigned long timestamp_buffer_elements, double timeout, int32_t *ec) { +LIBLSL_C_API size_t lsl_pull_chunk_buf(lsl_inlet in, char **data_buffer, + uint32_t *lengths_buffer, double *timestamp_buffer, size_t data_buffer_elements, + size_t timestamp_buffer_elements, double timeout, int32_t *ec) { if (ec) *ec = lsl_no_error; try { // capture output in a temporary string buffer diff --git a/src/lsl_outlet_c.cpp b/src/lsl_outlet_c.cpp index b79ba3153..f2a552549 100644 --- a/src/lsl_outlet_c.cpp +++ b/src/lsl_outlet_c.cpp @@ -98,16 +98,16 @@ LIBLSL_C_API int32_t lsl_push_sample_stp( return out->push_sample_noexcept(data, timestamp, pushthrough); } -LIBLSL_C_API int32_t lsl_push_sample_c(lsl_outlet out, const char *data) { +LIBLSL_C_API int32_t lsl_push_sample_c(lsl_outlet out, const int8_t *data) { return out->push_sample_noexcept(data); } -LIBLSL_C_API int32_t lsl_push_sample_ct(lsl_outlet out, const char *data, double timestamp) { +LIBLSL_C_API int32_t lsl_push_sample_ct(lsl_outlet out, const int8_t *data, double timestamp) { return out->push_sample_noexcept(data, timestamp); } LIBLSL_C_API int32_t lsl_push_sample_ctp( - lsl_outlet out, const char *data, double timestamp, int32_t pushthrough) { + lsl_outlet out, const int8_t *data, double timestamp, int32_t pushthrough) { return out->push_sample_noexcept(data, timestamp, pushthrough); } @@ -173,170 +173,170 @@ LIBLSL_C_API int32_t lsl_push_sample_buftp(lsl_outlet out, const char **data, } LIBLSL_C_API int32_t lsl_push_chunk_f( - lsl_outlet out, const float *data, unsigned long data_elements) { + lsl_outlet out, const float *data, size_t data_elements) { return out->push_chunk_multiplexed_noexcept(data, data_elements); } LIBLSL_C_API int32_t lsl_push_chunk_d( - lsl_outlet out, const double *data, unsigned long data_elements) { + lsl_outlet out, const double *data, size_t data_elements) { return out->push_chunk_multiplexed_noexcept(data, data_elements); } LIBLSL_C_API int32_t lsl_push_chunk_l( - lsl_outlet out, const int64_t *data, unsigned long data_elements) { + lsl_outlet out, const int64_t *data, size_t data_elements) { return out->push_chunk_multiplexed_noexcept(data, data_elements); } LIBLSL_C_API int32_t lsl_push_chunk_i( - lsl_outlet out, const int32_t *data, unsigned long data_elements) { + lsl_outlet out, const int32_t *data, size_t data_elements) { return out->push_chunk_multiplexed_noexcept(data, data_elements); } LIBLSL_C_API int32_t lsl_push_chunk_s( - lsl_outlet out, const int16_t *data, unsigned long data_elements) { + lsl_outlet out, const int16_t *data, size_t data_elements) { return out->push_chunk_multiplexed_noexcept(data, data_elements); } LIBLSL_C_API int32_t lsl_push_chunk_c( - lsl_outlet out, const char *data, unsigned long data_elements) { + lsl_outlet out, const int8_t *data, size_t data_elements) { return out->push_chunk_multiplexed_noexcept(data, data_elements); } LIBLSL_C_API int32_t lsl_push_chunk_ft( - lsl_outlet out, const float *data, unsigned long data_elements, double timestamp) { + lsl_outlet out, const float *data, size_t data_elements, double timestamp) { return out->push_chunk_multiplexed_noexcept(data, data_elements, timestamp); } LIBLSL_C_API int32_t lsl_push_chunk_dt( - lsl_outlet out, const double *data, unsigned long data_elements, double timestamp) { + lsl_outlet out, const double *data, size_t data_elements, double timestamp) { return out->push_chunk_multiplexed_noexcept(data, data_elements, timestamp); } LIBLSL_C_API int32_t lsl_push_chunk_lt( - lsl_outlet out, const int64_t *data, unsigned long data_elements, double timestamp) { + lsl_outlet out, const int64_t *data, size_t data_elements, double timestamp) { return out->push_chunk_multiplexed_noexcept(data, data_elements, timestamp); } LIBLSL_C_API int32_t lsl_push_chunk_it( - lsl_outlet out, const int32_t *data, unsigned long data_elements, double timestamp) { + lsl_outlet out, const int32_t *data, size_t data_elements, double timestamp) { return out->push_chunk_multiplexed_noexcept(data, data_elements, timestamp); } LIBLSL_C_API int32_t lsl_push_chunk_st( - lsl_outlet out, const int16_t *data, unsigned long data_elements, double timestamp) { + lsl_outlet out, const int16_t *data, size_t data_elements, double timestamp) { return out->push_chunk_multiplexed_noexcept(data, data_elements, timestamp); } LIBLSL_C_API int32_t lsl_push_chunk_ct( - lsl_outlet out, const char *data, unsigned long data_elements, double timestamp) { + lsl_outlet out, const int8_t *data, size_t data_elements, double timestamp) { return out->push_chunk_multiplexed_noexcept(data, data_elements, timestamp); } LIBLSL_C_API int32_t lsl_push_chunk_ftp(lsl_outlet out, const float *data, - unsigned long data_elements, double timestamp, int32_t pushthrough) { + size_t data_elements, double timestamp, int32_t pushthrough) { return out->push_chunk_multiplexed_noexcept(data, data_elements, timestamp, pushthrough); } LIBLSL_C_API int32_t lsl_push_chunk_dtp(lsl_outlet out, const double *data, - unsigned long data_elements, double timestamp, int32_t pushthrough) { + size_t data_elements, double timestamp, int32_t pushthrough) { return out->push_chunk_multiplexed_noexcept(data, data_elements, timestamp, pushthrough); } LIBLSL_C_API int32_t lsl_push_chunk_ltp(lsl_outlet out, const int64_t *data, - unsigned long data_elements, double timestamp, int32_t pushthrough) { + size_t data_elements, double timestamp, int32_t pushthrough) { return out->push_chunk_multiplexed_noexcept(data, data_elements, timestamp, pushthrough); } LIBLSL_C_API int32_t lsl_push_chunk_itp(lsl_outlet out, const int32_t *data, - unsigned long data_elements, double timestamp, int32_t pushthrough) { + size_t data_elements, double timestamp, int32_t pushthrough) { return out->push_chunk_multiplexed_noexcept(data, data_elements, timestamp, pushthrough); } LIBLSL_C_API int32_t lsl_push_chunk_stp(lsl_outlet out, const int16_t *data, - unsigned long data_elements, double timestamp, int32_t pushthrough) { + size_t data_elements, double timestamp, int32_t pushthrough) { return out->push_chunk_multiplexed_noexcept(data, data_elements, timestamp, pushthrough); } -LIBLSL_C_API int32_t lsl_push_chunk_ctp(lsl_outlet out, const char *data, - unsigned long data_elements, double timestamp, int32_t pushthrough) { +LIBLSL_C_API int32_t lsl_push_chunk_ctp(lsl_outlet out, const int8_t *data, + size_t data_elements, double timestamp, int32_t pushthrough) { return out->push_chunk_multiplexed_noexcept(data, data_elements, timestamp, pushthrough); } LIBLSL_C_API int32_t lsl_push_chunk_ftn( - lsl_outlet out, const float *data, unsigned long data_elements, const double *timestamps) { + lsl_outlet out, const float *data, size_t data_elements, const double *timestamps) { return out->push_chunk_multiplexed_noexcept(data, timestamps, data_elements); } LIBLSL_C_API int32_t lsl_push_chunk_dtn( - lsl_outlet out, const double *data, unsigned long data_elements, const double *timestamps) { + lsl_outlet out, const double *data, size_t data_elements, const double *timestamps) { return out->push_chunk_multiplexed_noexcept(data, timestamps, data_elements); } LIBLSL_C_API int32_t lsl_push_chunk_ltn( - lsl_outlet out, const int64_t *data, unsigned long data_elements, const double *timestamps) { + lsl_outlet out, const int64_t *data, size_t data_elements, const double *timestamps) { return out->push_chunk_multiplexed_noexcept(data, timestamps, data_elements); } LIBLSL_C_API int32_t lsl_push_chunk_itn( - lsl_outlet out, const int32_t *data, unsigned long data_elements, const double *timestamps) { + lsl_outlet out, const int32_t *data, size_t data_elements, const double *timestamps) { return out->push_chunk_multiplexed_noexcept(data, timestamps, data_elements); } LIBLSL_C_API int32_t lsl_push_chunk_stn( - lsl_outlet out, const int16_t *data, unsigned long data_elements, const double *timestamps) { + lsl_outlet out, const int16_t *data, size_t data_elements, const double *timestamps) { return out->push_chunk_multiplexed_noexcept(data, timestamps, data_elements); } LIBLSL_C_API int32_t lsl_push_chunk_ctn( - lsl_outlet out, const char *data, unsigned long data_elements, const double *timestamps) { + lsl_outlet out, const int8_t *data, size_t data_elements, const double *timestamps) { return out->push_chunk_multiplexed_noexcept(data, timestamps, data_elements); } LIBLSL_C_API int32_t lsl_push_chunk_ftnp(lsl_outlet out, const float *data, - unsigned long data_elements, const double *timestamps, int32_t pushthrough) { + size_t data_elements, const double *timestamps, int32_t pushthrough) { return out->push_chunk_multiplexed_noexcept(data, timestamps, data_elements, pushthrough); } LIBLSL_C_API int32_t lsl_push_chunk_dtnp(lsl_outlet out, const double *data, - unsigned long data_elements, const double *timestamps, int32_t pushthrough) { + size_t data_elements, const double *timestamps, int32_t pushthrough) { return out->push_chunk_multiplexed_noexcept(data, timestamps, data_elements, pushthrough); } LIBLSL_C_API int32_t lsl_push_chunk_ltnp(lsl_outlet out, const int64_t *data, - unsigned long data_elements, const double *timestamps, int32_t pushthrough) { + size_t data_elements, const double *timestamps, int32_t pushthrough) { return out->push_chunk_multiplexed_noexcept(data, timestamps, data_elements, pushthrough); } LIBLSL_C_API int32_t lsl_push_chunk_itnp(lsl_outlet out, const int32_t *data, - unsigned long data_elements, const double *timestamps, int32_t pushthrough) { + size_t data_elements, const double *timestamps, int32_t pushthrough) { return out->push_chunk_multiplexed_noexcept(data, timestamps, data_elements, pushthrough); } LIBLSL_C_API int32_t lsl_push_chunk_stnp(lsl_outlet out, const int16_t *data, - unsigned long data_elements, const double *timestamps, int32_t pushthrough) { + size_t data_elements, const double *timestamps, int32_t pushthrough) { return out->push_chunk_multiplexed_noexcept(data, timestamps, data_elements, pushthrough); } -LIBLSL_C_API int32_t lsl_push_chunk_ctnp(lsl_outlet out, const char *data, - unsigned long data_elements, const double *timestamps, int32_t pushthrough) { +LIBLSL_C_API int32_t lsl_push_chunk_ctnp(lsl_outlet out, const int8_t *data, + size_t data_elements, const double *timestamps, int32_t pushthrough) { return out->push_chunk_multiplexed_noexcept(data, timestamps, data_elements, pushthrough); } LIBLSL_C_API int32_t lsl_push_chunk_str( - lsl_outlet out, const char **data, unsigned long data_elements) { + lsl_outlet out, const char **data, size_t data_elements) { return lsl_push_chunk_strtp(out, data, data_elements, 0.0, true); } LIBLSL_C_API int32_t lsl_push_chunk_strt( - lsl_outlet out, const char **data, unsigned long data_elements, double timestamp) { + lsl_outlet out, const char **data, size_t data_elements, double timestamp) { return lsl_push_chunk_strtp(out, data, data_elements, timestamp, true); } LIBLSL_C_API int32_t lsl_push_chunk_strtp(lsl_outlet out, const char **data, - unsigned long data_elements, double timestamp, int32_t pushthrough) { + size_t data_elements, double timestamp, int32_t pushthrough) { try { std::vector tmp; - for (unsigned long k = 0; k < data_elements; k++) tmp.emplace_back(data[k]); + for (size_t k = 0; k < data_elements; k++) tmp.emplace_back(data[k]); if (data_elements) out->push_chunk_multiplexed(tmp.data(), tmp.size(), timestamp, pushthrough); } @@ -344,16 +344,16 @@ LIBLSL_C_API int32_t lsl_push_chunk_strtp(lsl_outlet out, const char **data, } LIBLSL_C_API int32_t lsl_push_chunk_strtn( - lsl_outlet out, const char **data, unsigned long data_elements, const double *timestamps) { + lsl_outlet out, const char **data, size_t data_elements, const double *timestamps) { return lsl_push_chunk_strtnp(out, data, data_elements, timestamps, true); } LIBLSL_C_API int32_t lsl_push_chunk_strtnp(lsl_outlet out, const char **data, - unsigned long data_elements, const double *timestamps, int32_t pushthrough) { + size_t data_elements, const double *timestamps, int32_t pushthrough) { try { if (data_elements) { std::vector tmp; - for (unsigned long k = 0; k < data_elements; k++) tmp.emplace_back(data[k]); + for (size_t k = 0; k < data_elements; k++) tmp.emplace_back(data[k]); out->push_chunk_multiplexed_noexcept( tmp.data(), timestamps, data_elements, pushthrough); } @@ -362,20 +362,20 @@ LIBLSL_C_API int32_t lsl_push_chunk_strtnp(lsl_outlet out, const char **data, } LIBLSL_C_API int32_t lsl_push_chunk_buf( - lsl_outlet out, const char **data, const uint32_t *lengths, unsigned long data_elements) { + lsl_outlet out, const char **data, const uint32_t *lengths, size_t data_elements) { return lsl_push_chunk_buftp(out, data, lengths, data_elements, 0.0, true); } LIBLSL_C_API int32_t lsl_push_chunk_buft(lsl_outlet out, const char **data, const uint32_t *lengths, - unsigned long data_elements, double timestamp) { + size_t data_elements, double timestamp) { return lsl_push_chunk_buftp(out, data, lengths, data_elements, timestamp, true); } LIBLSL_C_API int32_t lsl_push_chunk_buftp(lsl_outlet out, const char **data, - const uint32_t *lengths, unsigned long data_elements, double timestamp, int32_t pushthrough) { + const uint32_t *lengths, size_t data_elements, double timestamp, int32_t pushthrough) { try { std::vector tmp; - for (unsigned long k = 0; k < data_elements; k++) tmp.emplace_back(data[k], lengths[k]); + for (size_t k = 0; k < data_elements; k++) tmp.emplace_back(data[k], lengths[k]); if (data_elements) out->push_chunk_multiplexed(tmp.data(), tmp.size(), timestamp, pushthrough); } @@ -383,17 +383,17 @@ LIBLSL_C_API int32_t lsl_push_chunk_buftp(lsl_outlet out, const char **data, } LIBLSL_C_API int32_t lsl_push_chunk_buftn(lsl_outlet out, const char **data, - const uint32_t *lengths, unsigned long data_elements, const double *timestamps) { + const uint32_t *lengths, size_t data_elements, const double *timestamps) { return lsl_push_chunk_buftnp(out, data, lengths, data_elements, timestamps, true); } LIBLSL_C_API int32_t lsl_push_chunk_buftnp(lsl_outlet out, const char **data, - const uint32_t *lengths, unsigned long data_elements, const double *timestamps, + const uint32_t *lengths, size_t data_elements, const double *timestamps, int32_t pushthrough) { try { if (data_elements) { std::vector tmp; - for (unsigned long k = 0; k < data_elements; k++) tmp.emplace_back(data[k], lengths[k]); + for (size_t k = 0; k < data_elements; k++) tmp.emplace_back(data[k], lengths[k]); out->push_chunk_multiplexed( tmp.data(), timestamps, (std::size_t)data_elements, pushthrough); } diff --git a/src/sample.cpp b/src/sample.cpp index b95521b0e..4ebe8418e 100644 --- a/src/sample.cpp +++ b/src/sample.cpp @@ -482,14 +482,14 @@ void factory::reclaim_sample(sample *s) { // template instantiations template void lsl::sample::assign_typed(float const *); template void lsl::sample::assign_typed(double const *); -template void lsl::sample::assign_typed(char const *); +template void lsl::sample::assign_typed(int8_t const *); template void lsl::sample::assign_typed(int16_t const *); template void lsl::sample::assign_typed(int32_t const *); template void lsl::sample::assign_typed(int64_t const *); template void lsl::sample::assign_typed(std::string const *); template void lsl::sample::retrieve_typed(float *); template void lsl::sample::retrieve_typed(double *); -template void lsl::sample::retrieve_typed(char *); +template void lsl::sample::retrieve_typed(int8_t *); template void lsl::sample::retrieve_typed(int16_t *); template void lsl::sample::retrieve_typed(int32_t *); template void lsl::sample::retrieve_typed(int64_t *); diff --git a/src/stream_inlet_impl.h b/src/stream_inlet_impl.h index b3ad7e618..e5c397b5c 100644 --- a/src/stream_inlet_impl.h +++ b/src/stream_inlet_impl.h @@ -89,7 +89,7 @@ class stream_inlet_impl { data.resize(conn_.type_info().channel_count()); return pull_sample(data.data(), (int32_t)data.size(), timeout); } - double pull_sample(std::vector &data, double timeout = FOREVER) { + double pull_sample(std::vector &data, double timeout = FOREVER) { data.resize(conn_.type_info().channel_count()); return pull_sample(data.data(), (int32_t)data.size(), timeout); } @@ -127,7 +127,7 @@ class stream_inlet_impl { double pull_sample(int16_t *buffer, int32_t buffer_elements, double timeout = FOREVER) { return postprocess(data_receiver_.pull_sample_typed(buffer, buffer_elements, timeout)); } - double pull_sample(char *buffer, int32_t buffer_elements, double timeout = FOREVER) { + double pull_sample(int8_t *buffer, int32_t buffer_elements, double timeout = FOREVER) { return postprocess(data_receiver_.pull_sample_typed(buffer, buffer_elements, timeout)); } double pull_sample(std::string *buffer, int32_t buffer_elements, double timeout = FOREVER) { diff --git a/src/stream_outlet_impl.cpp b/src/stream_outlet_impl.cpp index 62f9a38fc..279b3d7c9 100644 --- a/src/stream_outlet_impl.cpp +++ b/src/stream_outlet_impl.cpp @@ -210,7 +210,7 @@ void stream_outlet_impl::enqueue(const T *data, double timestamp, bool pushthrou } } -template void stream_outlet_impl::enqueue(const char *data, double, bool); +template void stream_outlet_impl::enqueue(const int8_t *data, double, bool); template void stream_outlet_impl::enqueue(const int16_t *data, double, bool); template void stream_outlet_impl::enqueue(const int32_t *data, double, bool); template void stream_outlet_impl::enqueue(const int64_t *data, double, bool); @@ -289,8 +289,8 @@ void stream_outlet_impl::enqueue_chunk_sync( } // Explicit template instantiations for enqueue_chunk_sync -template void stream_outlet_impl::enqueue_chunk_sync( - const char *, std::size_t, double, bool); +template void stream_outlet_impl::enqueue_chunk_sync( + const int8_t *, std::size_t, double, bool); template void stream_outlet_impl::enqueue_chunk_sync( const int16_t *, std::size_t, double, bool); template void stream_outlet_impl::enqueue_chunk_sync( diff --git a/src/stream_outlet_impl.h b/src/stream_outlet_impl.h index e8fb3116a..7bee13187 100644 --- a/src/stream_outlet_impl.h +++ b/src/stream_outlet_impl.h @@ -96,7 +96,7 @@ class stream_outlet_impl { enqueue(data.data(), timestamp, pushthrough); } void push_sample( - const std::vector &data, double timestamp = 0.0, bool pushthrough = true) { + const std::vector &data, double timestamp = 0.0, bool pushthrough = true) { check_numchan((int32_t)data.size()); enqueue(data.data(), timestamp, pushthrough); } @@ -134,7 +134,7 @@ class stream_outlet_impl { void push_sample(const int16_t *data, double timestamp = 0.0, bool pushthrough = true) { enqueue(data, timestamp, pushthrough); } - void push_sample(const char *data, double timestamp = 0.0, bool pushthrough = true) { + void push_sample(const int8_t *data, double timestamp = 0.0, bool pushthrough = true) { enqueue(data, timestamp, pushthrough); } void push_sample(const std::string *data, double timestamp = 0.0, bool pushthrough = true) { diff --git a/testing/common/lsltypes.hpp b/testing/common/lsltypes.hpp index a14ef9237..678a33542 100644 --- a/testing/common/lsltypes.hpp +++ b/testing/common/lsltypes.hpp @@ -9,7 +9,7 @@ template struct SampleType { static const char *fmt_string(); }; -template <> struct SampleType { +template <> struct SampleType { static const lsl_channel_format_t chan_fmt = cft_int8; static const char *fmt_string() { return "cf_int8"; } }; diff --git a/testing/ext/DataType.cpp b/testing/ext/DataType.cpp index f09103159..2438a9a7d 100644 --- a/testing/ext/DataType.cpp +++ b/testing/ext/DataType.cpp @@ -10,7 +10,7 @@ // clazy:excludeall=non-pod-global-static TEMPLATE_TEST_CASE( - "datatransfer", "[datatransfer][basic]", char, int16_t, int32_t, int64_t, float, double) { + "datatransfer", "[datatransfer][basic]", int8_t, int16_t, int32_t, int64_t, float, double) { const int numBounces = sizeof(TestType) * 8; double timestamps[numBounces][2]; const char *name = SampleType::fmt_string(); diff --git a/testing/ext/sync_outlet.cpp b/testing/ext/sync_outlet.cpp index adc78a95e..06463ec99 100644 --- a/testing/ext/sync_outlet.cpp +++ b/testing/ext/sync_outlet.cpp @@ -48,7 +48,7 @@ TEST_CASE("sync_outlet_basic", "[sync][basic]") { } TEMPLATE_TEST_CASE( - "sync_outlet_datatypes", "[sync][datatransfer]", char, int16_t, int32_t, int64_t, float, double) { + "sync_outlet_datatypes", "[sync][datatransfer]", int8_t, int16_t, int32_t, int64_t, float, double) { const int nchannels = 2; const int nsamples = 32; const char *name = SampleType::fmt_string(); diff --git a/testing/ext/time.cpp b/testing/ext/time.cpp index 0a62243a5..1d38fc42e 100644 --- a/testing/ext/time.cpp +++ b/testing/ext/time.cpp @@ -29,14 +29,14 @@ TEST_CASE("timeouts", "[pull][basic]") { // Push a sample after some time so the test can continue even if the timeout isn't honored std::thread saver([&]() { - char val; + int8_t val; auto end = lsl::local_clock() + 2; while (!done && lsl::local_clock() < end) std::this_thread::sleep_for(std::chrono::milliseconds(50)); sp.out_.push_sample(&val); }); - char val; + int8_t val; REQUIRE(sp.in_.pull_sample(&val, 1, 0.5) == Catch::Approx(0.0)); done = true; saver.join();