- sb->length = ResampleSfx (data + info.dataofs, info.samples, &s->format, sb->data, s->name);
- s->format.speed = shm->format.speed;
- s->total_length = sb->length;
- sb->offset = 0;
+ wav_format.speed = info.rate;
+ wav_format.width = info.width;
+ wav_format.channels = info.channels;
+ sb = Snd_CreateSndBuffer (data + info.dataofs, info.samples, &wav_format, snd_renderbuffer->format.speed);
+ if (sb == NULL)
+ {
+ Mem_Free(data);
+ return false;
+ }
+ sfx->fetcher = &wav_fetcher;
+ sfx->fetcher_data = sb;
+
+ sfx->total_length = sb->nbframes;
+ sfx->memsize += sb->maxframes * sb->format.channels * sb->format.width + sizeof (*sb) - sizeof (sb->samples);
+
+ if (info.loopstart < 0)
+ sfx->loopstart = sfx->total_length;
+ else
+ sfx->loopstart = (unsigned int) ((double)info.loopstart * (double)sb->format.speed / (double)info.rate);
+ sfx->loopstart = min(sfx->loopstart, sfx->total_length);
+ sfx->flags &= ~SFXFLAG_STREAMED;