mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2025-12-11 22:17:17 +03:00
Bell catchup
This commit is contained in:
@@ -14,8 +14,8 @@ using namespace bell;
|
||||
EncodedAudioStream::EncodedAudioStream() {
|
||||
bell::decodersInstance->ensureAAC();
|
||||
bell::decodersInstance->ensureMP3();
|
||||
inputBuffer = std::vector<uint8_t>(AAC_READBUF_SIZE * 4);
|
||||
outputBuffer = std::vector<short>(AAC_MAX_NCHANS * AAC_MAX_NSAMPS * 4 * 4);
|
||||
inputBuffer = std::vector<uint8_t>(1024 * 4);
|
||||
outputBuffer = std::vector<short>(2 * 2 * 4 * 4);
|
||||
decodePtr = inputBuffer.data();
|
||||
}
|
||||
|
||||
@@ -115,46 +115,47 @@ bool EncodedAudioStream::isReadable() {
|
||||
}
|
||||
|
||||
size_t EncodedAudioStream::decodeFrameAAC(uint8_t* dst) {
|
||||
size_t writtenBytes = 0;
|
||||
auto bufSize = AAC_READBUF_SIZE;
|
||||
return 0;
|
||||
// size_t writtenBytes = 0;
|
||||
// auto bufSize = AAC_READBUF_SIZE;
|
||||
|
||||
int readBytes = innerStream->read(inputBuffer.data() + bytesInBuffer,
|
||||
bufSize - bytesInBuffer);
|
||||
if (readBytes > 0) {
|
||||
bytesInBuffer += readBytes;
|
||||
decodePtr = inputBuffer.data();
|
||||
offset = AACFindSyncWord(inputBuffer.data(), bytesInBuffer);
|
||||
// int readBytes = innerStream->read(inputBuffer.data() + bytesInBuffer,
|
||||
// bufSize - bytesInBuffer);
|
||||
// if (readBytes > 0) {
|
||||
// bytesInBuffer += readBytes;
|
||||
// decodePtr = inputBuffer.data();
|
||||
// offset = AACFindSyncWord(inputBuffer.data(), bytesInBuffer);
|
||||
|
||||
if (offset != -1) {
|
||||
bytesInBuffer -= offset;
|
||||
decodePtr += offset;
|
||||
// if (offset != -1) {
|
||||
// bytesInBuffer -= offset;
|
||||
// decodePtr += offset;
|
||||
|
||||
int decodeStatus =
|
||||
AACDecode(bell::decodersInstance->aacDecoder, &decodePtr,
|
||||
&bytesInBuffer, outputBuffer.data());
|
||||
AACGetLastFrameInfo(bell::decodersInstance->aacDecoder, &aacFrameInfo);
|
||||
if (decodeStatus == ERR_AAC_NONE) {
|
||||
decodedSampleRate = aacFrameInfo.sampRateOut;
|
||||
writtenBytes =
|
||||
(aacFrameInfo.bitsPerSample / 8) * aacFrameInfo.outputSamps;
|
||||
// int decodeStatus =
|
||||
// AACDecode(bell::decodersInstance->aacDecoder, &decodePtr,
|
||||
// &bytesInBuffer, outputBuffer.data());
|
||||
// AACGetLastFrameInfo(bell::decodersInstance->aacDecoder, &aacFrameInfo);
|
||||
// if (decodeStatus == ERR_AAC_NONE) {
|
||||
// decodedSampleRate = aacFrameInfo.sampRateOut;
|
||||
// writtenBytes =
|
||||
// (aacFrameInfo.bitsPerSample / 8) * aacFrameInfo.outputSamps;
|
||||
|
||||
memcpy(dst, outputBuffer.data(), writtenBytes);
|
||||
// memcpy(dst, outputBuffer.data(), writtenBytes);
|
||||
|
||||
} else {
|
||||
BELL_LOG(info, TAG, "Error in frame, moving two bytes %d",
|
||||
decodeStatus);
|
||||
decodePtr += 1;
|
||||
bytesInBuffer -= 1;
|
||||
}
|
||||
} else {
|
||||
BELL_LOG(info, TAG, "Unexpected error in data, skipping a word");
|
||||
decodePtr += 3800;
|
||||
bytesInBuffer -= 3800;
|
||||
}
|
||||
// } else {
|
||||
// BELL_LOG(info, TAG, "Error in frame, moving two bytes %d",
|
||||
// decodeStatus);
|
||||
// decodePtr += 1;
|
||||
// bytesInBuffer -= 1;
|
||||
// }
|
||||
// } else {
|
||||
// BELL_LOG(info, TAG, "Unexpected error in data, skipping a word");
|
||||
// decodePtr += 3800;
|
||||
// bytesInBuffer -= 3800;
|
||||
// }
|
||||
|
||||
memmove(inputBuffer.data(), decodePtr, bytesInBuffer);
|
||||
}
|
||||
return writtenBytes;
|
||||
// memmove(inputBuffer.data(), decodePtr, bytesInBuffer);
|
||||
// }
|
||||
// return writtenBytes;
|
||||
}
|
||||
|
||||
void EncodedAudioStream::guessDataFormat() {
|
||||
|
||||
Reference in New Issue
Block a user