DoubleReader.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*******************************************************************************
  2. * Copyright 2009-2016 Jörg Müller
  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 DoubleReader.h
  19. * @ingroup sequence
  20. * The DoubleReader class.
  21. */
  22. #include "IReader.h"
  23. #include <memory>
  24. AUD_NAMESPACE_BEGIN
  25. /**
  26. * This reader plays two readers sequently.
  27. */
  28. class AUD_API DoubleReader : public IReader
  29. {
  30. private:
  31. /**
  32. * The first reader.
  33. */
  34. std::shared_ptr<IReader> m_reader1;
  35. /**
  36. * The second reader.
  37. */
  38. std::shared_ptr<IReader> m_reader2;
  39. /**
  40. * Whether we've reached the end of the first reader.
  41. */
  42. bool m_finished1;
  43. // delete copy constructor and operator=
  44. DoubleReader(const DoubleReader&) = delete;
  45. DoubleReader& operator=(const DoubleReader&) = delete;
  46. public:
  47. /**
  48. * Creates a new double reader.
  49. * \param reader1 The first reader to read from.
  50. * \param reader2 The second reader to read from.
  51. */
  52. DoubleReader(std::shared_ptr<IReader> reader1, std::shared_ptr<IReader> reader2);
  53. /**
  54. * Destroys the reader.
  55. */
  56. virtual ~DoubleReader();
  57. virtual bool isSeekable() const;
  58. virtual void seek(int position);
  59. virtual int getLength() const;
  60. virtual int getPosition() const;
  61. virtual Specs getSpecs() const;
  62. virtual void read(int& length, bool& eos, sample_t* buffer);
  63. };
  64. AUD_NAMESPACE_END