1 /*
2 Copyright (C) 2005 The Pentagram team
3 Copyright (C) 2010-2013 The Exult Team
4
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 */
19
20 #include "pent_include.h"
21 #include "AudioSample.h"
22 #include "OggAudioSample.h"
23 #include "WavAudioSample.h"
24 #include "VocAudioSample.h"
25
26 namespace Pentagram {
27
AudioSample(std::unique_ptr<uint8[]> buffer_,uint32 size_)28 AudioSample::AudioSample(std::unique_ptr<uint8[]> buffer_, uint32 size_) :
29 bits(0), frame_size(0), decompressor_size(0), decompressor_align(0),
30 length(0), buffer_size(size_), buffer(std::move(buffer_)), refcount(1),
31 sample_rate(0), stereo(false)
32 {
33 }
createAudioSample(std::unique_ptr<uint8[]> data,uint32 size)34 AudioSample *AudioSample::createAudioSample(std::unique_ptr<uint8[]> data, uint32 size)
35 {
36 IBufferDataView ds(data, size);
37
38 if (VocAudioSample::isThis(&ds))
39 {
40 return new VocAudioSample(std::move(data), size);
41 }
42 else if (WavAudioSample::isThis(&ds))
43 {
44 return new WavAudioSample(std::move(data), size);
45 }
46 else if (OggAudioSample::isThis(&ds))
47 {
48 return new OggAudioSample(std::move(data), size);
49 }
50 return nullptr;
51 }
52
53 }
54