Reformat code with clang 10

This commit is contained in:
badaix 2020-11-27 21:29:34 +01:00
parent 59763f03c1
commit 3ac9245d00
24 changed files with 174 additions and 155 deletions

View file

@ -281,6 +281,8 @@ IF(CLANG_FORMAT)
server/*.[ch]pp
)
list(REMOVE_ITEM CHECK_CXX_SOURCE_FILES "${CMAKE_SOURCE_DIR}/common/json.hpp")
ADD_CUSTOM_TARGET(
reformat
COMMAND

View file

@ -176,15 +176,16 @@ bool BrowseBonjour::browse(const string& serviceName, mDNSResult& result, int /*
deque<mDNSReply> replyCollection;
{
DNSServiceHandle service(new DNSServiceRef(NULL));
CHECKED(DNSServiceBrowse(service.get(), 0, 0, serviceName.c_str(), "local.",
[](DNSServiceRef /*service*/, DNSServiceFlags /*flags*/, uint32_t /*interfaceIndex*/, DNSServiceErrorType errorCode,
const char* serviceName, const char* regtype, const char* replyDomain, void* context) {
auto replyCollection = static_cast<deque<mDNSReply>*>(context);
CHECKED(DNSServiceBrowse(
service.get(), 0, 0, serviceName.c_str(), "local.",
[](DNSServiceRef /*service*/, DNSServiceFlags /*flags*/, uint32_t /*interfaceIndex*/, DNSServiceErrorType errorCode, const char* serviceName,
const char* regtype, const char* replyDomain, void* context) {
auto replyCollection = static_cast<deque<mDNSReply>*>(context);
CHECKED(errorCode);
replyCollection->push_back(mDNSReply{string(serviceName), string(regtype), string(replyDomain)});
},
&replyCollection));
CHECKED(errorCode);
replyCollection->push_back(mDNSReply{string(serviceName), string(regtype), string(replyDomain)});
},
&replyCollection));
runService(service);
}
@ -194,16 +195,16 @@ bool BrowseBonjour::browse(const string& serviceName, mDNSResult& result, int /*
{
DNSServiceHandle service(new DNSServiceRef(NULL));
for (auto& reply : replyCollection)
CHECKED(DNSServiceResolve(service.get(), 0, 0, reply.name.c_str(), reply.regtype.c_str(), reply.domain.c_str(),
[](DNSServiceRef /*service*/, DNSServiceFlags /*flags*/, uint32_t /*interfaceIndex*/, DNSServiceErrorType errorCode,
const char* /*fullName*/, const char* hosttarget, uint16_t port, uint16_t /*txtLen*/,
const unsigned char* /*txtRecord*/, void* context) {
auto resultCollection = static_cast<deque<mDNSResolve>*>(context);
CHECKED(DNSServiceResolve(
service.get(), 0, 0, reply.name.c_str(), reply.regtype.c_str(), reply.domain.c_str(),
[](DNSServiceRef /*service*/, DNSServiceFlags /*flags*/, uint32_t /*interfaceIndex*/, DNSServiceErrorType errorCode, const char* /*fullName*/,
const char* hosttarget, uint16_t port, uint16_t /*txtLen*/, const unsigned char* /*txtRecord*/, void* context) {
auto resultCollection = static_cast<deque<mDNSResolve>*>(context);
CHECKED(errorCode);
resultCollection->push_back(mDNSResolve{string(hosttarget), ntohs(port)});
},
&resolveCollection));
CHECKED(errorCode);
resultCollection->push_back(mDNSResolve{string(hosttarget), ntohs(port)});
},
&resolveCollection));
runService(service);
}
@ -216,25 +217,25 @@ bool BrowseBonjour::browse(const string& serviceName, mDNSResult& result, int /*
for (auto& resolve : resolveCollection)
{
resultCollection[i].port = resolve.port;
CHECKED(DNSServiceGetAddrInfo(service.get(), kDNSServiceFlagsLongLivedQuery, 0, kDNSServiceProtocol_IPv4, resolve.fullName.c_str(),
[](DNSServiceRef /*service*/, DNSServiceFlags /*flags*/, uint32_t interfaceIndex, DNSServiceErrorType /*errorCode*/,
const char* hostname, const sockaddr* address, uint32_t /*ttl*/, void* context) {
auto result = static_cast<mDNSResult*>(context);
CHECKED(DNSServiceGetAddrInfo(
service.get(), kDNSServiceFlagsLongLivedQuery, 0, kDNSServiceProtocol_IPv4, resolve.fullName.c_str(),
[](DNSServiceRef /*service*/, DNSServiceFlags /*flags*/, uint32_t interfaceIndex, DNSServiceErrorType /*errorCode*/, const char* hostname,
const sockaddr* address, uint32_t /*ttl*/, void* context) {
auto result = static_cast<mDNSResult*>(context);
result->host = string(hostname);
result->ip_version = (address->sa_family == AF_INET) ? (IPVersion::IPv4) : (IPVersion::IPv6);
result->iface_idx = static_cast<int>(interfaceIndex);
result->host = string(hostname);
result->ip_version = (address->sa_family == AF_INET) ? (IPVersion::IPv4) : (IPVersion::IPv6);
result->iface_idx = static_cast<int>(interfaceIndex);
char hostIP[NI_MAXHOST];
char hostService[NI_MAXSERV];
if (getnameinfo(address, sizeof(*address), hostIP, sizeof(hostIP), hostService, sizeof(hostService),
NI_NUMERICHOST | NI_NUMERICSERV) == 0)
result->ip = string(hostIP);
else
return;
result->valid = true;
},
&resultCollection[i++]));
char hostIP[NI_MAXHOST];
char hostService[NI_MAXSERV];
if (getnameinfo(address, sizeof(*address), hostIP, sizeof(hostIP), hostService, sizeof(hostService), NI_NUMERICHOST | NI_NUMERICSERV) == 0)
result->ip = string(hostIP);
else
return;
result->valid = true;
},
&resultCollection[i++]));
}
runService(service);
}

