typedef struct
{
- qbyte *buffer;
+ unsigned char *buffer;
ogg_int64_t ind, buffsize;
} ov_decode_t;
const char* dllnames_vo [] =
{
#if defined(WIN64)
- "vorbis64.dll",
+ "libvorbis64.dll",
#elif defined(WIN32)
+ "libvorbis.dll",
"vorbis.dll",
#elif defined(MACOSX)
"libvorbis.dylib",
const char* dllnames_vf [] =
{
#if defined(WIN64)
- "vorbisfile64.dll",
+ "libvorbisfile64.dll",
#elif defined(WIN32)
+ "libvorbisfile.dll",
"vorbisfile.dll",
#elif defined(MACOSX)
"libvorbisfile.dylib",
*/
#define STREAM_BUFFER_DURATION 1.5f // 1.5 sec
-#define STREAM_BUFFER_SIZE(format_ptr) (ceil (STREAM_BUFFER_DURATION * ((format_ptr)->speed * (format_ptr)->width * (format_ptr)->channels)))
+#define STREAM_BUFFER_SIZE(format_ptr) ((int)(ceil (STREAM_BUFFER_DURATION * ((format_ptr)->speed * (format_ptr)->width * (format_ptr)->channels))))
// We work with 1 sec sequences, so this buffer must be able to contain
// 1 sec of sound of the highest quality (48 KHz, 16 bit samples, stereo)
-static qbyte resampling_buffer [48000 * 2 * 2];
+static unsigned char resampling_buffer [48000 * 2 * 2];
// Per-sfx data structure
typedef struct
{
- qbyte *file;
+ unsigned char *file;
size_t filesize;
snd_format_t format;
} ogg_stream_persfx_t;
*/
qboolean OGG_LoadVorbisFile (const char *filename, sfx_t *s)
{
- qbyte *data;
+ unsigned char *data;
+ fs_offset_t filesize;
ov_decode_t ov_decode;
OggVorbis_File vf;
vorbis_info *vi;
return true;
// Load the file
- data = FS_LoadFile (filename, snd_mempool, false);
+ data = FS_LoadFile (filename, snd_mempool, false, &filesize);
if (data == NULL)
return false;
// Open it with the VorbisFile API
ov_decode.buffer = data;
ov_decode.ind = 0;
- ov_decode.buffsize = fs_filesize;
+ ov_decode.buffsize = filesize;
if (qov_open_callbacks (&ov_decode, &vf, NULL, 0, callbacks) < 0)
{
Con_Printf ("error while opening Ogg Vorbis file \"%s\"\n", filename);
len = qov_pcm_total (&vf, -1) * vi->channels * 2; // 16 bits => "* 2"
// Decide if we go for a stream or a simple PCM cache
- buff_len = ceil (STREAM_BUFFER_DURATION * (shm->format.speed * 2 * vi->channels));
- if (snd_streaming.integer && len > (ogg_int64_t)fs_filesize + 3 * buff_len)
+ buff_len = (int)ceil (STREAM_BUFFER_DURATION * (shm->format.speed * 2 * vi->channels));
+ if (snd_streaming.integer && len > (ogg_int64_t)filesize + 3 * buff_len)
{
ogg_stream_persfx_t* per_sfx;
per_sfx = (ogg_stream_persfx_t *)Mem_Alloc (snd_mempool, sizeof (*per_sfx));
s->memsize += sizeof (*per_sfx);
per_sfx->file = data;
- per_sfx->filesize = fs_filesize;
- s->memsize += fs_filesize;
+ per_sfx->filesize = filesize;
+ s->memsize += filesize;
per_sfx->format.speed = vi->rate;
per_sfx->format.width = 2; // We always work with 16 bits samples
s->fetcher = &ogg_fetcher;
s->loopstart = -1;
s->flags |= SFXFLAG_STREAMED;
- s->total_length = (size_t)len / per_sfx->format.channels / 2 * ((float)s->format.speed / per_sfx->format.speed);
+ s->total_length = (int)((size_t)len / per_sfx->format.channels / 2 * ((float)s->format.speed / per_sfx->format.speed));
}
else
{
done += ret;
// Calculate resampled length
- len = (double)done * (double)shm->format.speed / (double)vi->rate;
+ // FIXME: is this using the correct rounding direction? ceil may be better
+ len = (int)((double)done * (double)shm->format.speed / (double)vi->rate);
// Resample it
memsize = (size_t)len + sizeof (*sb) - sizeof (sb->data);
s->loopstart = -1;
s->flags &= ~SFXFLAG_STREAMED;
- sb->length = (unsigned int)ResampleSfx ((qbyte *)buff, (size_t)done / (vi->channels * 2), &s->format, sb->data, s->name);
+ sb->length = (unsigned int)ResampleSfx ((unsigned char *)buff, (size_t)done / (vi->channels * 2), &s->format, sb->data, s->name);
s->format.speed = shm->format.speed;
s->total_length = sb->length;
sb->offset = 0;