17 #include "precompiled.h"
83 static size_t Read(
void* bufferToFill,
size_t itemSize,
size_t numItems,
void* context)
86 const off_t sizeRequested = numItems*itemSize;
88 const size_t sizeToRead = (size_t)std::min(sizeRequested, sizeRemaining);
93 adapter->
offset += sizeToRead;
101 static int Seek(
void* context, ogg_int64_t
offset,
int whence)
115 origin = adapter->
size+1;
127 adapter->
file.reset();
131 static long Tell(
void* context)
155 static size_t Read(
void* bufferToFill,
size_t itemSize,
size_t numItems,
void* context)
159 const off_t sizeRequested = numItems*itemSize;
161 const size_t sizeToRead = (size_t)std::min(sizeRequested, sizeRemaining);
163 memcpy(bufferToFill, adapter->
buffer.get() + adapter->
offset, sizeToRead);
165 adapter->
offset += sizeToRead;
169 static int Seek(
void* context, ogg_int64_t
offset,
int whence)
183 origin = adapter->
size+1;
199 static long Tell(
void* context)
214 template <
typename Adapter>
234 ov_callbacks callbacks;
236 callbacks.close_func = Adapter::Close;
237 callbacks.seek_func = Adapter::Seek;
238 callbacks.tell_func = Adapter::Tell;
239 const int ret = ov_open_callbacks(&
adapter, &
vf, 0, 0, callbacks);
244 info = ov_info(&
vf, link);
253 return (
info->channels == 1)? AL_FORMAT_MONO16 : AL_FORMAT_STEREO16;
267 ov_time_seek( &
vf, 0 );
276 size_t bytesRead = 0;
280 const int wordSize =
sizeof(
i16);
281 const int isSigned = 1;
283 const int ret = ov_read(&
vf, (
char*)buffer+bytesRead,
int(size-bytesRead), isBigEndian, wordSize, isSigned, &bitstream);
293 if(bytesRead == size)
322 shared_ptr<u8> contents;
332 #endif // CONFIG2_AUDIO
virtual Status GetNextChunk(u8 *buffer, size_t size)
VorbisBufferAdapter(const shared_ptr< u8 > &buffer, size_t size)
static int Seek(void *context, ogg_int64_t offset, int whence)
static long Tell(void *context)
static Status LibErrorFromVorbis(int err)
T Clamp(T val, T min, T max)
low-level aka "lib"
const Status INVALID_HANDLE
VorbisFileAdapter(const PFile &openedFile)
static size_t Read(void *bufferToFill, size_t itemSize, size_t numItems, void *context)
const Status NOT_SUPPORTED
const Status INVALID_VERSION
virtual Status ResetFile()
shared_ptr< OggStream > OggStreamPtr
u64 FileSize(const OsPath &pathname)
const Status INVALID_PARAM
i64 Status
Error handling system.
OggStreamImpl(const Adapter &adapter)
Status OpenOggStream(const OsPath &pathname, OggStreamPtr &stream)
virtual ALsizei SamplingRate()
static int Close(void *context)
Status OpenOggNonstream(const PIVFS &vfs, const VfsPath &pathname, OggStreamPtr &stream)
A non-streaming OggStream (reading the whole file in advance) that can cope with archived/compressed ...
#define WARN_RETURN(status)
#define NODEFAULT
convenient specialization of UNREACHABLE for switch statements whose default can never be reached...
static int Seek(void *context, ogg_int64_t offset, int whence)
static int Close(void *context)
static long Tell(void *context)
static size_t Read(void *bufferToFill, size_t itemSize, size_t numItems, void *context)
#define RETURN_STATUS_IF_ERR(expression)
static Status Run(const Operation &op, const Parameters &p=Parameters(), const CompletedHook &completedHook=CompletedHook(), const IssueHook &issueHook=IssueHook())