Cleanup some includes
[alure.git] / src / buffer.h
blob4e398a25ea83b656b472e0971ccc8eeff147678d
1 #ifndef BUFFER_H
2 #define BUFFER_H
4 #include <algorithm>
6 #include "main.h"
8 namespace alure {
10 ALenum GetFormat(ChannelConfig chans, SampleType type);
12 class BufferImpl {
13 ContextImpl *const mContext;
14 ALuint mId;
16 ALuint mFrequency;
17 ChannelConfig mChannelConfig;
18 SampleType mSampleType;
20 Vector<Source> mSources;
22 const String mName;
24 public:
25 BufferImpl(ContextImpl *context, ALuint id, ALuint freq, ChannelConfig config, SampleType type, StringView name)
26 : mContext(context), mId(id), mFrequency(freq), mChannelConfig(config), mSampleType(type)
27 , mName(String(name))
28 { }
30 void cleanup();
32 ContextImpl *getContext() { return mContext; }
33 ALuint getId() const { return mId; }
35 void addSource(Source source) { mSources.push_back(source); }
36 void removeSource(Source source)
38 auto iter = std::find(mSources.cbegin(), mSources.cend(), source);
39 if(iter != mSources.cend()) mSources.erase(iter);
42 void load(ALuint frames, ALenum format, SharedPtr<Decoder> decoder, ContextImpl *ctx);
44 ALuint getLength() const;
46 ALuint getFrequency() const { return mFrequency; }
47 ChannelConfig getChannelConfig() const { return mChannelConfig; }
48 SampleType getSampleType() const { return mSampleType; }
50 ALuint getSize() const;
52 void setLoopPoints(ALuint start, ALuint end);
53 std::pair<ALuint,ALuint> getLoopPoints() const;
55 Vector<Source> getSources() const { return mSources; }
57 StringView getName() const { return mName; }
59 bool isInUse() const { return (mSources.size() > 0); }
62 } // namespace alure
64 #endif /* BUFFER_H */