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
17 #include "fx/MutableReader.h"
18
19 #include <cstring>
20
21 AUD_NAMESPACE_BEGIN
22
MutableReader(std::shared_ptr<ISound> sound)23 MutableReader::MutableReader(std::shared_ptr<ISound> sound) :
24 m_sound(sound)
25 {
26 m_reader = m_sound->createReader();
27 }
28
isSeekable() const29 bool MutableReader::isSeekable() const
30 {
31 return m_reader->isSeekable();
32 }
33
seek(int position)34 void MutableReader::seek(int position)
35 {
36 if(position < m_reader->getPosition())
37 {
38 m_reader = m_sound->createReader();
39 }
40 else
41 m_reader->seek(position);
42 }
43
getLength() const44 int MutableReader::getLength() const
45 {
46 return m_reader->getLength();
47 }
48
getPosition() const49 int MutableReader::getPosition() const
50 {
51 return m_reader->getPosition();
52 }
53
getSpecs() const54 Specs MutableReader::getSpecs() const
55 {
56 return m_reader->getSpecs();
57 }
58
read(int & length,bool & eos,sample_t * buffer)59 void MutableReader::read(int& length, bool& eos, sample_t* buffer)
60 {
61 m_reader->read(length, eos, buffer);
62 }
63
64 AUD_NAMESPACE_END
65