- Con_Printf ("%s has an unsupported number of channels (%i)\n",s->name, info.channels);
- Mem_Free(data);
- return NULL;
- }
-
- // calculate resampled length
- len = (int) ((double) info.samples * (double) shm->speed / (double) info.rate);
- len = len * info.width * info.channels;
-
- // FIXME: add S_UnloadSounds or something?
- Mem_FreePool(&s->mempool);
- s->mempool = Mem_AllocPool(s->name);
- sc = s->sfxcache = Mem_Alloc(s->mempool, len + sizeof(sfxcache_t));
- if (!sc)
- {
- Mem_FreePool(&s->mempool);
- Mem_Free(data);
- return NULL;
- }
-
- sc->length = info.samples;
- sc->loopstart = info.loopstart;
- sc->speed = info.rate;
- sc->width = info.width;
- sc->stereo = info.channels == 2;
-
- ResampleSfx (sc, data + info.dataofs, s->name);
-
- Mem_Free(data);
- return sc;
-}
-
-
-
-/*
-===============================================================================
-
-WAV loading
-
-===============================================================================
-*/
-
-
-qbyte *data_p;
-qbyte *iff_end;
-qbyte *last_chunk;
-qbyte *iff_data;
-int iff_chunk_len;
-
-
-short GetLittleShort(void)
-{
- short val = 0;
- val = *data_p;
- val = val + (*(data_p+1)<<8);
- data_p += 2;
- return val;
-}
-
-int GetLittleLong(void)
-{
- int val = 0;
- val = *data_p;
- val = val + (*(data_p+1)<<8);
- val = val + (*(data_p+2)<<16);
- val = val + (*(data_p+3)<<24);
- data_p += 4;
- return val;
-}
-
-void FindNextChunk(char *name)
-{
- while (1)
- {
- data_p=last_chunk;
-
- if (data_p >= iff_end)
- { // didn't find the chunk
- data_p = NULL;
- return;
- }
-
- data_p += 4;
- iff_chunk_len = GetLittleLong();
- if (iff_chunk_len < 0)