Added audiere File client. NOT TESTED.

actorid
Nicolay Korslund 15 years ago
parent 721f3b139b
commit 985e3847e0

@ -0,0 +1,39 @@
#include "audiere_file.h"
using namespace audiere;
using namespace Mangle::Stream;
bool AudiereFile::seek(int pos, SeekMode mode)
{
assert(inp->isSeekable);
assert(inp->hasPosition);
if(mode == BEGIN)
{
// Absolute position
inp->seek(pos);
return inp->tell() == pos;
}
if(mode == CURRENT)
{
// Current position
int cpos = inp->tell();
// Seek to a elative position
inp->seek(cpos + pos);
return inp->tell() == (pos+cpos);
}
if(mode == END)
{
// Seeking from the end. This requires that we're able to get
// the entire size of the file. The pos also has to be
// non-positive.
assert(inp->hasSize);
assert(pos <= 0);
size_t epos = inp->size();
inp->seek(epos + pos);
return inp->tell() == (epos+pos);
}
assert(0 && "invalid seek mode");
}

@ -0,0 +1,35 @@
#ifndef MANGLE_STREAM_AUDIERECLIENT_H
#define MANGLE_STREAM_AUDIERECLIENT_H
#include <audiere.h>
#include <assert.h>
#include "iwrapper.h"
namespace Mangle {
namespace Stream {
/** @brief An Audiere::File that wraps a Mangle::Stream input.
This lets Audiere read sound files from any generic archive or
file manager that supports Mangle streams.
*/
class AudiereFile : public audiere::File, _IWrapper
{
public:
AudiereFile(InputStream *inp, bool autoDel=false)
: _IWrapper(inp, autoDel) {}
/// Read 'count' bytes, return bytes successfully read
int read(void *buf, int count)
{ return inp->read(buf,count); }
/// Seek, relative to specified seek mode. Returns true if successful.
bool seek(int pos, audiere::SeekMode mode);
/// Get current position
int tell()
{ assert(inp->hasPosition); return inp->tell(); }
};
}} // namespaces
#endif
Loading…
Cancel
Save