mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-26 22:31:05 +00:00
make streams work in chunks of 256 samples (won't work so well for non power
of 2 resample rates :/)
This commit is contained in:
parent
e4ba0ad5e5
commit
52f41f8095
4 changed files with 10 additions and 2 deletions
|
@ -68,6 +68,7 @@ typedef struct sfxstream_s {
|
|||
sfx_t *sfx;
|
||||
void *file;
|
||||
wavinfo_t wavinfo;
|
||||
int pos;
|
||||
void (*resample)(sfxbuffer_t *, byte *, int, void *);
|
||||
int (*read)(void *file, byte *data, int bytes, wavinfo_t *info);
|
||||
int (*seek)(void *file, int pos, wavinfo_t *info);
|
||||
|
|
|
@ -157,6 +157,11 @@ SND_StreamAdvance (sfxbuffer_t *buffer, unsigned int count)
|
|||
wavinfo_t *info = &stream->wavinfo;
|
||||
void *prev;
|
||||
|
||||
stream->pos += count;
|
||||
count = (stream->pos - buffer->pos) & ~255;
|
||||
if (!count)
|
||||
return;
|
||||
|
||||
stepscale = (float) info->rate / shm->speed; // usually 0.5, 1, or 2
|
||||
|
||||
// find out how many samples the buffer currently holds
|
||||
|
@ -185,6 +190,7 @@ SND_StreamAdvance (sfxbuffer_t *buffer, unsigned int count)
|
|||
buffer->pos %= sfx->length - sfx->loopstart;
|
||||
buffer->pos += sfx->loopstart;
|
||||
}
|
||||
stream->pos = buffer->pos;
|
||||
}
|
||||
headpos = buffer->pos;
|
||||
stream->seek (stream->file, buffer->pos * stepscale, info);
|
||||
|
@ -200,6 +206,7 @@ SND_StreamAdvance (sfxbuffer_t *buffer, unsigned int count)
|
|||
} else {
|
||||
buffer->pos -= sfx->length - sfx->loopstart;
|
||||
}
|
||||
stream->pos = buffer->pos;
|
||||
}
|
||||
|
||||
buffer->tail += count;
|
||||
|
|
|
@ -248,7 +248,7 @@ vorbis_stream (sfx_t *sfx, char *realname, OggVorbis_File *vf, wavinfo_t info)
|
|||
int size;
|
||||
|
||||
samples = shm->speed * 0.3;
|
||||
size = samples = (samples + 3) & ~3;
|
||||
size = samples = (samples + 255) & ~255;
|
||||
if (!snd_loadas8bit->int_val)
|
||||
size *= 2;
|
||||
if (info.channels == 2)
|
||||
|
|
|
@ -119,7 +119,7 @@ wav_stream (sfx_t *sfx, char *realname, void *file, wavinfo_t info)
|
|||
int size;
|
||||
|
||||
samples = shm->speed * 0.3;
|
||||
size = samples = (samples + 3) & ~3;
|
||||
size = samples = (samples + 255) & ~255;
|
||||
if (!snd_loadas8bit->int_val)
|
||||
size *= 2;
|
||||
if (info.channels == 2)
|
||||
|
|
Loading…
Reference in a new issue