Files
EchoionCore/src/MemoryPool.cpp
T
faumarayandClaude Opus 4.8 2d7651c308 Route all logging through the Void::Log facade
Delete the echoion Logger adapter (Logger.{hpp,cpp}) and the
ILogger/LoggerRegistry indirection. Core::installLogging() builds the
console + split-file Void::Logging::MultiLogger and installs it as the
process-wide Void::Log sink via Void::Log::make_sink (logSink_ owns it for
the process lifetime). The ~450 ECHOION_LOG_* call sites across EchoionCore
are rewritten to Void::Log::<level>("<Subsystem>", "{}", <expr>) with
per-file module tags (warning->warn, critical->fatal); the pre-formatted
message is passed as the single "{}" argument. Build green.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-23 14:10:06 +03:00

61 lines
1.4 KiB
C++

#include <Void/Log/Log.hpp>
#include <MemoryPool.hpp>
#include <format>
#include <vector>
namespace Echoion::Api
{
AudioBufferPool& AudioBufferPool::instance()
{
static AudioBufferPool instance;
return instance;
}
void AudioBufferPool::initialize(size_t bufferSize, size_t poolSize)
{
bufferSize_ = bufferSize;
pool_ = std::make_unique<Void::BufferPool::BufferPool<int16_t>>();
// Pre-warm the size-class bucket: acquire then immediately drop
// `poolSize` buffers so subsequent acquireBuffer() calls reuse storage.
{
std::vector<AudioSampleBuffer> warm;
warm.reserve(poolSize);
for (size_t i = 0; i < poolSize; ++i) {
warm.push_back(pool_->acquire(bufferSize));
}
} // buffers returned to the pool here
Void::Log::info("MemoryPool", "{}", std::format(
"AudioBufferPool initialized: {} buffers of {} samples (~{} KB)",
poolSize, bufferSize,
(bufferSize * poolSize * sizeof(int16_t)) / 1024));
}
void AudioBufferPool::shutdown()
{
pool_.reset();
Void::Log::info("MemoryPool", "{}", "AudioBufferPool shutdown");
}
AudioSampleBuffer AudioBufferPool::acquireBuffer()
{
if (!pool_) {
return AudioSampleBuffer{};
}
return pool_->acquire(bufferSize_);
}
size_t AudioBufferPool::getAvailableBuffers() const
{
return pool_ ? pool_->stats().pooled : 0;
}
size_t AudioBufferPool::getTotalBuffers() const
{
return pool_ ? static_cast<size_t>(pool_->stats().allocations) : 0;
}
} // namespace Echoion::Api