make the vorbis support mostly work. qf segs in Cache_TryAlloc when loading

a map, but I think that's related to some of our other sound resample bugs.
This commit is contained in:
Bill Currie 2002-06-14 22:55:57 +00:00
parent f2f6041e05
commit 9f1e6f9c82
2 changed files with 13 additions and 11 deletions

View file

@ -156,26 +156,27 @@ sfxcache_t *
SND_LoadSound (sfx_t *sfx, cache_allocator_t allocator)
{
char namebuffer[256];
char foundname[256];
byte *data;
wavinfo_t info;
int len;
float stepscale;
sfxcache_t *sc;
byte stackbuf[1 * 1024]; // avoid dirtying the cache heap
VFile *file;
// load it in
strcpy (namebuffer, "sound/");
strncat (namebuffer, sfx->name, sizeof (namebuffer) - strlen (namebuffer));
if (strcmp (".ogg", COM_FileExtension (sfx->name)) == 0) {
VFile *file;
COM_FOpenFile (namebuffer, &file);
if (!file) {
Sys_Printf ("Couldn't load %s\n", namebuffer);
return 0;
}
_COM_FOpenFile (namebuffer, &file, foundname, 1);
if (!file) {
Sys_Printf ("Couldn't load %s\n", namebuffer);
return 0;
}
if (strcmp (".ogg", COM_FileExtension (foundname)) == 0) {
return SND_LoadOgg (file, sfx, allocator);
}
Qclose (file); //FIXME this is a dumb way to do this
data = COM_LoadStackFile (namebuffer, stackbuf, sizeof (stackbuf));
if (!data) {

View file

@ -95,6 +95,7 @@ SND_LoadOgg (VFile *file, sfx_t *sfx, cache_allocator_t allocator)
}
vi = ov_info (&vf, -1);
samples = ov_pcm_total (&vf, -1);
size = samples * vi->channels * 2;
if (developer->int_val) {
char **ptr = ov_comment (&vf, -1)->user_comments;
@ -102,10 +103,10 @@ SND_LoadOgg (VFile *file, sfx_t *sfx, cache_allocator_t allocator)
Sys_Printf ("%s\n", *ptr++);
Sys_Printf ("\nBitstream is %d channel, %ldHz\n",
vi->channels, vi->rate);
Sys_Printf ("\nDecoded length: %ld samples\n", samples);
Sys_Printf ("\nDecoded length: %ld samples (%ld bytes)\n",
samples, size);
Sys_Printf ("Encoded by: %s\n\n", ov_comment (&vf, -1)->vendor);
}
size = samples * vi->channels * 2;
data = malloc (size);
if (!data)
goto bail;
@ -116,7 +117,7 @@ SND_LoadOgg (VFile *file, sfx_t *sfx, cache_allocator_t allocator)
sc->length = samples;
sc->loopstart = 0;
sc->speed = vi->rate;
sc->width = 16;
sc->width = 2;
sc->stereo = vi->channels;
SND_ResampleSfx (sc, sc->speed, sc->width, data);
bail: