ModPlugDecoder.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /**
  2. * Copyright (c) 2006-2022 LOVE Development Team
  3. *
  4. * This software is provided 'as-is', without any express or implied
  5. * warranty. In no event will the authors be held liable for any damages
  6. * arising from the use of this software.
  7. *
  8. * Permission is granted to anyone to use this software for any purpose,
  9. * including commercial applications, and to alter it and redistribute it
  10. * freely, subject to the following restrictions:
  11. *
  12. * 1. The origin of this software must not be misrepresented; you must not
  13. * claim that you wrote the original software. If you use this software
  14. * in a product, an acknowledgment in the product documentation would be
  15. * appreciated but is not required.
  16. * 2. Altered source versions must be plainly marked as such, and must not be
  17. * misrepresented as being the original software.
  18. * 3. This notice may not be removed or altered from any source distribution.
  19. **/
  20. #ifndef LOVE_SOUND_LULLABY_MODPLUG_DECODER_H
  21. #define LOVE_SOUND_LULLABY_MODPLUG_DECODER_H
  22. #include "common/config.h"
  23. #ifndef LOVE_NO_MODPLUG
  24. // LOVE
  25. #include "common/Stream.h"
  26. #include "sound/Decoder.h"
  27. // libmodplug
  28. #if defined(LOVE_ANDROID) || defined(LOVE_IOS)
  29. #include <modplug.h>
  30. #else
  31. #include <libmodplug/modplug.h>
  32. #endif
  33. namespace love
  34. {
  35. namespace sound
  36. {
  37. namespace lullaby
  38. {
  39. class ModPlugDecoder : public Decoder
  40. {
  41. public:
  42. ModPlugDecoder(Stream *stream, int bufferSize);
  43. virtual ~ModPlugDecoder();
  44. love::sound::Decoder *clone() override;
  45. int decode() override;
  46. bool seek(double s) override;
  47. bool rewind() override;
  48. bool isSeekable() override;
  49. int getChannelCount() const override;
  50. int getBitDepth() const override;
  51. double getDuration() override;
  52. private:
  53. StrongRef<Data> data;
  54. ModPlugFile *plug;
  55. ModPlug_Settings settings;
  56. double duration;
  57. }; // ModPlugDecoder
  58. } // lullaby
  59. } // sound
  60. } // love
  61. #endif // LOVE_NO_MODPLUG
  62. #endif // LOVE_SOUND_LULLABY_MODPLUG_DECODER_H