mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-23 04:42:32 +00:00
reset the "resampler" when seeking
This commit is contained in:
parent
22e8698827
commit
b1620616b9
3 changed files with 21 additions and 1 deletions
|
@ -146,6 +146,11 @@ struct sfxstream_s {
|
|||
holding the samples
|
||||
*/
|
||||
long (*ll_read)(void *cb_data, float **data);
|
||||
/** Seek to an absolute position within the stream (low level).
|
||||
\param stream "this"
|
||||
\param pos frame position with the stream
|
||||
*/
|
||||
int (*ll_seek)(sfxstream_t *stream, int pos);
|
||||
/** Read data from the stream.
|
||||
This is a high-level function for use in the mixer. The read samples
|
||||
will always at be the correct sample rate for the mixer, reguardless
|
||||
|
|
|
@ -127,6 +127,20 @@ snd_resample_read (sfxstream_t *stream, float *data, int frames)
|
|||
return src_callback_read (stream->state, ratio, frames, data);
|
||||
}
|
||||
|
||||
static int
|
||||
snd_seek (sfxstream_t *stream, int pos)
|
||||
{
|
||||
int res = stream->ll_seek (stream, pos);
|
||||
if (stream->read == snd_resample_read) {
|
||||
src_reset (stream->state);
|
||||
} else {
|
||||
snd_null_state_t *state = (snd_null_state_t *) stream->state;
|
||||
state->size = 0;
|
||||
state->pos = 0;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
void
|
||||
SND_SetupResampler (sfxbuffer_t *sc, int streamed)
|
||||
{
|
||||
|
@ -157,6 +171,7 @@ SND_SetupResampler (sfxbuffer_t *sc, int streamed)
|
|||
&err, stream);
|
||||
stream->read = snd_resample_read;
|
||||
}
|
||||
stream->seek = snd_seek;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -140,7 +140,7 @@ SND_SFX_StreamOpen (sfx_t *sfx, void *file,
|
|||
stream->file = file;
|
||||
stream->sfx = new_sfx;
|
||||
stream->ll_read = read;
|
||||
stream->seek = seek;
|
||||
stream->ll_seek = seek;
|
||||
|
||||
stream->wavinfo = *sfx->wavinfo (sfx);
|
||||
|
||||
|
|
Loading…
Reference in a new issue