16 ALenum
GetFormat(ChannelConfig chans
, SampleType type
);
19 ContextImpl
*const mContext
;
23 ChannelConfig mChannelConfig
;
24 SampleType mSampleType
;
26 BufferLoadStatus mLoadStatus
;
27 std::atomic
<bool> mIsLoaded
;
29 Vector
<Source
> mSources
;
34 BufferImpl(ContextImpl
*context
, ALuint id
, ALuint freq
, ChannelConfig config
, SampleType type
, bool preloaded
, const String
&name
)
35 : mContext(context
), mId(id
), mFrequency(freq
), mChannelConfig(config
), mSampleType(type
),
36 mLoadStatus(preloaded
? BufferLoadStatus::Ready
: BufferLoadStatus::Pending
),
37 mIsLoaded(preloaded
), mName(name
)
42 ContextImpl
*getContext() { return mContext
; }
43 ALuint
getId() const { return mId
; }
45 void addSource(Source source
) { mSources
.push_back(source
); }
46 void removeSource(Source source
)
48 auto iter
= std::find(mSources
.cbegin(), mSources
.cend(), source
);
49 if(iter
!= mSources
.cend()) mSources
.erase(iter
);
52 void load(ALuint frames
, ALenum format
, SharedPtr
<Decoder
> decoder
, const String
&name
, ContextImpl
*ctx
);
54 bool isReady() const { return mLoadStatus
== BufferLoadStatus::Ready
; }
56 ALuint
getLength() const;
58 ALuint
getFrequency() const { return mFrequency
; }
59 ChannelConfig
getChannelConfig() const { return mChannelConfig
; }
60 SampleType
getSampleType() const { return mSampleType
; }
62 ALuint
getSize() const;
64 void setLoopPoints(ALuint start
, ALuint end
);
65 std::pair
<ALuint
,ALuint
> getLoopPoints() const;
67 Vector
<Source
> getSources() const { return mSources
; }
69 BufferLoadStatus
getLoadStatus();
71 const String
&getName() const { return mName
; }
73 bool isInUse() const { return (mSources
.size() > 0); }