View file

@ -61,7 +61,7 @@ public:
/// @param value the response message
void setValue(std::unique_ptr<msg::BaseMessage> value)
{
boost::asio::post(strand_, [ this, self = shared_from_this(), val = std::move(value) ]() mutable {
boost::asio::post(strand_, [this, self = shared_from_this(), val = std::move(value)]() mutable {
timer_.cancel();
if (handler_)
handler_({}, std::move(val));
@ -79,7 +79,7 @@ public:
void startTimer(const chronos::usec& timeout)
{
timer_.expires_after(timeout);
timer_.async_wait(boost::asio::bind_executor(strand_, [ this, self = shared_from_this() ](boost::system::error_code ec) {
timer_.async_wait(boost::asio::bind_executor(strand_, [this, self = shared_from_this()](boost::system::error_code ec) {
if (!handler_)
return;
if (!ec)

View file

@ -260,34 +260,35 @@ void Controller::getNextMessage()
void Controller::sendTimeSyncMessage(int quick_syncs)
{
auto timeReq = std::make_shared<msg::Time>();
clientConnection_->sendRequest<msg::Time>(timeReq, 2s, [this, quick_syncs](const boost::system::error_code& ec,
const std::unique_ptr<msg::Time>& response) mutable {
if (ec)
{
LOG(ERROR, LOG_TAG) << "Time sync request failed: " << ec.message() << "\n";
reconnect();
return;
}
else
{
TimeProvider::getInstance().setDiff(response->latency, response->received - response->sent);
}
std::chrono::microseconds next = TIME_SYNC_INTERVAL;
if (quick_syncs > 0)
{
if (--quick_syncs == 0)
LOG(INFO, LOG_TAG) << "diff to server [ms]: " << (float)TimeProvider::getInstance().getDiffToServer<chronos::usec>().count() / 1000.f << "\n";
next = 100us;
}
timer_.expires_after(next);
timer_.async_wait([this, quick_syncs](const boost::system::error_code& ec) {
if (!ec)
clientConnection_->sendRequest<msg::Time>(
timeReq, 2s, [this, quick_syncs](const boost::system::error_code& ec, const std::unique_ptr<msg::Time>& response) mutable {
if (ec)
{
sendTimeSyncMessage(quick_syncs);
LOG(ERROR, LOG_TAG) << "Time sync request failed: " << ec.message() << "\n";
reconnect();
return;
}
else
{
TimeProvider::getInstance().setDiff(response->latency, response->received - response->sent);
}
std::chrono::microseconds next = TIME_SYNC_INTERVAL;
if (quick_syncs > 0)
{
if (--quick_syncs == 0)
LOG(INFO, LOG_TAG) << "diff to server [ms]: " << (float)TimeProvider::getInstance().getDiffToServer<chronos::usec>().count() / 1000.f
<< "\n";
next = 100us;
}
timer_.expires_after(next);
timer_.async_wait([this, quick_syncs](const boost::system::error_code& ec) {
if (!ec)
{
sendTimeSyncMessage(quick_syncs);
}
});
});
});
}
void Controller::browseMdns(const MdnsHandler& handler)

View file

@ -368,7 +368,8 @@ void AlsaPlayer::initAlsa()
unsigned int period_time;
snd_pcm_hw_params_get_period_time(params, &period_time, nullptr);
snd_pcm_hw_params_get_period_size(params, &frames_, nullptr);
LOG(INFO, LOG_TAG) << "rate: " << rate << ", channels: " << channels << ", buffer time: " << buffer_time << " us, periods: " << periods << ", period time: " << period_time << " us, period frames: " << frames_ << "\n";
LOG(INFO, LOG_TAG) << "rate: " << rate << ", channels: " << channels << ", buffer time: " << buffer_time << " us, periods: " << periods
<< ", period time: " << period_time << " us, period frames: " << frames_ << "\n";
// Allocate buffer to hold single period
snd_pcm_sw_params_t* swparams;

View file

@ -93,29 +93,30 @@ bool PulsePlayer::getHardwareVolume(double& volume, bool& muted)
void PulsePlayer::triggerVolumeUpdate()
{
pa_context_get_sink_input_info(pa_ctx_, pa_stream_get_index(playstream_),
[](pa_context* ctx, const pa_sink_input_info* info, int eol, void* userdata) {
std::ignore = ctx;
LOG(DEBUG, LOG_TAG) << "pa_context_get_sink_info_by_index info: " << (info != nullptr) << ", eol: " << eol << "\n";
if (info)
{
auto self = static_cast<PulsePlayer*>(userdata);
auto volume = (double)pa_cvolume_avg(&(info->volume)) / (double)PA_VOLUME_NORM;
bool muted = (info->mute != 0);
LOG(DEBUG, LOG_TAG) << "volume changed: " << volume << ", muted: " << muted << "\n";
pa_context_get_sink_input_info(
pa_ctx_, pa_stream_get_index(playstream_),
[](pa_context* ctx, const pa_sink_input_info* info, int eol, void* userdata) {
std::ignore = ctx;
LOG(DEBUG, LOG_TAG) << "pa_context_get_sink_info_by_index info: " << (info != nullptr) << ", eol: " << eol << "\n";
if (info)
{
auto self = static_cast<PulsePlayer*>(userdata);
auto volume = (double)pa_cvolume_avg(&(info->volume)) / (double)PA_VOLUME_NORM;
bool muted = (info->mute != 0);
LOG(DEBUG, LOG_TAG) << "volume changed: " << volume << ", muted: " << muted << "\n";
auto now = std::chrono::steady_clock::now();
if (now - self->last_change_ < 1s)
{
LOG(DEBUG, LOG_TAG) << "Last volume change by server: "
<< std::chrono::duration_cast<std::chrono::milliseconds>(now - self->last_change_).count()
<< " ms => ignoring volume change\n";
return;
}
self->notifyVolumeChange(volume, muted);
}
},
this);
auto now = std::chrono::steady_clock::now();
if (now - self->last_change_ < 1s)
{
LOG(DEBUG, LOG_TAG) << "Last volume change by server: "
<< std::chrono::duration_cast<std::chrono::milliseconds>(now - self->last_change_).count()
<< " ms => ignoring volume change\n";
return;
}
self->notifyVolumeChange(volume, muted);
}
},
this);
}
@ -247,12 +248,13 @@ void PulsePlayer::start()
// modify the variable to 1 so we know when we have a connection and it's
// ready.
// If there's an error, the callback will set pa_ready to 2
pa_context_set_state_callback(pa_ctx_,
[](pa_context* c, void* userdata) {
auto self = static_cast<PulsePlayer*>(userdata);
self->stateCallback(c);
},
this);
pa_context_set_state_callback(
pa_ctx_,
[](pa_context* c, void* userdata) {
auto self = static_cast<PulsePlayer*>(userdata);
self->stateCallback(c);
},
this);
// We can't do anything until PA is ready, so just iterate the mainloop
// and continue
@ -276,39 +278,43 @@ void PulsePlayer::start()
if (settings_.mixer.mode == ClientSettings::Mixer::Mode::hardware)
{
pa_context_set_subscribe_callback(pa_ctx_,
[](pa_context* ctx, pa_subscription_event_type_t event_type, uint32_t idx, void* userdata) {
auto self = static_cast<PulsePlayer*>(userdata);
self->subscribeCallback(ctx, event_type, idx);
},
this);
pa_context_set_subscribe_callback(
pa_ctx_,
[](pa_context* ctx, pa_subscription_event_type_t event_type, uint32_t idx, void* userdata) {
auto self = static_cast<PulsePlayer*>(userdata);
self->subscribeCallback(ctx, event_type, idx);
},
this);
const pa_subscription_mask_t mask = static_cast<pa_subscription_mask_t>(PA_SUBSCRIPTION_MASK_SINK_INPUT);
pa_context_subscribe(pa_ctx_, mask,
[](pa_context* ctx, int success, void* userdata) {
std::ignore = ctx;
if (success)
{
auto self = static_cast<PulsePlayer*>(userdata);
self->triggerVolumeUpdate();
}
},
this);
pa_context_subscribe(
pa_ctx_, mask,
[](pa_context* ctx, int success, void* userdata) {
std::ignore = ctx;
if (success)
{
auto self = static_cast<PulsePlayer*>(userdata);
self->triggerVolumeUpdate();
}
},
this);
}
pa_stream_set_write_callback(playstream_,
[](pa_stream* stream, size_t length, void* userdata) {
auto self = static_cast<PulsePlayer*>(userdata);
self->writeCallback(stream, length);
},
this);
pa_stream_set_write_callback(
playstream_,
[](pa_stream* stream, size_t length, void* userdata) {
auto self = static_cast<PulsePlayer*>(userdata);
self->writeCallback(stream, length);
},
this);
pa_stream_set_underflow_callback(playstream_,
[](pa_stream* stream, void* userdata) {
auto self = static_cast<PulsePlayer*>(userdata);
self->underflowCallback(stream);
},
this);
pa_stream_set_underflow_callback(
playstream_,
[](pa_stream* stream, void* userdata) {
auto self = static_cast<PulsePlayer*>(userdata);
self->underflowCallback(stream);
},
this);
bufattr_.fragsize = pa_usec_to_bytes(latency_.count(), &pa_ss_);
bufattr_.maxlength = pa_usec_to_bytes(latency_.count(), &pa_ss_);

View file

@ -42,6 +42,6 @@ inline int64_t swap(const int64_t& val)
{
return SWAP_64(val);
}
}
} // namespace endian
#endif

View file

@ -58,7 +58,7 @@ public:
msg["muted"] = muted;
}
};
}
} // namespace msg
#endif

View file

@ -106,7 +106,7 @@ public:
return id;
}
};
}
} // namespace msg
#endif

View file

@ -80,7 +80,7 @@ public:
msg["muted"] = muted;
}
};
}
} // namespace msg
#endif

