Change the current buffer size for a sample.
Defined in <SDL3_sound/SDL_sound.h>
int Sound_SetBufferSize(Sound_Sample *sample,
Uint32 new_size);| Sound_Sample * | sample | The Sound_Sample whose buffer to modify. |
| Uint32 | new_size | The desired size, in bytes, of the new buffer. |
(int) Returns non-zero if buffer size changed, zero on failure.
If the buffer size could be changed, then the
sample->buffer and sample->buffer_size
fields will reflect that. If they could not be changed, then your
original sample state is preserved. If the buffer is shrinking, the data
at the end of buffer is truncated. If the buffer is growing, the
contents of the new space at the end is undefined until you decode more
into it or initialize it yourself.
The buffer size specified must be a multiple of the size of a single sample frame. So, if you want 16-bit, stereo samples, then your sample frame size is (2 channels * 16 bits), or 32 bits per sample, which is four bytes. In such a case, you could specify 128 or 132 bytes for a buffer, but not 129, 130, or 131 (although in reality, you'll want to specify a MUCH larger buffer).
It is safe to call this function from any thread, but a single Sound_Sample should not be accessed from two threads at the same time.
This function is available since SDL_sound 1.0.0.