mirror of
https://github.com/badaix/snapcast.git
synced 2025-07-17 08:27:42 +02:00
FLAC: support different sample formats
This commit is contained in:
parent
c4fd9aa355
commit
16be4f53b8
2 changed files with 43 additions and 30 deletions
|
@ -80,10 +80,25 @@ void FlacEncoder::encode(const msg::PcmChunk* chunk)
|
|||
pcmBuffer_ = (FLAC__int32*)realloc(pcmBuffer_, pcmBufferSize_ * sizeof(FLAC__int32));
|
||||
}
|
||||
|
||||
for(int i=0; i<samples; i++)
|
||||
if (sampleFormat_.sampleSize == 1)
|
||||
{
|
||||
pcmBuffer_[i] = (FLAC__int32)(((FLAC__int16)(FLAC__int8)chunk->payload[2*i+1] << 8) | (FLAC__int16)(0x00ff&chunk->payload[2*i]));
|
||||
FLAC__int8* buffer = (FLAC__int8*)chunk->payload;
|
||||
for(int i=0; i<samples; i++)
|
||||
pcmBuffer_[i] = (FLAC__int32)(buffer[i]);
|
||||
}
|
||||
else if (sampleFormat_.sampleSize == 2)
|
||||
{
|
||||
FLAC__int16* buffer = (FLAC__int16*)chunk->payload;
|
||||
for(int i=0; i<samples; i++)
|
||||
pcmBuffer_[i] = (FLAC__int32)(buffer[i]);
|
||||
}
|
||||
else if (sampleFormat_.sampleSize == 4)
|
||||
{
|
||||
FLAC__int32* buffer = (FLAC__int32*)chunk->payload;
|
||||
for(int i=0; i<samples; i++)
|
||||
pcmBuffer_[i] = (FLAC__int32)(buffer[i]);
|
||||
}
|
||||
|
||||
|
||||
FLAC__stream_encoder_process_interleaved(encoder_, pcmBuffer_, frames);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue