BsOAFileReader.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. namespace BansheeEngine
  6. {
  7. /** @addtogroup OpenAudio
  8. * @{
  9. */
  10. /** Interface used for implementations that parse audio formats into a set of samples. */
  11. class OAFileReader
  12. {
  13. public:
  14. virtual ~OAFileReader() { }
  15. /**
  16. * Attempts to open audio data from the provided stream. Must be called before any reads or seeks.
  17. *
  18. * @param[in] stream Data stream audio data is stored in.
  19. * @param[out] info Output information describing meta-data of the audio in the stream.
  20. * @return True if the data is valid, false otherwise.
  21. */
  22. virtual bool open(const SPtr<DataStream>& stream, AudioFileInfo& info) = 0;
  23. /**
  24. * Moves the read pointer to the specified offset. Any further read() calls will read from this location. User must
  25. * ensure not to seek past the end of the data.
  26. *
  27. * @param[in] offset Offset to move the pointer in. In number of samples.
  28. */
  29. virtual void seek(UINT32 offset) = 0;
  30. /**
  31. * Reads a set of samples from the audio data.
  32. *
  33. * @param[out] samples Pre-allocated buffer to store the samples in.
  34. * @param[in] numSamples Number of samples to read.
  35. * @return Number of samples that were actually read (can be less than requested if the more data
  36. * in the stream).
  37. */
  38. virtual UINT32 read(UINT8* samples, UINT32 numSamples) = 0;
  39. /**
  40. * Checks if the data in the provided stream valid audio data for the current format. You should check this before
  41. * calling open().
  42. */
  43. virtual bool isValid(const SPtr<DataStream>& stream) = 0;
  44. };
  45. /** @} */
  46. }