mirror of
https://github.com/badaix/snapcast.git
synced 2025-05-25 06:56:15 +02:00
Reformat code
This commit is contained in:
parent
2efe44517a
commit
0c25a7a42d
3 changed files with 7 additions and 20 deletions
|
@ -93,7 +93,7 @@ void ControlSessionTcp::stop()
|
||||||
void ControlSessionTcp::sendAsync(const std::string& message)
|
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);
|
messages_.emplace_back(message + "\r\n");
|
||||||
if (messages_.size() > 1)
|
if (messages_.size() > 1)
|
||||||
{
|
{
|
||||||
LOG(DEBUG) << "TCP session outstanding async_writes: " << messages_.size() << "\n";
|
LOG(DEBUG) << "TCP session outstanding async_writes: " << messages_.size() << "\n";
|
||||||
|
@ -105,20 +105,7 @@ void ControlSessionTcp::sendAsync(const std::string& message)
|
||||||
|
|
||||||
void ControlSessionTcp::send_next()
|
void ControlSessionTcp::send_next()
|
||||||
{
|
{
|
||||||
// We cannot simply do boost::asio::buffer(message + "\r\n"), because 'message + "\r\n"' becomes invalid
|
boost::asio::async_write(socket_, boost::asio::buffer(messages_.front()),
|
||||||
// after leaving this method, leading to a 'Bad address' error.
|
|
||||||
// Instead, we need to mutate the string before passing it to boost::asio::buffer.
|
|
||||||
//
|
|
||||||
// From the boost reference:
|
|
||||||
//
|
|
||||||
// A buffer object does not have any ownership of the memory it refers to. It is the responsibility of
|
|
||||||
// the application to ensure the memory region remains valid until it is no longer required for an I/O
|
|
||||||
// operation. When the memory is no longer available, the buffer is said to have been invalidated.
|
|
||||||
// https://www.boost.org/doc/libs/1_72_0/doc/html/boost_asio/reference/buffer.html#boost_asio.reference.buffer.buffer_invalidation
|
|
||||||
|
|
||||||
string& message = messages_.front();
|
|
||||||
message += "\r\n";
|
|
||||||
boost::asio::async_write(socket_, 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();
|
messages_.pop_front();
|
||||||
if (ec)
|
if (ec)
|
||||||
|
|
|
@ -68,7 +68,7 @@ protected:
|
||||||
std::unique_ptr<TageEntry> entry_;
|
std::unique_ptr<TageEntry> entry_;
|
||||||
std::string buf_;
|
std::string buf_;
|
||||||
json metadata_;
|
json metadata_;
|
||||||
// set whenever metadata_ has changed
|
/// set whenever metadata_ has changed
|
||||||
bool metadata_dirty_;
|
bool metadata_dirty_;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ protected:
|
||||||
int parse(std::string line);
|
int parse(std::string line);
|
||||||
void createParser();
|
void createParser();
|
||||||
void push();
|
void push();
|
||||||
void setMetaData(const std::string&, const std::string&);
|
void setMetaData(const string& key, const string& newValue);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void setParamsAndPipePathFromPort();
|
void setParamsAndPipePathFromPort();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue