Initial commit
This commit is contained in:
commit
a583c17916
56 files changed
+11025
No files matched your search
@@ -0,0 +1,47 @@
|
||||
#include "echoion/api/MemoryPool.hpp"
|
||||
#include "echoion/core/Logger.hpp"
|
||||
|
||||
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<MemoryPool<float>>(bufferSize, poolSize);
|
||||
ECHOION_LOG_INFO(std::format("AudioBufferPool initialized: {} buffers of {} samples (~{} MB)",
|
||||
poolSize, bufferSize, (bufferSize * poolSize * sizeof(float)) / (1024 * 1024)));
|
||||
}
|
||||
|
||||
void AudioBufferPool::shutdown() {
|
||||
pool_.reset();
|
||||
ECHOION_LOG_INFO("AudioBufferPool shutdown");
|
||||
}
|
||||
|
||||
PooledPtr<float> AudioBufferPool::acquireBuffer() {
|
||||
if (!pool_) {
|
||||
return PooledPtr<float>();
|
||||
}
|
||||
|
||||
float* ptr = pool_->acquire();
|
||||
if (!ptr) {
|
||||
ECHOION_LOG_WARNING("AudioBufferPool exhausted - consider increasing pool size");
|
||||
return PooledPtr<float>();
|
||||
}
|
||||
|
||||
return PooledPtr<float>(ptr, pool_.get());
|
||||
}
|
||||
|
||||
size_t AudioBufferPool::getAvailableBuffers() const {
|
||||
if (!pool_) return 0;
|
||||
return pool_->available();
|
||||
}
|
||||
|
||||
size_t AudioBufferPool::getTotalBuffers() const {
|
||||
if (!pool_) return 0;
|
||||
return pool_->capacity();
|
||||
}
|
||||
|
||||
} // namespace Echoion::Api
|
||||
Reference in new issue
Block a user