2004-08-23 00:15:46 +00:00
|
|
|
#include "quakedef.h"
|
|
|
|
|
|
|
|
#ifdef AVAIL_OGGVORBIS
|
|
|
|
|
2006-07-08 22:45:07 +00:00
|
|
|
#ifdef __MORPHOS__
|
2007-06-20 00:02:54 +00:00
|
|
|
#include <exec/exec.h>
|
|
|
|
#include <libraries/vorbisfile.h>
|
2006-07-08 22:45:07 +00:00
|
|
|
|
2007-06-20 00:02:54 +00:00
|
|
|
#include <proto/exec.h>
|
|
|
|
#include <proto/vorbisfile.h>
|
2007-10-20 15:53:39 +00:00
|
|
|
#else
|
2007-06-20 00:02:54 +00:00
|
|
|
#include <vorbis/vorbisfile.h>
|
2006-07-08 22:45:07 +00:00
|
|
|
#endif
|
|
|
|
|
2004-08-23 00:15:46 +00:00
|
|
|
|
2006-07-08 22:45:07 +00:00
|
|
|
#if defined(__MORPHOS__)
|
2004-08-23 00:15:46 +00:00
|
|
|
|
2007-06-20 00:02:54 +00:00
|
|
|
#define oggvorbislibrary VorbisFileBase
|
|
|
|
struct Library *VorbisFileBase;
|
2004-08-23 00:15:46 +00:00
|
|
|
|
2005-04-18 03:21:16 +00:00
|
|
|
#else
|
2012-02-27 12:23:15 +00:00
|
|
|
dllhandle_t *oggvorbislibrary;
|
2004-08-23 00:15:46 +00:00
|
|
|
#endif
|
|
|
|
|
2006-07-08 22:45:07 +00:00
|
|
|
#ifdef __MORPHOS__
|
2007-06-20 00:02:54 +00:00
|
|
|
#define p_ov_open_callbacks(a, b, c, d, e) ov_open_callbacks(a, b, c, d, &e)
|
|
|
|
#define p_ov_clear ov_clear
|
|
|
|
#define p_ov_info ov_info
|
|
|
|
#define p_ov_comment ov_comment
|
|
|
|
#define p_ov_pcm_total ov_pcm_total
|
|
|
|
#define p_ov_read ov_read
|
2012-02-27 12:23:15 +00:00
|
|
|
#define p_ov_pcm_seek ov_pcm_seek
|
2006-07-08 22:45:07 +00:00
|
|
|
#else
|
2007-06-20 00:02:54 +00:00
|
|
|
int (VARGS *p_ov_open_callbacks) (void *datasource, OggVorbis_File *vf, char *initial, long ibytes, ov_callbacks callbacks);
|
|
|
|
int (VARGS *p_ov_clear)(OggVorbis_File *vf);
|
|
|
|
vorbis_info *(VARGS *p_ov_info)(OggVorbis_File *vf,int link);
|
|
|
|
vorbis_comment *(VARGS *p_ov_comment) (OggVorbis_File *vf,int link);
|
|
|
|
ogg_int64_t (VARGS *p_ov_pcm_total)(OggVorbis_File *vf,int i);
|
|
|
|
long (VARGS *p_ov_read)(OggVorbis_File *vf,char *buffer,int length,
|
|
|
|
int bigendianp,int word,int sgned,int *bitstream);
|
2012-02-27 12:23:15 +00:00
|
|
|
int (VARGS *p_ov_pcm_seek)(OggVorbis_File *vf,ogg_int64_t pos);
|
2006-07-08 22:45:07 +00:00
|
|
|
#endif
|
2004-08-23 00:15:46 +00:00
|
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
unsigned char *start; //file positions
|
|
|
|
unsigned long length;
|
|
|
|
unsigned long pos;
|
2005-03-29 15:01:57 +00:00
|
|
|
int srcspeed;
|
2012-02-27 12:23:15 +00:00
|
|
|
int srcchannels;
|
2004-08-23 00:15:46 +00:00
|
|
|
|
|
|
|
qboolean failed;
|
|
|
|
|
2012-02-27 12:23:15 +00:00
|
|
|
char *tempbuffer;
|
|
|
|
int tempbufferbytes;
|
|
|
|
|
|
|
|
char *decodedbuffer;
|
|
|
|
int decodedbufferbytes;
|
|
|
|
int decodedbytestart;
|
|
|
|
int decodedbytecount;
|
2004-08-23 00:15:46 +00:00
|
|
|
|
|
|
|
OggVorbis_File vf;
|
|
|
|
|
|
|
|
sfx_t *s;
|
|
|
|
} ovdecoderbuffer_t;
|
|
|
|
|
2012-02-27 12:23:15 +00:00
|
|
|
sfxcache_t *OV_DecodeSome(struct sfx_s *sfx, struct sfxcache_s *buf, int start, int length);
|
2004-08-23 00:15:46 +00:00
|
|
|
void OV_CancelDecoder(sfx_t *s);
|
2005-04-18 03:21:16 +00:00
|
|
|
qboolean OV_StartDecode(unsigned char *start, unsigned long length, ovdecoderbuffer_t *buffer);
|
2004-08-23 00:15:46 +00:00
|
|
|
|
2012-02-27 12:23:15 +00:00
|
|
|
qboolean S_LoadOVSound (sfx_t *s, qbyte *data, int datalen, int sndspeed)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
|
|
|
char *name;
|
|
|
|
ovdecoderbuffer_t *buffer;
|
|
|
|
|
2007-06-20 00:02:54 +00:00
|
|
|
if (datalen < 4 || strncmp(data, "OggS", 4))
|
2012-02-27 12:23:15 +00:00
|
|
|
return false;
|
2007-06-20 00:02:54 +00:00
|
|
|
|
2004-08-23 00:15:46 +00:00
|
|
|
name = s->name;
|
|
|
|
|
2012-02-27 12:23:15 +00:00
|
|
|
buffer = Z_Malloc(sizeof(ovdecoderbuffer_t));
|
2004-08-23 00:15:46 +00:00
|
|
|
|
2012-02-27 12:23:15 +00:00
|
|
|
buffer->decodedbytestart = 0;
|
|
|
|
buffer->decodedbytecount = 0;
|
2004-08-23 00:15:46 +00:00
|
|
|
buffer->s = s;
|
2012-02-27 12:23:15 +00:00
|
|
|
s->decoder.buf = buffer;
|
|
|
|
s->decoder.decodedata = OV_DecodeSome;
|
|
|
|
s->decoder.abort = OV_CancelDecoder;
|
2004-08-23 00:15:46 +00:00
|
|
|
|
2005-11-30 01:20:53 +00:00
|
|
|
if (!OV_StartDecode(data, datalen, buffer))
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
2012-02-27 12:23:15 +00:00
|
|
|
if (buffer->decodedbuffer)
|
2008-05-11 14:38:19 +00:00
|
|
|
{
|
2012-02-27 12:23:15 +00:00
|
|
|
BZ_Free(buffer->decodedbuffer);
|
|
|
|
buffer->decodedbuffer = NULL;
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
2012-02-27 12:23:15 +00:00
|
|
|
buffer->decodedbufferbytes = 0;
|
|
|
|
buffer->decodedbytestart = 0;
|
|
|
|
buffer->decodedbytecount = 0;
|
|
|
|
Z_Free(s->decoder.buf);
|
|
|
|
s->decoder.buf = NULL;
|
2007-06-20 00:02:54 +00:00
|
|
|
s->failedload = true;
|
2012-02-27 12:23:15 +00:00
|
|
|
return false;
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
|
2012-02-27 12:23:15 +00:00
|
|
|
s->decoder.decodedata(s, NULL, 0, 100);
|
2004-08-23 00:15:46 +00:00
|
|
|
|
2012-02-27 12:23:15 +00:00
|
|
|
return true;
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
|
2012-02-27 12:23:15 +00:00
|
|
|
sfxcache_t *OV_DecodeSome(struct sfx_s *sfx, struct sfxcache_s *buf, int start, int length)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
2005-03-29 15:01:57 +00:00
|
|
|
extern int snd_speed;
|
2008-05-11 14:38:19 +00:00
|
|
|
extern cvar_t snd_linearresample_stream;
|
2006-07-08 22:45:07 +00:00
|
|
|
int bigendianp = bigendian;
|
2005-03-29 15:01:57 +00:00
|
|
|
int current_section = 0;
|
2004-11-17 18:10:46 +00:00
|
|
|
|
2012-02-27 12:23:15 +00:00
|
|
|
ovdecoderbuffer_t *dec = sfx->decoder.buf;
|
2004-08-23 00:15:46 +00:00
|
|
|
int bytesread;
|
2004-11-17 18:10:46 +00:00
|
|
|
|
2012-02-27 12:23:15 +00:00
|
|
|
int outspeed = snd_speed;
|
|
|
|
|
2005-11-30 01:20:53 +00:00
|
|
|
// Con_Printf("Minlength = %03i ", minlength);
|
2005-05-26 12:55:34 +00:00
|
|
|
|
2012-02-27 12:23:15 +00:00
|
|
|
start *= 2*dec->srcchannels;
|
|
|
|
length *= 2*dec->srcchannels;
|
|
|
|
|
2007-06-20 00:02:54 +00:00
|
|
|
for (;;)
|
2004-11-17 18:10:46 +00:00
|
|
|
{
|
2012-02-27 12:23:15 +00:00
|
|
|
if (start < dec->decodedbytestart)
|
2007-06-20 00:02:54 +00:00
|
|
|
{
|
2012-02-27 12:23:15 +00:00
|
|
|
/*something rewound, purge clear the buffer*/
|
|
|
|
dec->decodedbytecount = 0;
|
|
|
|
dec->decodedbytestart = start;
|
|
|
|
|
|
|
|
//check pos
|
|
|
|
p_ov_pcm_seek(&dec->vf, dec->decodedbytestart);
|
2007-06-20 00:02:54 +00:00
|
|
|
}
|
2005-03-29 15:01:57 +00:00
|
|
|
|
2012-02-27 12:23:15 +00:00
|
|
|
if (start+length <= dec->decodedbytestart + dec->decodedbytecount)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (dec->decodedbytecount > snd_speed*8)
|
2007-06-20 00:02:54 +00:00
|
|
|
{
|
2012-02-27 12:23:15 +00:00
|
|
|
/*everything is okay, but our buffer is getting needlessly large.
|
|
|
|
keep anything after the 'new' position, but discard all before that
|
|
|
|
trim shouldn't be able to go negative
|
|
|
|
*/
|
|
|
|
unsigned int trim = start - dec->decodedbytestart;
|
|
|
|
//FIXME: retain an extra half-second for dual+ sound devices running slightly out of sync
|
|
|
|
memmove(dec->decodedbuffer, dec->decodedbuffer + trim, dec->decodedbytecount - trim);
|
|
|
|
dec->decodedbytecount -= trim;
|
|
|
|
dec->decodedbytestart += trim;
|
2007-06-20 00:02:54 +00:00
|
|
|
}
|
2004-11-17 18:10:46 +00:00
|
|
|
|
2012-02-27 12:23:15 +00:00
|
|
|
if (dec->decodedbufferbytes < start+length - dec->decodedbytestart + 128) //expand if needed.
|
2005-05-26 12:55:34 +00:00
|
|
|
{
|
2012-02-27 12:23:15 +00:00
|
|
|
// Con_Printf("Expand buffer\n");
|
|
|
|
dec->decodedbufferbytes = (start+length - dec->decodedbytestart) + snd_speed;
|
|
|
|
dec->decodedbuffer = BZ_Realloc(dec->decodedbuffer, dec->decodedbufferbytes);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (outspeed == dec->srcspeed)
|
|
|
|
{
|
|
|
|
bytesread = p_ov_read(&dec->vf, dec->decodedbuffer+dec->decodedbytecount, (start+length) - (dec->decodedbytestart+dec->decodedbytecount), bigendianp, 2, 1, ¤t_section);
|
2008-05-11 14:38:19 +00:00
|
|
|
if (bytesread <= 0)
|
2007-06-20 00:02:54 +00:00
|
|
|
{
|
2008-05-11 14:38:19 +00:00
|
|
|
if (bytesread != 0) //0==eof
|
|
|
|
{
|
|
|
|
Con_Printf("ogg decoding failed\n");
|
2012-02-27 12:23:15 +00:00
|
|
|
return NULL;
|
2008-05-11 14:38:19 +00:00
|
|
|
}
|
2012-02-27 12:23:15 +00:00
|
|
|
break;
|
2007-06-20 00:02:54 +00:00
|
|
|
}
|
2005-05-26 12:55:34 +00:00
|
|
|
}
|
2008-05-11 14:38:19 +00:00
|
|
|
else
|
|
|
|
{
|
2012-02-27 12:23:15 +00:00
|
|
|
double scale = dec->srcspeed / (double)outspeed;
|
|
|
|
int decodesize = ceil((dec->decodedbufferbytes-dec->decodedbytecount) * scale);
|
|
|
|
/*round down...*/
|
|
|
|
decodesize &= ~(2 * dec->srcchannels - 1);
|
|
|
|
if (decodesize > dec->tempbufferbytes)
|
2005-03-29 15:01:57 +00:00
|
|
|
{
|
2012-02-27 12:23:15 +00:00
|
|
|
dec->tempbuffer = BZ_Realloc(dec->tempbuffer, decodesize);
|
|
|
|
dec->tempbufferbytes = decodesize;
|
2005-03-29 15:01:57 +00:00
|
|
|
}
|
2008-05-11 14:38:19 +00:00
|
|
|
|
2012-02-27 12:23:15 +00:00
|
|
|
bytesread = p_ov_read(&dec->vf, dec->tempbuffer, decodesize, bigendianp, 2, 1, ¤t_section);
|
2008-05-11 14:38:19 +00:00
|
|
|
|
2008-11-09 22:29:28 +00:00
|
|
|
if (bytesread <= 0)
|
|
|
|
{
|
|
|
|
if (bytesread != 0) //0==eof
|
|
|
|
{
|
|
|
|
Con_Printf("ogg decoding failed\n");
|
2012-02-27 12:23:15 +00:00
|
|
|
return NULL;
|
2008-11-09 22:29:28 +00:00
|
|
|
}
|
2012-02-27 12:23:15 +00:00
|
|
|
return NULL;
|
2008-11-09 22:29:28 +00:00
|
|
|
}
|
|
|
|
|
2012-02-27 12:23:15 +00:00
|
|
|
SND_ResampleStream(dec->tempbuffer,
|
2008-05-11 14:38:19 +00:00
|
|
|
dec->srcspeed,
|
|
|
|
2,
|
2012-02-27 12:23:15 +00:00
|
|
|
dec->srcchannels,
|
|
|
|
bytesread / (2 * dec->srcchannels),
|
|
|
|
dec->decodedbuffer+dec->decodedbytecount,
|
|
|
|
outspeed,
|
2008-05-11 14:38:19 +00:00
|
|
|
2,
|
2012-02-27 12:23:15 +00:00
|
|
|
dec->srcchannels,
|
2009-11-04 21:16:50 +00:00
|
|
|
snd_linearresample_stream.ival);
|
2008-05-11 14:38:19 +00:00
|
|
|
|
|
|
|
bytesread = (int)floor(bytesread / scale) & ~0x1;
|
2005-03-29 15:01:57 +00:00
|
|
|
}
|
|
|
|
|
2012-02-27 12:23:15 +00:00
|
|
|
dec->decodedbytecount += bytesread;
|
|
|
|
}
|
2004-11-17 18:10:46 +00:00
|
|
|
|
2012-02-27 12:23:15 +00:00
|
|
|
if (buf)
|
|
|
|
{
|
|
|
|
buf->data = dec->decodedbuffer;
|
|
|
|
buf->soundoffset = dec->decodedbytestart / (2 * dec->srcchannels);
|
|
|
|
buf->length = dec->decodedbytecount;
|
|
|
|
buf->loopstart = -1;
|
|
|
|
buf->numchannels = dec->srcchannels;
|
|
|
|
buf->speed = snd_speed;
|
|
|
|
buf->width = 2;
|
2004-11-17 18:10:46 +00:00
|
|
|
}
|
2012-02-27 12:23:15 +00:00
|
|
|
return buf;
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
void OV_CancelDecoder(sfx_t *s)
|
|
|
|
{
|
2012-02-27 12:23:15 +00:00
|
|
|
/*
|
2005-03-29 15:01:57 +00:00
|
|
|
sfxcache_t *src, *dest;
|
|
|
|
ovdecoderbuffer_t *dec;
|
|
|
|
|
|
|
|
dec = s->decoder->buf;
|
|
|
|
p_ov_clear (&dec->vf); //close the decoder
|
|
|
|
|
|
|
|
//copy to new buffer
|
|
|
|
|
|
|
|
src = s->cache.data;
|
|
|
|
s->cache.fake = false;
|
|
|
|
s->cache.data = NULL;
|
|
|
|
dest = Cache_Alloc(&s->cache, dec->mediaaswavpos, s->name);
|
|
|
|
memcpy(dest, src, dec->mediaaswavpos);
|
|
|
|
BZ_Free(src);
|
|
|
|
|
2012-02-27 12:23:15 +00:00
|
|
|
if (dec->tempbuffer)
|
2008-05-11 14:38:19 +00:00
|
|
|
{
|
2012-02-27 12:23:15 +00:00
|
|
|
BZ_Free(dec->tempbuffer);
|
|
|
|
dec->tempbufferbytes = NULL;
|
2008-05-11 14:38:19 +00:00
|
|
|
}
|
|
|
|
|
2005-03-29 15:01:57 +00:00
|
|
|
Z_Free(s->decoder);
|
|
|
|
s->decoder = NULL;
|
2012-02-27 12:23:15 +00:00
|
|
|
*/
|
2005-03-29 15:01:57 +00:00
|
|
|
|
|
|
|
//and it's now indistinguisable from a wav
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
static size_t VARGS read_func (void *ptr, size_t size, size_t nmemb, void *datasource)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
|
|
|
ovdecoderbuffer_t *buffer = datasource;
|
|
|
|
int spare = buffer->length - buffer->pos;
|
|
|
|
|
|
|
|
if (size*nmemb > spare)
|
|
|
|
nmemb = spare / size;
|
|
|
|
memcpy(ptr, &buffer->start[buffer->pos], size*nmemb);
|
|
|
|
buffer->pos += size*nmemb;
|
|
|
|
return nmemb;
|
|
|
|
}
|
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
static int VARGS seek_func (void *datasource, ogg_int64_t offset, int whence)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
|
|
|
ovdecoderbuffer_t *buffer = datasource;
|
|
|
|
switch(whence)
|
|
|
|
{
|
|
|
|
case SEEK_SET:
|
|
|
|
buffer->pos = offset;
|
|
|
|
break;
|
|
|
|
case SEEK_END:
|
|
|
|
buffer->pos = buffer->length+offset;
|
|
|
|
break;
|
|
|
|
case SEEK_CUR:
|
|
|
|
buffer->pos+=offset;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
static int VARGS close_func (void *datasource)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
|
|
|
ovdecoderbuffer_t *buffer = datasource;
|
2005-03-29 15:01:57 +00:00
|
|
|
BZ_Free(buffer->start);
|
2004-08-23 00:15:46 +00:00
|
|
|
buffer->start=0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
static long VARGS tell_func (void *datasource)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
|
|
|
ovdecoderbuffer_t *buffer = datasource;
|
|
|
|
return buffer->pos;
|
|
|
|
}
|
|
|
|
static ov_callbacks callbacks = {
|
|
|
|
read_func,
|
|
|
|
seek_func,
|
|
|
|
close_func,
|
|
|
|
tell_func,
|
|
|
|
};
|
|
|
|
qboolean OV_StartDecode(unsigned char *start, unsigned long length, ovdecoderbuffer_t *buffer)
|
|
|
|
{
|
2005-04-16 16:21:27 +00:00
|
|
|
static qboolean tried;
|
2012-02-27 12:23:15 +00:00
|
|
|
static dllfunction_t funcs[] =
|
|
|
|
{
|
|
|
|
{(void*)&p_ov_open_callbacks, "ov_open_callbacks"},
|
|
|
|
{(void*)&p_ov_comment, "ov_comment"},
|
|
|
|
{(void*)&p_ov_pcm_total, "ov_pcm_total"},
|
|
|
|
{(void*)&p_ov_clear, "ov_clear"},
|
|
|
|
{(void*)&p_ov_info, "ov_info"},
|
|
|
|
{(void*)&p_ov_read, "ov_read"},
|
|
|
|
{(void*)&p_ov_pcm_seek, "ov_pcm_seek"},
|
|
|
|
{NULL}
|
|
|
|
};
|
|
|
|
static void *libhandle;
|
|
|
|
|
2005-04-16 16:21:27 +00:00
|
|
|
if (!oggvorbislibrary && !tried)
|
2006-07-08 22:45:07 +00:00
|
|
|
#if defined(__MORPHOS__)
|
|
|
|
{
|
|
|
|
VorbisFileBase = OpenLibrary("vorbisfile.library", 2);
|
|
|
|
if (!VorbisFileBase)
|
|
|
|
{
|
|
|
|
Con_Printf("Unable to open vorbisfile.library version 2\n");
|
|
|
|
}
|
|
|
|
}
|
2012-02-27 12:23:15 +00:00
|
|
|
#elif defined(_WIN32)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
2012-02-27 12:23:15 +00:00
|
|
|
oggvorbislibrary = Sys_LoadLibrary("vorbisfile", funcs);
|
2007-06-20 00:02:54 +00:00
|
|
|
if (!oggvorbislibrary)
|
2012-02-27 12:23:15 +00:00
|
|
|
oggvorbislibrary = Sys_LoadLibrary("libvorbisfile", funcs);
|
2004-08-23 00:15:46 +00:00
|
|
|
if (!oggvorbislibrary)
|
|
|
|
Con_Printf("Couldn't load DLL: \"vorbisfile.dll\".\n");
|
|
|
|
}
|
|
|
|
#else
|
2005-04-18 03:21:16 +00:00
|
|
|
{
|
2012-02-27 12:23:15 +00:00
|
|
|
oggvorbislibrary = Sys_LoadLibrary("libvorbisfile", funcs);
|
2005-04-18 03:21:16 +00:00
|
|
|
if (!oggvorbislibrary)
|
2012-02-27 12:23:15 +00:00
|
|
|
Con_Printf("Couldn't load library: \"libvorbisfile\".\n");
|
2005-04-18 03:21:16 +00:00
|
|
|
}
|
2004-08-23 00:15:46 +00:00
|
|
|
#endif
|
|
|
|
|
2006-07-08 22:45:07 +00:00
|
|
|
tried = true;
|
|
|
|
|
2006-03-12 05:23:18 +00:00
|
|
|
if (!oggvorbislibrary)
|
2007-06-20 00:02:54 +00:00
|
|
|
{
|
|
|
|
Con_Printf("ogg vorbis library is not loaded.\n");
|
2006-03-12 05:23:18 +00:00
|
|
|
return false;
|
2007-06-20 00:02:54 +00:00
|
|
|
}
|
2006-03-12 05:23:18 +00:00
|
|
|
|
2004-08-23 00:15:46 +00:00
|
|
|
buffer->start = start;
|
|
|
|
buffer->length = length;
|
|
|
|
buffer->pos = 0;
|
|
|
|
if (p_ov_open_callbacks(buffer, &buffer->vf, NULL, 0, callbacks))
|
|
|
|
{
|
2007-06-20 00:02:54 +00:00
|
|
|
Con_Printf("Input does not appear to be an Ogg bitstream.\n");
|
2004-08-23 00:15:46 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2005-03-29 15:01:57 +00:00
|
|
|
/* Print the comments plus a few lines about the bitstream we're
|
2004-08-23 00:15:46 +00:00
|
|
|
decoding */
|
|
|
|
{
|
2005-04-16 16:21:27 +00:00
|
|
|
// char **ptr=p_ov_comment(&buffer->vf,-1)->user_comments;
|
2004-08-23 00:15:46 +00:00
|
|
|
vorbis_info *vi=p_ov_info(&buffer->vf,-1);
|
2005-03-29 15:01:57 +00:00
|
|
|
|
|
|
|
if (vi->channels < 1 || vi->channels > 2)
|
|
|
|
{
|
|
|
|
p_ov_clear (&buffer->vf);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-02-27 12:23:15 +00:00
|
|
|
buffer->srcchannels = vi->channels;
|
2005-03-29 15:01:57 +00:00
|
|
|
buffer->srcspeed = vi->rate;
|
2005-04-16 16:21:27 +00:00
|
|
|
/*
|
2004-08-23 00:15:46 +00:00
|
|
|
while(*ptr){
|
|
|
|
Con_Printf("%s\n",*ptr);
|
2005-04-16 16:21:27 +00:00
|
|
|
ptr++;
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
Con_Printf("\nBitstream is %d channel, %ldHz\n",vi->channels,vi->rate);
|
|
|
|
Con_Printf("\nDecoded length: %ld samples\n",
|
|
|
|
(long)p_ov_pcm_total(&buffer->vf,-1));
|
|
|
|
Con_Printf("Encoded by: %s\n\n",p_ov_comment(&buffer->vf,-1)->vendor);
|
2005-04-16 16:21:27 +00:00
|
|
|
*/ }
|
2012-02-27 12:23:15 +00:00
|
|
|
buffer->tempbuffer = NULL;
|
|
|
|
buffer->tempbufferbytes = 0;
|
2005-11-30 01:20:53 +00:00
|
|
|
|
|
|
|
buffer->start = BZ_Malloc(length);
|
|
|
|
memcpy(buffer->start, start, length);
|
|
|
|
|
2004-08-23 00:15:46 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|