mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-06-01 17:12:15 +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
|
holding the samples
|
||||||
*/
|
*/
|
||||||
long (*ll_read)(void *cb_data, float **data);
|
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.
|
/** Read data from the stream.
|
||||||
This is a high-level function for use in the mixer. The read samples
|
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
|
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);
|
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
|
void
|
||||||
SND_SetupResampler (sfxbuffer_t *sc, int streamed)
|
SND_SetupResampler (sfxbuffer_t *sc, int streamed)
|
||||||
{
|
{
|
||||||
|
@ -157,6 +171,7 @@ SND_SetupResampler (sfxbuffer_t *sc, int streamed)
|
||||||
&err, stream);
|
&err, stream);
|
||||||
stream->read = snd_resample_read;
|
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->file = file;
|
||||||
stream->sfx = new_sfx;
|
stream->sfx = new_sfx;
|
||||||
stream->ll_read = read;
|
stream->ll_read = read;
|
||||||
stream->seek = seek;
|
stream->ll_seek = seek;
|
||||||
|
|
||||||
stream->wavinfo = *sfx->wavinfo (sfx);
|
stream->wavinfo = *sfx->wavinfo (sfx);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue