mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-16 18:49:58 +00:00
Added more capabilities to Audiere sources
This commit is contained in:
parent
d60f0fa900
commit
d22bea5eab
3 changed files with 22 additions and 10 deletions
|
@ -33,7 +33,8 @@ class SampleSource : public Stream::Stream
|
|||
|
||||
bool eof() const { return isEof; }
|
||||
|
||||
// Disabled functions
|
||||
// Disabled functions by default. You can still override them in
|
||||
// subclasses.
|
||||
void seek(size_t pos) const { assert(0); }
|
||||
size_t tell() const { assert(0); }
|
||||
size_t size() const { assert(0); }
|
||||
|
|
|
@ -28,11 +28,14 @@ void AudiereSource::getInfo(int32_t *rate, int32_t *channels, int32_t *bits)
|
|||
{
|
||||
SampleFormat fmt;
|
||||
sample->getFormat(*channels, *rate, fmt);
|
||||
if(fmt == SF_U8)
|
||||
*bits = 8;
|
||||
else if(fmt == SF_S16)
|
||||
*bits = 16;
|
||||
else assert(0);
|
||||
if(bits)
|
||||
{
|
||||
if(fmt == SF_U8)
|
||||
*bits = 8;
|
||||
else if(fmt == SF_S16)
|
||||
*bits = 16;
|
||||
else assert(0);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -103,7 +106,7 @@ AudiereSource::AudiereSource(const std::string &file)
|
|||
if(!sample)
|
||||
fail("Couldn't load file " + file);
|
||||
|
||||
getFormat();
|
||||
setup();
|
||||
}
|
||||
|
||||
AudiereSource::AudiereSource(Stream::Stream *input)
|
||||
|
@ -114,15 +117,15 @@ AudiereSource::AudiereSource(Stream::Stream *input)
|
|||
if(!sample)
|
||||
fail("Couldn't load stream");
|
||||
|
||||
getFormat();
|
||||
setup();
|
||||
}
|
||||
|
||||
AudiereSource::AudiereSource(audiere::SampleSourcePtr src)
|
||||
: sample(src)
|
||||
{ assert(sample); getFormat(); }
|
||||
{ assert(sample); setup(); }
|
||||
|
||||
// Common function called from all constructors
|
||||
AudiereSource::getFormat()
|
||||
AudiereSource::setup()
|
||||
{
|
||||
assert(sample);
|
||||
|
||||
|
@ -136,4 +139,8 @@ AudiereSource::getFormat()
|
|||
// Make sure that our pullover hack will work. Increase this size if
|
||||
// this doesn't work in all cases.
|
||||
assert(frameSize <= PSIZE);
|
||||
|
||||
isSeekable = sample->isSeekable();
|
||||
hasPosition = true;
|
||||
hasSize = true;
|
||||
}
|
||||
|
|
|
@ -40,6 +40,10 @@ class AudiereSource : public SampleSource
|
|||
|
||||
void getInfo(int32_t *rate, int32_t *channels, int32_t *bits);
|
||||
size_t read(void *data, size_t length);
|
||||
|
||||
void seek(size_t pos) const { sample->setPosition(pos); }
|
||||
size_t tell() const { return sample->getPosition(); }
|
||||
size_t size() const { return sample->getLength(); }
|
||||
};
|
||||
|
||||
#include "loadertemplate.h"
|
||||
|
|
Loading…
Reference in a new issue