Merge pull request #40 from McSinyx/travis
[alure.git] / src / sourcegroup.h
blobec8ace2a556a0bc65f9b15cd1f4c64e81a0416e0
1 #ifndef SOURCEGROUP_H
2 #define SOURCEGROUP_H
4 #include "main.h"
7 namespace alure
10 struct SourceGroupProps {
11 ALfloat mGain;
12 ALfloat mPitch;
14 SourceGroupProps() : mGain(1.0f), mPitch(1.0f) { }
17 class SourceGroupImpl : SourceGroupProps {
18 ContextImpl &mContext;
20 Vector<SourceImpl*> mSources;
21 Vector<SourceGroupImpl*> mSubGroups;
23 SourceGroupProps mParentProps;
24 SourceGroupImpl *mParent;
26 void update(ALfloat gain, ALfloat pitch);
28 void unsetParent();
30 void insertSubGroup(SourceGroupImpl *group);
31 void eraseSubGroup(SourceGroupImpl *group);
33 bool findInSubGroups(SourceGroupImpl *group) const;
35 void collectPlayingSourceIds(Vector<ALuint> &sourceids) const;
36 void updatePausedStatus() const;
38 void collectPausedSourceIds(Vector<ALuint> &sourceids) const;
39 void updatePlayingStatus() const;
41 void collectSourceIds(Vector<ALuint> &sourceids) const;
42 void updateStoppedStatus() const;
44 public:
45 SourceGroupImpl(ContextImpl &context) : mContext(context), mParent(nullptr) { }
47 ALfloat getAppliedGain() const { return mGain * mParentProps.mGain; }
48 ALfloat getAppliedPitch() const { return mPitch * mParentProps.mPitch; }
50 void insertSource(SourceImpl *source);
51 void eraseSource(SourceImpl *source);
53 void setParentGroup(SourceGroup group);
54 SourceGroup getParentGroup() const { return SourceGroup(mParent); }
56 Vector<Source> getSources() const;
58 Vector<SourceGroup> getSubGroups() const;
60 void setGain(ALfloat gain);
61 ALfloat getGain() const { return mGain; }
63 void setPitch(ALfloat pitch);
64 ALfloat getPitch() const { return mPitch; }
66 void pauseAll() const;
67 void resumeAll() const;
69 void stopAll() const;
71 void destroy();
74 } // namespace alure2
76 #endif /* SOURCEGROUP_H */