BaseCodec.cpp 609 B

12345678910111213141516171819202122232425262728
  1. #include "BaseCodec.h"
  2. #include "AudioContainer.h" // for AudioContainer
  3. using namespace bell;
  4. bool BaseCodec::setup(AudioContainer* container) {
  5. return false;
  6. }
  7. uint8_t* BaseCodec::decode(AudioContainer* container, uint32_t& outLen) {
  8. auto* data = container->readSample(lastSampleLen);
  9. if (data == nullptr) {
  10. outLen = 0;
  11. return nullptr;
  12. }
  13. if (lastSampleLen == 0) {
  14. outLen = 0;
  15. return nullptr;
  16. }
  17. availableBytes = lastSampleLen;
  18. auto* result = decode((uint8_t*)data, availableBytes, outLen);
  19. container->consumeBytes(lastSampleLen - availableBytes);
  20. return result;
  21. }