mirror of https://github.com/libsdl-org/SDL
loopwave: Use SDL_GetAudioStreamQueued() for more accurate results.
This commit is contained in:
parent
34b931f7eb
commit
b656720bc6
|
@ -31,14 +31,14 @@ static struct
|
||||||
SDL_AudioSpec spec;
|
SDL_AudioSpec spec;
|
||||||
Uint8 *sound; /* Pointer to wave data */
|
Uint8 *sound; /* Pointer to wave data */
|
||||||
Uint32 soundlen; /* Length of wave data */
|
Uint32 soundlen; /* Length of wave data */
|
||||||
Uint32 soundpos;
|
|
||||||
} wave;
|
} wave;
|
||||||
|
|
||||||
static SDL_AudioStream *stream;
|
static SDL_AudioStream *stream;
|
||||||
|
|
||||||
static void fillerup(void)
|
static void fillerup(void)
|
||||||
{
|
{
|
||||||
if (SDL_GetAudioStreamAvailable(stream) < (int) ((wave.soundlen / 2))) {
|
const int minimum = (wave.soundlen / SDL_AUDIO_FRAMESIZE(wave.spec)) / 2;
|
||||||
|
if (SDL_GetAudioStreamQueued(stream) < minimum) {
|
||||||
SDL_PutAudioStreamData(stream, wave.sound, wave.soundlen);
|
SDL_PutAudioStreamData(stream, wave.sound, wave.soundlen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue