mirror of
https://github.com/badaix/snapcast.git
synced 2025-05-14 01:26:42 +02:00
Pass encoded chunks as shared_ptr
This commit is contained in:
parent
d9d403d729
commit
63ad64dfff
10 changed files with 15 additions and 21 deletions
|
@ -28,9 +28,8 @@ using namespace std;
|
|||
namespace encoder
|
||||
{
|
||||
|
||||
FlacEncoder::FlacEncoder(const std::string& codecOptions) : Encoder(codecOptions), encoder_(nullptr), pcmBufferSize_(0), encodedSamples_(0)
|
||||
FlacEncoder::FlacEncoder(const std::string& codecOptions) : Encoder(codecOptions), encoder_(nullptr), pcmBufferSize_(0), encodedSamples_(0), flacChunk_(nullptr)
|
||||
{
|
||||
flacChunk_ = new msg::PcmChunk();
|
||||
headerChunk_.reset(new msg::CodecHeader("flac"));
|
||||
pcmBuffer_ = (FLAC__int32*)malloc(pcmBufferSize_ * sizeof(FLAC__int32));
|
||||
}
|
||||
|
@ -46,7 +45,6 @@ FlacEncoder::~FlacEncoder()
|
|||
FLAC__stream_encoder_delete(encoder_);
|
||||
}
|
||||
|
||||
delete flacChunk_;
|
||||
free(pcmBuffer_);
|
||||
}
|
||||
|
||||
|
@ -71,8 +69,8 @@ std::string FlacEncoder::name() const
|
|||
|
||||
void FlacEncoder::encode(const msg::PcmChunk* chunk)
|
||||
{
|
||||
if (!flacChunk_->format.isInitialized())
|
||||
flacChunk_->format = chunk->format;
|
||||
if (flacChunk_ == nullptr)
|
||||
flacChunk_ = make_shared<msg::PcmChunk>(chunk->format, 0);
|
||||
|
||||
int samples = chunk->getSampleCount();
|
||||
int frames = chunk->getFrameCount();
|
||||
|
@ -113,7 +111,7 @@ void FlacEncoder::encode(const msg::PcmChunk* chunk)
|
|||
// LOG(INFO) << "encoded: " << chunk->payloadSize << "\tframes: " << encodedSamples_ << "\tres: " << resMs << "\n";
|
||||
encodedSamples_ = 0;
|
||||
listener_->onChunkEncoded(this, flacChunk_, resMs);
|
||||
flacChunk_ = new msg::PcmChunk(chunk->format, 0);
|
||||
flacChunk_ = make_shared<msg::PcmChunk>(chunk->format, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue