Skip to content

Commit

Permalink
Fix playing unallocated memory on opening audio device
Browse files Browse the repository at this point in the history
  • Loading branch information
zugz committed Nov 16, 2020
1 parent ba5ded9 commit b04b3cb
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/audio_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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);
Expand Down

0 comments on commit b04b3cb

Please sign in to comment.