BsOAFLACReader.h 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #pragma once
  4. #include "BsOAPrerequisites.h"
  5. #include "FLAC\stream_decoder.h"
  6. namespace BansheeEngine
  7. {
  8. /** @addtogroup OpenAudio
  9. * @{
  10. */
  11. struct FLACDecoderData
  12. {
  13. SPtr<DataStream> stream;
  14. AudioFileInfo info;
  15. UINT8* output = nullptr;
  16. Vector<UINT8> overflow;
  17. UINT32 overflowBytesPerSample = 0;
  18. UINT32 samplesToRead = 0;
  19. bool error = false;
  20. };
  21. /** Used for reading FLAC audio files. */
  22. class OAFLACReader
  23. {
  24. public:
  25. OAFLACReader();
  26. ~OAFLACReader();
  27. bool open(const SPtr<DataStream>& stream, AudioFileInfo& info);
  28. void seek(UINT32 offset); // Offset in number of samples
  29. UINT32 read(UINT8* samples, UINT32 numSamples);
  30. static bool isValid(const SPtr<DataStream>& stream);
  31. private:
  32. void close();
  33. FLAC__StreamDecoder* mDecoder;
  34. FLACDecoderData mData;
  35. };
  36. /** @} */
  37. }