6 #include <unordered_map>
18 class AuxiliaryEffectSlotImpl
;
19 class SourceGroupImpl
;
22 AuxiliaryEffectSlotImpl
*mSlot
;
25 SendProps(AuxiliaryEffectSlotImpl
*slot
) : mSlot(slot
), mFilter(AL_FILTER_NULL
)
27 SendProps(ALuint filter
) : mSlot(0), mFilter(filter
)
29 SendProps(AuxiliaryEffectSlotImpl
*slot
, ALuint filter
) : mSlot(slot
), mFilter(filter
)
32 typedef std::unordered_map
<ALuint
,SendProps
> SendPropMap
;
35 ContextImpl
*const mContext
;
39 UniquePtr
<ALBufferStream
> mStream
;
41 SourceGroupImpl
*mGroup
;
43 mutable std::mutex mMutex
;
44 std::atomic
<bool> mIsAsync
;
46 std::atomic
<bool> mPaused
;
50 ALfloat mMinGain
, mMaxGain
;
51 ALfloat mRefDist
, mMaxDist
;
55 Vector3 mOrientation
[2];
56 ALfloat mConeInnerAngle
, mConeOuterAngle
;
57 ALfloat mConeOuterGain
, mConeOuterGainHF
;
58 ALfloat mRolloffFactor
, mRoomRolloffFactor
;
59 ALfloat mDopplerFactor
;
60 ALfloat mAirAbsorptionFactor
;
62 ALfloat mStereoAngles
[2];
63 Spatialize mSpatialize
;
67 bool mDryGainHFAuto
: 1;
68 bool mWetGainAuto
: 1;
69 bool mWetGainHFAuto
: 1;
72 SendPropMap mEffectSlots
;
76 void resetProperties();
77 void applyProperties(bool looping
, ALuint offset
) const;
79 ALint
refillBufferStream();
81 void setFilterParams(ALuint
&filterid
, const FilterParams
¶ms
);
84 SourceImpl(ContextImpl
*context
);
87 ALuint
getId() const { return mId
; }
89 bool playUpdate(ALuint id
);
93 void setGroup(SourceGroupImpl
*group
);
97 void groupPropUpdate(ALfloat gain
, ALfloat pitch
);
100 void unsetPaused() { mPaused
= false; }
101 void makeStopped(bool dolock
=true);
103 void play(Buffer buffer
);
104 void play(SharedPtr
<Decoder
> decoder
, ALuint updatelen
, ALuint queuesize
);
109 bool isPlaying() const;
110 bool isPaused() const;
112 void setPriority(ALuint priority
);
113 ALuint
getPriority() const { return mPriority
; }
115 void setOffset(uint64_t offset
);
116 std::pair
<uint64_t,std::chrono::nanoseconds
> getSampleOffsetLatency() const;
117 std::pair
<Seconds
,Seconds
> getSecOffsetLatency() const;
119 void setLooping(bool looping
);
120 bool getLooping() const { return mLooping
; }
122 void setPitch(ALfloat pitch
);
123 ALfloat
getPitch() const { return mPitch
; }
125 void setGain(ALfloat gain
);
126 ALfloat
getGain() const { return mGain
; }
128 void setGainRange(ALfloat mingain
, ALfloat maxgain
);
129 std::pair
<ALfloat
,ALfloat
> getGainRange() const
130 { return {mMinGain
, mMaxGain
}; }
132 void setDistanceRange(ALfloat refdist
, ALfloat maxdist
);
133 std::pair
<ALfloat
,ALfloat
> getDistanceRange() const
134 { return {mRefDist
, mMaxDist
}; }
136 void set3DParameters(const Vector3
&position
, const Vector3
&velocity
, const Vector3
&direction
);
137 void set3DParameters(const Vector3
&position
, const Vector3
&velocity
, std::pair
<Vector3
,Vector3
> orientation
);
139 void setPosition(ALfloat x
, ALfloat y
, ALfloat z
);
140 void setPosition(const ALfloat
*pos
);
141 Vector3
getPosition() const { return mPosition
; }
143 void setVelocity(ALfloat x
, ALfloat y
, ALfloat z
);
144 void setVelocity(const ALfloat
*vel
);
145 Vector3
getVelocity() const { return mVelocity
; }
147 void setDirection(ALfloat x
, ALfloat y
, ALfloat z
);
148 void setDirection(const ALfloat
*dir
);
149 Vector3
getDirection() const { return mDirection
; }
151 void setOrientation(ALfloat x1
, ALfloat y1
, ALfloat z1
, ALfloat x2
, ALfloat y2
, ALfloat z2
);
152 void setOrientation(const ALfloat
*at
, const ALfloat
*up
);
153 void setOrientation(const ALfloat
*ori
);
154 std::pair
<Vector3
,Vector3
> getOrientation() const
155 { return {mOrientation
[0], mOrientation
[1]}; }
157 void setConeAngles(ALfloat inner
, ALfloat outer
);
158 std::pair
<ALfloat
,ALfloat
> getConeAngles() const
159 { return {mConeInnerAngle
, mConeOuterAngle
}; }
161 void setOuterConeGains(ALfloat gain
, ALfloat gainhf
=1.0f
);
162 std::pair
<ALfloat
,ALfloat
> getOuterConeGains() const
163 { return {mConeOuterGain
, mConeOuterGainHF
}; }
165 void setRolloffFactors(ALfloat factor
, ALfloat roomfactor
=0.0f
);
166 std::pair
<ALfloat
,ALfloat
> getRolloffFactors() const
167 { return {mRolloffFactor
, mRoomRolloffFactor
}; }
169 void setDopplerFactor(ALfloat factor
);
170 ALfloat
getDopplerFactor() const { return mDopplerFactor
; }
172 void setRelative(bool relative
);
173 bool getRelative() const { return mRelative
; }
175 void setRadius(ALfloat radius
);
176 ALfloat
getRadius() const { return mRadius
; }
178 void setStereoAngles(ALfloat leftAngle
, ALfloat rightAngle
);
179 std::pair
<ALfloat
,ALfloat
> getStereoAngles() const
180 { return std::make_pair(mStereoAngles
[0], mStereoAngles
[1]); }
182 void set3DSpatialize(Spatialize spatialize
);
183 Spatialize
get3DSpatialize() const { return mSpatialize
; }
185 void setResamplerIndex(ALsizei index
);
186 ALsizei
getResamplerIndex() const { return mResampler
; }
188 void setAirAbsorptionFactor(ALfloat factor
);
189 ALfloat
getAirAbsorptionFactor() const { return mAirAbsorptionFactor
; }
191 void setGainAuto(bool directhf
, bool send
, bool sendhf
);
192 std::tuple
<bool,bool,bool> getGainAuto() const
193 { return std::make_tuple(mDryGainHFAuto
, mWetGainAuto
, mWetGainHFAuto
); }
195 void setDirectFilter(const FilterParams
&filter
);
196 void setSendFilter(ALuint send
, const FilterParams
&filter
);
197 void setAuxiliarySend(AuxiliaryEffectSlot slot
, ALuint send
);
198 void setAuxiliarySendFilter(AuxiliaryEffectSlot slot
, ALuint send
, const FilterParams
&filter
);
204 struct SourceBufferUpdateEntry
{
208 struct SourceStreamUpdateEntry
{
214 #endif /* SOURCE_H */