mirror of
https://github.com/badaix/snapcast.git
synced 2025-06-03 03:11:43 +02:00
Reformat code
This commit is contained in:
parent
58e82ef9e8
commit
d5677b6f78
31 changed files with 236 additions and 330 deletions
|
@ -1,6 +1,6 @@
|
|||
/***
|
||||
This file is part of snapcast
|
||||
Copyright (C) 2014-2024 Johannes Pohl
|
||||
Copyright (C) 2014-2025 Johannes Pohl
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
@ -45,7 +45,7 @@ StreamSession::StreamSession(const boost::asio::any_io_executor& executor, Strea
|
|||
void StreamSession::setPcmStream(PcmStreamPtr pcmStream)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
pcmStream_ = pcmStream;
|
||||
pcmStream_ = std::move(pcmStream);
|
||||
}
|
||||
|
||||
|
||||
|
@ -60,12 +60,10 @@ void StreamSession::send_next()
|
|||
{
|
||||
auto& buffer = messages_.front();
|
||||
buffer.on_air = true;
|
||||
boost::asio::post(strand_,
|
||||
[this, self = shared_from_this(), buffer]()
|
||||
{
|
||||
sendAsync(buffer,
|
||||
[this](boost::system::error_code ec, std::size_t length)
|
||||
{
|
||||
boost::asio::post(strand_, [this, self = shared_from_this(), buffer]()
|
||||
{
|
||||
sendAsync(buffer, [this](boost::system::error_code ec, std::size_t length)
|
||||
{
|
||||
messages_.pop_front();
|
||||
if (ec)
|
||||
{
|
||||
|
@ -82,19 +80,18 @@ void StreamSession::send_next()
|
|||
|
||||
void StreamSession::send(shared_const_buffer const_buf)
|
||||
{
|
||||
boost::asio::post(strand_,
|
||||
[this, self = shared_from_this(), const_buf]()
|
||||
{
|
||||
boost::asio::post(strand_, [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)
|
||||
{
|
||||
{
|
||||
const auto& msg = buffer.message();
|
||||
if (!msg.is_pcm_chunk || buffer.on_air)
|
||||
return false;
|
||||
auto age = chronos::clk::now() - msg.rec_time;
|
||||
return (age > std::chrono::milliseconds(bufferMs_) + 100ms);
|
||||
}),
|
||||
}),
|
||||
messages_.end());
|
||||
|
||||
messages_.push_back(const_buf);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue