mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2026-01-28 13:20:49 +03:00
move to new cspot
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
#include "MP3Decoder.h"
|
||||
|
||||
using namespace bell;
|
||||
|
||||
MP3Decoder::MP3Decoder() {
|
||||
mp3 = MP3InitDecoder();
|
||||
pcmData =
|
||||
(int16_t*)malloc(MAX_NSAMP * MAX_NGRAN * MAX_NCHAN * sizeof(int16_t));
|
||||
}
|
||||
|
||||
MP3Decoder::~MP3Decoder() {
|
||||
MP3FreeDecoder(mp3);
|
||||
free(pcmData);
|
||||
}
|
||||
|
||||
bool MP3Decoder::setup(uint32_t sampleRate, uint8_t channelCount,
|
||||
uint8_t bitDepth) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MP3Decoder::setup(AudioContainer* container) {
|
||||
return true;
|
||||
}
|
||||
|
||||
uint8_t* MP3Decoder::decode(uint8_t* inData, uint32_t& inLen,
|
||||
uint32_t& outLen) {
|
||||
if (!inData || inLen == 0)
|
||||
return nullptr;
|
||||
int status = MP3Decode(mp3, static_cast<unsigned char**>(&inData),
|
||||
reinterpret_cast<int*>(&inLen),
|
||||
static_cast<short*>(this->pcmData),
|
||||
/* useSize */ 0);
|
||||
MP3GetLastFrameInfo(mp3, &frame);
|
||||
if (status != ERR_MP3_NONE) {
|
||||
lastErrno = status;
|
||||
return nullptr;
|
||||
}
|
||||
if (sampleRate != frame.samprate) {
|
||||
this->sampleRate = frame.samprate;
|
||||
}
|
||||
|
||||
if (channelCount != frame.nChans) {
|
||||
this->channelCount = frame.nChans;
|
||||
}
|
||||
outLen = frame.outputSamps * sizeof(int16_t);
|
||||
return (uint8_t*)pcmData;
|
||||
}
|
||||
Reference in New Issue
Block a user