1
0
mirror of https://github.com/Tha14/toxic.git synced 2024-11-14 05:23:01 +01:00

Fix playing unallocated memory on opening audio device

This commit is contained in:
zugz (tox) 2020-11-16 00:00:01 +00:00
parent 6c239193ab
commit c135c812c2
No known key found for this signature in database
GPG Key ID: 6F2BDA289D04F249

View File

@ -397,7 +397,7 @@ static DeviceError open_source(Device *device)
alSourcei(device->source, AL_LOOPING, AL_FALSE);
const uint32_t frame_size = device->frame_info.samples_per_frame * sample_size(device->frame_info.stereo);
size_t zeros_size = frame_size / 2;
size_t zeros_size = frame_size * sizeof(uint16_t);
uint16_t *zeros = calloc(1, zeros_size);
if (zeros == NULL) {
@ -407,7 +407,7 @@ static DeviceError open_source(Device *device)
for (int i = 0; i < OPENAL_BUFS; ++i) {
alBufferData(device->buffers[i], sound_mode(device->frame_info.stereo), zeros,
frame_size, device->frame_info.sample_rate);
zeros_size, device->frame_info.sample_rate);
}
free(zeros);