VolumeReader.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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 VolumeReader.h
  19. * @ingroup fx
  20. * The VolumeReader class.
  21. */
  22. #include "IReader.h"
  23. #include "ISound.h"
  24. #include "VolumeStorage.h"
  25. #include <memory>
  26. AUD_NAMESPACE_BEGIN
  27. /**
  28. * This class represents a reader for a sound that has its own shared volume
  29. */
  30. class AUD_API VolumeReader : public IReader
  31. {
  32. private:
  33. /**
  34. * The current reader.
  35. */
  36. std::shared_ptr<IReader> m_reader;
  37. /**
  38. * A sound from which to get the reader.
  39. */
  40. std::shared_ptr<VolumeStorage> m_volumeStorage;
  41. // delete copy constructor and operator=
  42. VolumeReader(const VolumeReader&) = delete;
  43. VolumeReader& operator=(const VolumeReader&) = delete;
  44. public:
  45. /**
  46. * Creates a new volume reader.
  47. * \param reader A reader of the sound to be assigned to this reader.
  48. * \param volumeStorage A shared pointer to a VolumeStorage object.
  49. */
  50. VolumeReader(std::shared_ptr<IReader> reader, std::shared_ptr<VolumeStorage> volumeStorage);
  51. virtual bool isSeekable() const;
  52. virtual void seek(int position);
  53. virtual int getLength() const;
  54. virtual int getPosition() const;
  55. virtual Specs getSpecs() const;
  56. virtual void read(int& length, bool& eos, sample_t* buffer);
  57. };
  58. AUD_NAMESPACE_END