29 #include "../idlib/precompiled.h"
59 void *ptr = decoderMemoryAllocator.
Alloc( size );
65 void *ptr = decoderMemoryAllocator.
Alloc( num * size );
67 memset( ptr, 0, num * size );
72 void *ptr = decoderMemoryAllocator.
Resize( (
byte *)memblock, size );
78 decoderMemoryAllocator.
Free( (
byte *)memblock );
95 size_t FS_ReadOGG(
void *dest,
size_t size1,
size_t size2,
void *fh ) {
97 return f->
Read( dest, size1 * size2 );
118 return f->
Seek( to, retype );
228 int total = dwSizeToRead;
229 char *bufferPtr = (
char *)pBuffer;
242 }
while( total > 0 );
244 dwSizeToRead = (
byte *)bufferPtr - pBuffer;
246 if ( pdwSizeRead !=
NULL ) {
247 *pdwSizeRead = dwSizeToRead;
284 virtual void Decode(
idSoundSample *sample,
int sampleOffset44k,
int sampleCount44k,
float *dest );
312 decoderMemoryAllocator.
Init();
346 sampleDecoderAllocator.
Free( localDecoder );
394 memset( &
ogg, 0,
sizeof(
ogg ) );
437 memset( dest, 0, sampleCount44k *
sizeof( dest[0] ) );
446 readSamples44k =
DecodePCM( sample, sampleOffset44k, sampleCount44k, dest );
450 readSamples44k =
DecodeOGG( sample, sampleOffset44k, sampleCount44k, dest );
461 if ( readSamples44k < sampleCount44k ) {
462 memset( dest + readSamples44k, 0, ( sampleCount44k - readSamples44k ) *
sizeof( dest[0] ) );
473 int pos,
size, readSamples;
479 int sampleOffset = sampleOffset44k >> shift;
480 int sampleCount = sampleCount44k >> shift;
488 if ( !sample->
FetchFromCache( sampleOffset *
sizeof(
short ), &first, &pos, &size,
false ) ) {
493 if ( size - pos < sampleCount *
sizeof(
short ) ) {
494 readSamples = ( size - pos ) /
sizeof(
short );
496 readSamples = sampleCount;
502 return ( readSamples << shift );
511 int readSamples, totalSamples;
514 int sampleOffset = sampleOffset44k >> shift;
515 int sampleCount = sampleCount44k >> shift;
548 totalSamples = sampleCount;
567 }
while( totalSamples > 0 );
571 return ( readSamples << shift );
void * _decoder_malloc(size_t size)
virtual int GetLastDecodeTime(void) const
idSoundSample * lastSample
int(* close_func)(void *datasource)
virtual idFile * OpenFileRead(const char *relativePath, bool allowCopyFiles=true, const char *gamedir=NULL)=0
waveformatextensible_t mpwfx
size_t FS_ReadOGG(void *dest, size_t size1, size_t size2, void *fh)
bool Swap_IsBigEndian(void)
static idSampleDecoder * Alloc(void)
assert(prefInfo.fullscreenBtn)
int GetNumUsedBlocks(void) const
void SetData(const char *data, int length)
virtual void VPCALL UpSamplePCMTo44kHz(float *dest, const short *pcm, const int numSamples, const int kHz, const int numChannels)=0
bool FetchFromCache(int offset, const byte **output, int *position, int *size, const bool allowIO)
int ov_open_callbacks(void *datasource, OggVorbis_File *vf, char *initial, long ibytes, ov_callbacks callbacks)
static int GetNumUsedBlocks(void)
idFileSystem * fileSystem
void SetFixedBlocks(int numBlocks)
int GetFreeBlockMemory(void) const
idBlockAlloc< idSampleDecoderLocal, 64 > sampleDecoderAllocator
int ov_clear(OggVorbis_File *vf)
GLuint GLuint GLsizei GLenum type
size_t(* read_func)(void *ptr, size_t size, size_t nmemb, void *datasource)
int DecodeOGG(idSoundSample *sample, int sampleOffset44k, int sampleCount44k, float *dest)
void * _decoder_realloc(void *memblock, size_t size)
type * Alloc(const int num)
ogg_int64_t ov_pcm_total(OggVorbis_File *vf, int i)
int DecodePCM(idSoundSample *sample, int sampleOffset44k, int sampleCount44k, float *dest)
static int GetUsedBlockMemory(void)
const int MIN_OGGVORBIS_MEMORY
void _decoder_free(void *memblock)
static void Shutdown(void)
type * Resize(type *ptr, const int num)
virtual void VPCALL UpSampleOGGTo44kHz(float *dest, const float *const *ogg, const int numSamples, const int kHz, const int numChannels)=0
vorbis_info * ov_info(OggVorbis_File *vf, int link)
int OpenOGG(const char *strFileName, waveformatex_t *pwfx=NULL)
virtual void virtual void FatalError(const char *fmt,...) id_attribute((format(printf
virtual int Read(void *buffer, int len)
static void Free(idSampleDecoder *decoder)
int FS_SeekOGG(void *fh, ogg_int64_t to, int type)
virtual idSoundSample * GetSample(void) const
virtual void Decode(idSoundSample *sample, int sampleOffset44k, int sampleCount44k, float *dest)
int FS_CloseOGG(void *fh)
long ov_read(OggVorbis_File *vf, char *buffer, int length, int bigendianp, int word, int sgned, int *bitstream)
virtual int Seek(long offset, fsOrigin_t origin)
virtual ID_TIME_T Timestamp(void)
long(* tell_func)(void *datasource)
int ov_openFile(idFile *f, OggVorbis_File *vf)
void * _decoder_calloc(size_t num, size_t size)
int(* seek_func)(void *datasource, ogg_int64_t offset, int whence)
idSoundSystemLocal soundSystemLocal
struct OggVorbis_File OggVorbis_File
int GetUsedBlockMemory(void) const
long ov_read_float(OggVorbis_File *vf, float ***pcm_channels, int samples, int *bitstream)
void SetLockMemory(bool lock)
virtual void ClearDecoder(void)
idDynamicBlockAlloc< byte, 1<< 20, 128 > decoderMemoryAllocator
virtual void CloseFile(idFile *f)=0
waveformatex_t objectInfo
bool mbIsReadingFromMemory
void Sys_LeaveCriticalSection(int index)
void Sys_EnterCriticalSection(int index)
static idCVar s_realTimeDecoding
int ReadOGG(byte *pBuffer, int dwSizeToRead, int *pdwSizeRead)
int ov_pcm_seek(OggVorbis_File *vf, ogg_int64_t pos)
long FS_TellOGG(void *fh)
idSIMDProcessor * SIMDProcessor