43 IResource(createUniqueClipName(), loader),
46 m_deletedecoder(false) {
54 m_deletedecoder(false) {
63 if(
m_name.find(
".ogg",
m_name.size() - 4) != std::string::npos) {
67 FL_WARN(_log,
LMsg() <<
"No audio-decoder available for file \"" <<
m_name <<
"\"!");
68 throw InvalidFormat(
"Error: Ogg loader can't load files without ogg extension");
90 alGenBuffers(1, &ptr->
buffers[i]);
114 std::vector<SoundBufferEntry*>::iterator it;
117 if ((*it)->buffers[0] != 0) {
129 alDeleteBuffers(1, &ptr->
buffers[i]);
155 pos =
static_cast<uint64_t
>(value);
175 uint64_t pos =
m_buffervec.at(streamid)->deccursor;
210 throw Exception(
"error while reading from audio file");
246 static std::string baseName =
"soundclip";
248 std::ostringstream oss;
249 oss << uniqueNumber <<
"_" << baseName;
251 const std::string name = oss.str();
#define FL_WARN(logger, msg)
const uint32_t BUFFER_LEN
bool getStream(uint32_t streamid, ALuint buffer)
Refill a processed buffer with new data.
ALuint buffers[BUFFER_NUM]
Helper class to create log strings out from separate parts Usage: LMsg("some text") << variable << "...
virtual void releaseBuffer()=0
Releases the buffer returned by getBuffer()
bool isStereo() const
Tests if the audio data is stereo data or mono.
IResourceLoader * m_loader
static Logger _log(LM_AUDIO)
#define CHECK_OPENAL_LOG(logger, level, msg)
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.
virtual bool decode(uint64_t length)=0
Request the decoding of the next part of the stream.
bool needsStreaming() const
A stream or not?
void acquireStream(uint32_t streamid)
Fills the streaming-buffers with initial data.
SoundPositionType
Different types of audio-file positions.
virtual uint64_t getDecodedLength() const =0
Returns the decoded length of the file in bytes.
std::string createUniqueClipName()
int16_t getBitResolution() const
Returns the bit resolution.
float getStreamPos(uint32_t streamid, SoundPositionType type) const
Gets the stream position.
virtual bool setCursor(uint64_t pos)=0
Sets the current position in the file (in bytes)
uint64_t getSampleRate() const
Returns the sample rate.
std::vector< SoundBufferEntry * > m_buffervec
void quitStreaming(uint32_t streamid)
Quits Streaming.
virtual void load(IResource *res)
SoundClip(IResourceLoader *loader=0)
virtual void load(IResource *resource)=0
Create a Logger instance to communicate with LogManager Logger stores information about the current m...
bool setStreamPos(uint32_t streamid, SoundPositionType type, float value)
Sets the stream position.
uint32_t beginStreaming()
Starts streaming the soundclip.
ALenum getALFormat() const
Returns the openAL-Format of the audio file.