MutableReader.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*******************************************************************************
  2. * Copyright 2015-2016 Juan Francisco Crespo Galán
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. ******************************************************************************/
  16. #pragma once
  17. /**
  18. * @file MutableReader.h
  19. * @ingroup fx
  20. * The MutableReader class.
  21. */
  22. #include "IReader.h"
  23. #include "ISound.h"
  24. #include <memory>
  25. AUD_NAMESPACE_BEGIN
  26. /**
  27. * This class represents a reader for a sound that can change with each playback. The change will occur when trying to seek backwards
  28. * If the sound doesn't support that, it will be restarted.
  29. * \warning Notice that if a SoundList object is assigned to several MutableReaders, sequential playback won't work correctly.
  30. * To prevent this the SoundList must be copied.
  31. */
  32. class AUD_API MutableReader : public IReader
  33. {
  34. private:
  35. /**
  36. * The current reader.
  37. */
  38. std::shared_ptr<IReader> m_reader;
  39. /**
  40. * A sound from which to get the reader.
  41. */
  42. std::shared_ptr<ISound> m_sound;
  43. // delete copy constructor and operator=
  44. MutableReader(const MutableReader&) = delete;
  45. MutableReader& operator=(const MutableReader&) = delete;
  46. public:
  47. /**
  48. * Creates a new mutable reader.
  49. * \param sound A of sound you want to assign to this reader.
  50. */
  51. MutableReader(std::shared_ptr<ISound> sound);
  52. virtual bool isSeekable() const;
  53. virtual void seek(int position);
  54. virtual int getLength() const;
  55. virtual int getPosition() const;
  56. virtual Specs getSpecs() const;
  57. virtual void read(int& length, bool& eos, sample_t* buffer);
  58. };
  59. AUD_NAMESPACE_END