mirror of
https://github.com/badaix/snapcast.git
synced 2025-05-10 15:46:42 +02:00
valgrind optimizations
This commit is contained in:
parent
063ed462f9
commit
c8c3b0357e
4 changed files with 9 additions and 9 deletions
|
@ -124,7 +124,7 @@ void ControlServer::onMessageReceived(ServerSession* connection, const msg::Base
|
|||
|
||||
void ControlServer::startAccept()
|
||||
{
|
||||
socket_ptr socket(new tcp::socket(io_service_));
|
||||
socket_ptr socket = make_shared<tcp::socket>(io_service_);
|
||||
acceptor_->async_accept(*socket, bind(&ControlServer::handleAccept, this, socket));
|
||||
}
|
||||
|
||||
|
@ -137,7 +137,7 @@ void ControlServer::handleAccept(socket_ptr socket)
|
|||
setsockopt(socket->native(), SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv));
|
||||
setsockopt(socket->native(), SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(tv));
|
||||
logS(kLogNotice) << "ControlServer::NewConnection: " << socket->remote_endpoint().address().to_string() << endl;
|
||||
shared_ptr<ServerSession> session(new ServerSession(this, socket));
|
||||
shared_ptr<ServerSession> session = make_shared<ServerSession>(this, socket);
|
||||
{
|
||||
std::unique_lock<std::mutex> mlock(mutex_);
|
||||
session->setBufferMs(settings_.bufferMs);
|
||||
|
@ -152,7 +152,7 @@ void ControlServer::start()
|
|||
{
|
||||
pipeReader_ = new PipeReader(this, settings_.sampleFormat, settings_.codec, settings_.fifoName);
|
||||
pipeReader_->start();
|
||||
acceptor_ = shared_ptr<tcp::acceptor>(new tcp::acceptor(io_service_, tcp::endpoint(tcp::v4(), settings_.port)));
|
||||
acceptor_ = make_shared<tcp::acceptor>(io_service_, tcp::endpoint(tcp::v4(), settings_.port));
|
||||
startAccept();
|
||||
acceptThread_ = thread(&ControlServer::acceptor, this);
|
||||
}
|
||||
|
|
|
@ -93,7 +93,7 @@ void FlacEncoder::encode(const msg::PcmChunk* chunk)
|
|||
// logO << "encoded: " << chunk->payloadSize << "\tframes: " << encodedSamples_ << "\tres: " << resMs << "\n";
|
||||
encodedSamples_ = 0;
|
||||
listener_->onChunkEncoded(this, flacChunk_, resMs);
|
||||
flacChunk_ = new msg::PcmChunk();
|
||||
flacChunk_ = new msg::PcmChunk(chunk->format, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -175,13 +175,13 @@ void ServerSession::writer()
|
|||
{
|
||||
if (bufferMs_ > 0)
|
||||
{
|
||||
const msg::PcmChunk* pcmChunk = dynamic_cast<const msg::PcmChunk*>(message.get());
|
||||
if (pcmChunk != NULL)
|
||||
const msg::WireChunk* wireChunk = dynamic_cast<const msg::WireChunk*>(message.get());
|
||||
if (wireChunk != NULL)
|
||||
{
|
||||
chronos::time_point_hrc now = chronos::hrc::now();
|
||||
size_t age = 0;
|
||||
if (now > pcmChunk->start())
|
||||
age = std::chrono::duration_cast<chronos::msec>(now - pcmChunk->start()).count();
|
||||
if (now > wireChunk->start())
|
||||
age = std::chrono::duration_cast<chronos::msec>(now - wireChunk->start()).count();
|
||||
//logD << "PCM chunk. Age: " << age << ", buffer: " << bufferMs_ << ", age > buffer: " << (age > bufferMs_) << "\n";
|
||||
if (age > bufferMs_)
|
||||
continue;
|
||||
|
|
|
@ -121,7 +121,7 @@ int main(int argc, char* argv[])
|
|||
if (settings.bufferMs < 400)
|
||||
settings.bufferMs = 400;
|
||||
settings.sampleFormat = sampleFormat;
|
||||
ControlServer* controlServer = new ControlServer(settings);
|
||||
std::unique_ptr<ControlServer> controlServer(new ControlServer(settings));
|
||||
controlServer->start();
|
||||
|
||||
while (!g_terminated)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue