BsOggVorbisDecoder.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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 "BsAudioDecoder.h"
  6. #include "vorbis\vorbisfile.h"
  7. namespace bs
  8. {
  9. /** @addtogroup OpenAudio
  10. * @{
  11. */
  12. /** Information used by the active decoder. */
  13. struct OggDecoderData
  14. {
  15. OggDecoderData()
  16. : offset(0)
  17. { }
  18. SPtr<DataStream> stream;
  19. UINT32 offset;
  20. };
  21. /** Used for reading Ogg Vorbis audio data. */
  22. class OggVorbisDecoder : public AudioDecoder
  23. {
  24. public:
  25. OggVorbisDecoder();
  26. ~OggVorbisDecoder();
  27. /** @copydoc AudioDecoder::open */
  28. bool open(const SPtr<DataStream>& stream, AudioDataInfo& info, UINT32 offset = 0) override;
  29. /** @copydoc AudioDecoder::read */
  30. UINT32 read(UINT8* samples, UINT32 numSamples) override;
  31. /** @copydoc AudioDecoder::seek */
  32. void seek(UINT32 offset) override;
  33. /** @copydoc AudioDecoder::isValid */
  34. bool isValid(const SPtr<DataStream>& stream, UINT32 offset = 0) override;
  35. private:
  36. OggDecoderData mDecoderData;
  37. OggVorbis_File mOggVorbisFile;
  38. UINT32 mChannelCount;
  39. };
  40. /** @} */
  41. }