You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think this probably also applies to 03-load-wav and 04-multiple-streams. SDL_GetAudioStreamAvailable() returns
the number of converted/resampled bytes available
that is: the number of bytes after resampling the input to destination/device format.
I expect this is typically not the same as the the generated input 8000hz, 32-bit float mono input. E.g. on my Ubuntu laptop with headphones plugged in its 44100Hz, S16, 2 channel. This example does a comparison that is not apples-to-apples:
const int minimum_audio = (8000 * sizeof (float)) / 2; /* 8000 float samples per second. Half of that. */
if (SDL_GetAudioStreamAvailable(stream) < minimum_audio) {
...
I discovered this while doing some network streaming and playback, I kept getting data underflow and injected silence, because I thought my buffers were satisfied when they were not. minimum_audio should be calculated using the device format gotten via a SDL_GetAudioStreamFormat(stream, NULL, &dst_spec).
Edit: I've also just seen SDL_GetAudioStreamQueued(), which returns the amount of queued input data, so that could be used too, instead of SDL_GetAudioStreamAvailable().
The text was updated successfully, but these errors were encountered:
I think this probably also applies to 03-load-wav and 04-multiple-streams.
SDL_GetAudioStreamAvailable()
returnsthat is: the number of bytes after resampling the input to destination/device format.
I expect this is typically not the same as the the generated input 8000hz, 32-bit float mono input. E.g. on my Ubuntu laptop with headphones plugged in its 44100Hz, S16, 2 channel. This example does a comparison that is not apples-to-apples:
I discovered this while doing some network streaming and playback, I kept getting data underflow and injected silence, because I thought my buffers were satisfied when they were not.
minimum_audio
should be calculated using the device format gotten via aSDL_GetAudioStreamFormat(stream, NULL, &dst_spec)
.Edit: I've also just seen SDL_GetAudioStreamQueued(), which returns the amount of queued input data, so that could be used too, instead of
SDL_GetAudioStreamAvailable()
.The text was updated successfully, but these errors were encountered: