mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-06-01 06:44:27 +08:00
Make sure GetAudioStreamDataInternal is called with a valid length
This commit is contained in:
@@ -863,6 +863,8 @@ static int GetAudioStreamDataInternal(SDL_AudioStream *stream, void *buf, int le
|
|||||||
SDL_Log("AUDIOSTREAM: asking for an output chunk of %d bytes.", len);
|
SDL_Log("AUDIOSTREAM: asking for an output chunk of %d bytes.", len);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
SDL_assert((len % dst_sample_frame_size) == 0);
|
||||||
|
|
||||||
// Clamp the output length to the maximum currently available.
|
// Clamp the output length to the maximum currently available.
|
||||||
// The rest of this function assumes enough input data is available.
|
// The rest of this function assumes enough input data is available.
|
||||||
const int max_available = SDL_GetAudioStreamAvailable(stream);
|
const int max_available = SDL_GetAudioStreamAvailable(stream);
|
||||||
@@ -1049,9 +1051,10 @@ int SDL_GetAudioStreamData(SDL_AudioStream *stream, void *voidbuf, int len)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const int chunk_size = stream->dst_sample_frame_size * 4096;
|
||||||
|
|
||||||
int retval = 0;
|
int retval = 0;
|
||||||
while (len > 0) { // didn't ask for a whole sample frame, nothing to do
|
while (len > 0) { // didn't ask for a whole sample frame, nothing to do
|
||||||
const int chunk_size = 32 * 1024;
|
|
||||||
const int rc = GetAudioStreamDataInternal(stream, buf, SDL_min(len, chunk_size));
|
const int rc = GetAudioStreamDataInternal(stream, buf, SDL_min(len, chunk_size));
|
||||||
|
|
||||||
if (rc == -1) {
|
if (rc == -1) {
|
||||||
|
|||||||
Reference in New Issue
Block a user