Skip to content

Commit 215058f

Browse files
tstennercboulay
authored andcommitted
Reduce usage of api_config header
1 parent 068c0f3 commit 215058f

File tree

6 files changed

+35
-20
lines changed

6 files changed

+35
-20
lines changed

src/data_receiver.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "data_receiver.h"
2+
#include "api_config.h"
23
#include "cancellable_streambuf.h"
34
#include "sample.h"
45
#include "socket_utils.h"

src/socket_utils.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "socket_utils.h"
2+
#include "api_config.h"
23
#include "common.h"
34
#include <boost/endian/conversion.hpp>
45
#include <boost/system/system_error.hpp>

src/socket_utils.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#ifndef SOCKET_UTILS_H
22
#define SOCKET_UTILS_H
33

4-
#include "api_config.h"
54
#include <boost/asio/detail/chrono.hpp>
65
#include <boost/asio/ip/tcp.hpp>
76
#include <boost/asio/ip/udp.hpp>

src/stream_outlet_impl.cpp

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
#include "stream_outlet_impl.h"
2+
#include "api_config.h"
23
#include "tcp_server.h"
34
#include "udp_server.h"
45
#include <memory>
56
#include <sstream>
67

7-
using namespace lsl;
88
using namespace lslboost::asio;
99

10+
namespace lsl {
11+
1012
stream_outlet_impl::stream_outlet_impl(
1113
const stream_info_impl &info, int chunk_size, int max_capacity)
1214
: sample_factory_(std::make_shared<factory>(info.channel_format(), info.channel_count(),
@@ -135,8 +137,35 @@ stream_outlet_impl::~stream_outlet_impl() {
135137
} catch (...) { LOG_F(ERROR, "Severe error during stream outlet shutdown."); }
136138
}
137139

140+
void stream_outlet_impl::push_numeric_raw(const void *data, double timestamp, bool pushthrough) {
141+
if (lsl::api_config::get_instance()->force_default_timestamps()) timestamp = 0.0;
142+
sample_p smp(
143+
sample_factory_->new_sample(timestamp == 0.0 ? lsl_clock() : timestamp, pushthrough));
144+
smp->assign_untyped(data);
145+
send_buffer_->push_sample(smp);
146+
}
147+
138148
bool stream_outlet_impl::have_consumers() { return send_buffer_->have_consumers(); }
139149

140150
bool stream_outlet_impl::wait_for_consumers(double timeout) {
141151
return send_buffer_->wait_for_consumers(timeout);
142152
}
153+
154+
template <class T>
155+
void stream_outlet_impl::enqueue(const T *data, double timestamp, bool pushthrough) {
156+
if (lsl::api_config::get_instance()->force_default_timestamps()) timestamp = 0.0;
157+
sample_p smp(
158+
sample_factory_->new_sample(timestamp == 0.0 ? lsl_clock() : timestamp, pushthrough));
159+
smp->assign_typed(data);
160+
send_buffer_->push_sample(smp);
161+
}
162+
163+
template void stream_outlet_impl::enqueue<char>(const char *data, double, bool);
164+
template void stream_outlet_impl::enqueue<int16_t>(const int16_t *data, double, bool);
165+
template void stream_outlet_impl::enqueue<int32_t>(const int32_t *data, double, bool);
166+
template void stream_outlet_impl::enqueue<int64_t>(const int64_t *data, double, bool);
167+
template void stream_outlet_impl::enqueue<float>(const float *data, double, bool);
168+
template void stream_outlet_impl::enqueue<double>(const double *data, double, bool);
169+
template void stream_outlet_impl::enqueue<std::string>(const std::string *data, double, bool);
170+
171+
} // namespace lsl

src/stream_outlet_impl.h

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#ifndef STREAM_OUTLET_IMPL_H
22
#define STREAM_OUTLET_IMPL_H
33

4-
#include "api_config.h"
54
#include "common.h"
65
#include "forward.h"
76
#include "sample.h"
@@ -162,13 +161,7 @@ class stream_outlet_impl {
162161
* @param pushthrough Whether to push the sample through to the receivers instead of buffering
163162
* it into a chunk according to network speeds.
164163
*/
165-
void push_numeric_raw(const void *data, double timestamp = 0.0, bool pushthrough = true) {
166-
if (lsl::api_config::get_instance()->force_default_timestamps()) timestamp = 0.0;
167-
sample_p smp(
168-
sample_factory_->new_sample(timestamp == 0.0 ? lsl_clock() : timestamp, pushthrough));
169-
smp->assign_untyped(data);
170-
send_buffer_->push_sample(smp);
171-
}
164+
void push_numeric_raw(const void *data, double timestamp = 0.0, bool pushthrough = true);
172165

173166
//
174167
// === Pushing an chunk of samples into the outlet ===
@@ -300,17 +293,8 @@ class stream_outlet_impl {
300293
/// Instantiate a new server stack.
301294
void instantiate_stack(tcp tcp_protocol, udp udp_protocol);
302295

303-
/// Run the given io_context
304-
void run_io(io_context_p &ios);
305-
306296
/// Allocate and enqueue a new sample into the send buffer.
307-
template <class T> void enqueue(T *data, double timestamp, bool pushthrough) {
308-
if (lsl::api_config::get_instance()->force_default_timestamps()) timestamp = 0.0;
309-
sample_p smp(
310-
sample_factory_->new_sample(timestamp == 0.0 ? lsl_clock() : timestamp, pushthrough));
311-
smp->assign_typed(data);
312-
send_buffer_->push_sample(smp);
313-
}
297+
template <class T> void enqueue(const T *data, double timestamp, bool pushthrough);
314298

315299
/**
316300
* Check whether some given number of channels matches the stream's channel_count.

src/tcp_server.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "tcp_server.h"
2+
#include "api_config.h"
23
#include "cast.h"
34
#include "consumer_queue.h"
45
#include "sample.h"

0 commit comments

Comments
 (0)