2009-12-22 12:22:32 +00:00
|
|
|
#include "audiere_file.h"
|
|
|
|
|
|
|
|
using namespace audiere;
|
|
|
|
using namespace Mangle::Stream;
|
|
|
|
|
|
|
|
bool AudiereFile::seek(int pos, SeekMode mode)
|
|
|
|
{
|
|
|
|
assert(inp->isSeekable);
|
|
|
|
assert(inp->hasPosition);
|
|
|
|
|
2009-12-26 09:52:10 +00:00
|
|
|
int newPos;
|
2009-12-22 12:22:32 +00:00
|
|
|
|
2009-12-26 09:52:10 +00:00
|
|
|
switch(mode)
|
2009-12-22 12:22:32 +00:00
|
|
|
{
|
2009-12-26 09:52:10 +00:00
|
|
|
case BEGIN: newPos = pos; break;
|
|
|
|
case CURRENT: newPos = pos+tell(); break;
|
|
|
|
case END:
|
2009-12-22 12:22:32 +00:00
|
|
|
// Seeking from the end. This requires that we're able to get
|
2009-12-26 09:52:10 +00:00
|
|
|
// the entire size of the stream. The pos also has to be
|
2009-12-22 12:22:32 +00:00
|
|
|
// non-positive.
|
|
|
|
assert(inp->hasSize);
|
|
|
|
assert(pos <= 0);
|
2009-12-26 09:52:10 +00:00
|
|
|
newPos = inp->size() + pos;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
assert(0 && "invalid seek mode");
|
2009-12-22 12:22:32 +00:00
|
|
|
}
|
2009-12-26 09:52:10 +00:00
|
|
|
|
|
|
|
inp->seek(newPos);
|
|
|
|
return inp->tell() == newPos;
|
|
|
|
|
2009-12-22 12:22:32 +00:00
|
|
|
}
|