View file

@ -67,7 +67,7 @@ public:
~StreamTags() override = default;
};
}
} // namespace msg
#endif

View file

@ -53,7 +53,7 @@ protected:
writeVal(stream, latency.usec);
}
};
}
} // namespace msg
#endif

View file

@ -111,7 +111,7 @@ static float strtof(const char* str, char** endptr)
return std::strtof(str, endptr);
#endif
}
}
} // namespace cpt
#endif

View file

@ -152,8 +152,9 @@ ControlSessionHttp::~ControlSessionHttp()
void ControlSessionHttp::start()
{
http::async_read(socket_, buffer_, req_, boost::asio::bind_executor(strand_, [ this, self = shared_from_this() ](
boost::system::error_code ec, std::size_t bytes) { on_read(ec, bytes); }));
http::async_read(
socket_, buffer_, req_,
boost::asio::bind_executor(strand_, [this, self = shared_from_this()](boost::system::error_code ec, std::size_t bytes) { on_read(ec, bytes); }));
}
@ -313,7 +314,7 @@ void ControlSessionHttp::on_read(beast::error_code ec, std::size_t bytes_transfe
// Create a WebSocket session by transferring the socket
// std::make_shared<websocket_session>(std::move(socket_), state_)->run(std::move(req_));
auto ws = std::make_shared<websocket::stream<beast::tcp_stream>>(std::move(socket_));
ws->async_accept(req_, [ this, ws, self = shared_from_this() ](beast::error_code ec) {
ws->async_accept(req_, [this, ws, self = shared_from_this()](beast::error_code ec) {
if (ec)
{
LOG(ERROR, LOG_TAG) << "Error during WebSocket handshake (control): " << ec.message() << "\n";
@ -330,7 +331,7 @@ void ControlSessionHttp::on_read(beast::error_code ec, std::size_t bytes_transfe
// Create a WebSocket session by transferring the socket
// std::make_shared<websocket_session>(std::move(socket_), state_)->run(std::move(req_));
auto ws = std::make_shared<websocket::stream<beast::tcp_stream>>(std::move(socket_));
ws->async_accept(req_, [ this, ws, self = shared_from_this() ](beast::error_code ec) {
ws->async_accept(req_, [this, ws, self = shared_from_this()](beast::error_code ec) {
if (ec)
{
LOG(ERROR, LOG_TAG) << "Error during WebSocket handshake (stream): " << ec.message() << "\n";
@ -355,7 +356,7 @@ void ControlSessionHttp::on_read(beast::error_code ec, std::size_t bytes_transfe
// Write the response
http::async_write(this->socket_, *sp,
boost::asio::bind_executor(strand_, [ this, self = this->shared_from_this(), sp ](beast::error_code ec, std::size_t bytes) {
boost::asio::bind_executor(strand_, [this, self = this->shared_from_this(), sp](beast::error_code ec, std::size_t bytes) {
this->on_write(ec, bytes, sp->need_eof());
}));
});
@ -385,7 +386,7 @@ void ControlSessionHttp::on_write(beast::error_code ec, std::size_t, bool close)
// Read another request
http::async_read(socket_, buffer_, req_,
boost::asio::bind_executor(strand_, [ this, self = shared_from_this() ](beast::error_code ec, std::size_t bytes) { on_read(ec, bytes); }));
boost::asio::bind_executor(strand_, [this, self = shared_from_this()](beast::error_code ec, std::size_t bytes) { on_read(ec, bytes); }));
}

View file

@ -45,7 +45,7 @@ void ControlSessionTcp::do_read()
const std::string delimiter = "\n";
boost::asio::async_read_until(
socket_, streambuf_, delimiter,
boost::asio::bind_executor(strand_, [ this, self = shared_from_this(), delimiter ](const std::error_code& ec, std::size_t bytes_transferred) {
boost::asio::bind_executor(strand_, [this, self = shared_from_this(), delimiter](const std::error_code& ec, std::size_t bytes_transferred) {
if (ec)
{
LOG(ERROR, LOG_TAG) << "Error while reading from control socket: " << ec.message() << "\n";
@ -94,7 +94,7 @@ void ControlSessionTcp::stop()
void ControlSessionTcp::sendAsync(const std::string& message)
{
strand_.post([ this, self = shared_from_this(), message ]() {
strand_.post([this, self = shared_from_this(), message]() {
messages_.emplace_back(message + "\r\n");
if (messages_.size() > 1)
{
@ -108,7 +108,7 @@ void ControlSessionTcp::sendAsync(const std::string& message)
void ControlSessionTcp::send_next()
{
boost::asio::async_write(socket_, boost::asio::buffer(messages_.front()),
boost::asio::bind_executor(strand_, [ this, self = shared_from_this() ](std::error_code ec, std::size_t length) {
boost::asio::bind_executor(strand_, [this, self = shared_from_this()](std::error_code ec, std::size_t length) {
messages_.pop_front();
if (ec)
{

View file

@ -61,7 +61,7 @@ void ControlSessionWebsocket::stop()
void ControlSessionWebsocket::sendAsync(const std::string& message)
{
strand_.post([ this, self = shared_from_this(), msg = message ]() {
strand_.post([this, self = shared_from_this(), msg = message]() {
messages_.push_back(std::move(msg));
if (messages_.size() > 1)
{
@ -77,7 +77,7 @@ void ControlSessionWebsocket::send_next()
{
const std::string& message = messages_.front();
ws_.async_write(boost::asio::buffer(message),
boost::asio::bind_executor(strand_, [ this, self = shared_from_this() ](std::error_code ec, std::size_t length) {
boost::asio::bind_executor(strand_, [this, self = shared_from_this()](std::error_code ec, std::size_t length) {
messages_.pop_front();
if (ec)
{
@ -96,7 +96,7 @@ void ControlSessionWebsocket::send_next()
void ControlSessionWebsocket::do_read_ws()
{
// Read a message into our buffer
ws_.async_read(buffer_, boost::asio::bind_executor(strand_, [ this, self = shared_from_this() ](beast::error_code ec, std::size_t bytes_transferred) {
ws_.async_read(buffer_, boost::asio::bind_executor(strand_, [this, self = shared_from_this()](beast::error_code ec, std::size_t bytes_transferred) {
on_read_ws(ec, bytes_transferred);
}));
}

View file

@ -803,7 +803,8 @@ inline void Error::parse_json(const Json& json)
inline Json Error::to_json() const
{
Json j = {
{"code", code_}, {"message", message_},
{"code", code_},
{"message", message_},
};
if (!data_.is_null())
@ -1065,7 +1066,8 @@ inline void Response::parse_json(const Json& json)
inline Json Response::to_json() const
{
Json j = {
{"jsonrpc", "2.0"}, {"id", id_.to_json()},
{"jsonrpc", "2.0"},
{"id", id_.to_json()},
};
if (error_)
@ -1129,7 +1131,8 @@ inline void Notification::parse_json(const Json& json)
inline Json Notification::to_json() const
{
Json json = {
{"jsonrpc", "2.0"}, {"method", method_},
{"jsonrpc", "2.0"},
{"method", method_},
};
if (params_)

View file

@ -222,8 +222,8 @@ void PublishAvahi::client_callback(AvahiClient* c, AvahiClientState state, AVAHI
case AVAHI_CLIENT_S_COLLISION:
/// Let's drop our registered services. When the server is back
/// in AVAHI_SERVER_RUNNING state we will register them again with the new host name.
/// Let's drop our registered services. When the server is back
/// in AVAHI_SERVER_RUNNING state we will register them again with the new host name.
case AVAHI_CLIENT_S_REGISTERING:

View file

@ -24,7 +24,8 @@
static constexpr auto LOG_TAG = "Bonjour";
typedef union {
typedef union
{
unsigned char b[2];
unsigned short NotAnInteger;
} Opaque16;

View file

@ -52,7 +52,7 @@ void StreamSession::send_next()
{
auto& buffer = messages_.front();
buffer.on_air = true;
strand_.post([ this, self = shared_from_this(), buffer ]() {
strand_.post([this, self = shared_from_this(), buffer]() {
sendAsync(buffer, [this](boost::system::error_code ec, std::size_t length) {
messages_.pop_front();
if (ec)
@ -70,7 +70,7 @@ void StreamSession::send_next()
void StreamSession::send(shared_const_buffer const_buf)
{
strand_.post([ this, self = shared_from_this(), const_buf ]() {
strand_.post([this, self = shared_from_this(), const_buf]() {
// delete PCM chunks that are older than the overall buffer duration
messages_.erase(std::remove_if(messages_.begin(), messages_.end(),
[this](const shared_const_buffer& buffer) {

View file

@ -81,7 +81,7 @@ std::string StreamSessionTcp::getIP()
void StreamSessionTcp::read_next()
{
boost::asio::async_read(socket_, boost::asio::buffer(buffer_, base_msg_size_),
boost::asio::bind_executor(strand_, [ this, self = shared_from_this() ](boost::system::error_code ec, std::size_t length) mutable {
boost::asio::bind_executor(strand_, [this, self = shared_from_this()](boost::system::error_code ec, std::size_t length) mutable {
if (ec)
{
LOG(ERROR, LOG_TAG) << "Error reading message header of length " << length << ": " << ec.message() << "\n";
@ -131,6 +131,6 @@ void StreamSessionTcp::read_next()
void StreamSessionTcp::sendAsync(const shared_const_buffer& buffer, const WriteHandler& handler)
{
boost::asio::async_write(socket_, buffer,
boost::asio::bind_executor(strand_, [ self = shared_from_this(), buffer, handler ](boost::system::error_code ec,
std::size_t length) { handler(ec, length); }));
boost::asio::bind_executor(strand_, [self = shared_from_this(), buffer, handler](boost::system::error_code ec,
std::size_t length) { handler(ec, length); }));
}

View file

@ -77,15 +77,16 @@ std::string StreamSessionWebsocket::getIP()
void StreamSessionWebsocket::sendAsync(const shared_const_buffer& buffer, const WriteHandler& handler)
{
LOG(TRACE, LOG_TAG) << "sendAsync: " << buffer.message().type << "\n";
ws_.async_write(buffer, boost::asio::bind_executor(strand_, [ self = shared_from_this(), buffer, handler ](boost::system::error_code ec,
std::size_t length) { handler(ec, length); }));
ws_.async_write(buffer, boost::asio::bind_executor(strand_, [self = shared_from_this(), buffer, handler](boost::system::error_code ec, std::size_t length) {
handler(ec, length);
}));
}
void StreamSessionWebsocket::do_read_ws()
{
// Read a message into our buffer
ws_.async_read(buffer_, boost::asio::bind_executor(strand_, [ this, self = shared_from_this() ](beast::error_code ec, std::size_t bytes_transferred) {
ws_.async_read(buffer_, boost::asio::bind_executor(strand_, [this, self = shared_from_this()](beast::error_code ec, std::size_t bytes_transferred) {
on_read_ws(ec, bytes_transferred);
}));
}

View file

@ -192,7 +192,9 @@ json PcmStream::toJson() const
state = "disabled";
json j = {
{"uri", uri_.toJson()}, {"id", getId()}, {"status", state},
{"uri", uri_.toJson()},
{"id", getId()},
{"status", state},
};
if (meta_)

View file

@ -147,4 +147,4 @@ std::string StreamUri::getQuery(const std::string& key, const std::string& def)
return iter->second;
return def;
}
}
} // namespace streamreader