43 IResource(createUniqueClipName(), loader),
46 m_deleteDecoder(false) {
72 if(
m_name.find(
".ogg",
m_name.size() - 4) != std::string::npos) {
77 throw InvalidFormat(
"Error: Ogg loader can't load files without ogg extension");
98 alGenBuffers(1, &ptr->
buffers[i]);
122 std::vector<SoundBufferEntry*>::iterator it;
124 if ((*it) && (*it)->buffers[0] != 0) {
133 alDeleteBuffers(1, &ptr->
buffers[i]);
186 pos =
static_cast<uint64_t
>(value);
207 uint64_t pos =
m_buffervec.at(streamid)->deccursor;
243 throw Exception(
"error while reading from audio file");
294 static std::string baseName =
"soundclip";
296 std::ostringstream oss;
297 oss << uniqueNumber <<
"_" << baseName;
299 const std::string name = oss.str();
#define FL_WARN(logger, msg)
const uint32_t BUFFER_LEN
bool needsStreaming() const
A stream or not?
bool getStream(uint32_t streamid, ALuint buffer)
Refill a processed buffer with new data.
void endStreaming(uint32_t streamid)
Ends streaming, invalidate also the stream id.
ALuint buffers[BUFFER_NUM]
float getStreamPos(uint32_t streamid, SoundPositionType type) const
Gets the stream position.
Helper class to create log strings out from separate parts Usage: LMsg("some text") << variable << "...
uint64_t getSampleRate() const
Returns the sample rate.
virtual void releaseBuffer()=0
Releases the buffer returned by getBuffer()
IResourceLoader * m_loader
static Logger _log(LM_AUDIO)
#define CHECK_OPENAL_LOG(logger, level, msg)
SoundDecoder * getDecoder() const
Returns the attached decoder.
virtual uint64_t getBufferSize()=0
Returns the byte-size of the buffer returned by getBuffer().
virtual void * getBuffer() const =0
Returns the next decoded buffer.
void adobtDecoder(SoundDecoder *decoder)
Adopts a decoder to use so DONT delete it.
virtual bool decode(uint64_t length)=0
Request the decoding of the next part of the stream.
void acquireStream(uint32_t streamid)
Fills the streaming-buffers with initial data.
SoundPositionType
Different types of audio-file positions.
uint32_t countBuffers() const
Returns the number of buffers used by the SoundClip (only for non-streaming sound clips) ...
bool isStereo() const
Tests if the audio data is stereo data or mono.
virtual uint64_t getDecodedLength() const =0
Returns the decoded length of the file in bytes.
std::string createUniqueClipName()
bool isStream() const
Does this SoundClip require a streaming mechanism?
virtual bool setCursor(uint64_t pos)=0
Sets the current position in the file (in bytes)
std::vector< SoundBufferEntry * > m_buffervec
void setDecoder(SoundDecoder *decoder)
Sets the decoder to use so DONT delete it before this SoundClip is done with it.
void quitStreaming(uint32_t streamid)
Quits Streaming.
ALuint * getBuffers(uint32_t streamid=0) const
Returns the array of buffers for queuing.
int16_t getBitResolution() const
Returns the bit resolution.
ALenum getALFormat() const
Returns the openAL-Format of the audio file.
virtual void load(IResource *res)
SoundClip(IResourceLoader *loader=0)
virtual void load(IResource *resource)=0
bool setStreamPos(uint32_t streamid, SoundPositionType type, float value)
Sets the stream position.
uint32_t beginStreaming()
Starts streaming the soundclip.