ModPlugDecoder.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. static int probe(Stream *stream);
  45. love::sound::Decoder *clone() override;
  46. int decode() override;
  47. bool seek(double s) override;
  48. bool rewind() override;
  49. bool isSeekable() override;
  50. int getChannelCount() const override;
  51. int getBitDepth() const override;
  52. double getDuration() override;
  53. private:
  54. StrongRef<Data> data;
  55. ModPlugFile *plug;
  56. ModPlug_Settings settings;
  57. double duration;
  58. }; // ModPlugDecoder
  59. } // lullaby
  60. } // sound
  61. } // love
  62. #endif // LOVE_NO_MODPLUG
  63. #endif // LOVE_SOUND_LULLABY_MODPLUG_DECODER_H