Skip to content

Commit

Permalink
Clear audio buffer when switching songs/modes
Browse files Browse the repository at this point in the history
  • Loading branch information
HunterWhyte committed Jan 8, 2023
1 parent c5c5385 commit dbc657e
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions jumaudio.c
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ ma_int32 jum_startPlayback(jum_AudioSetup* setup, const char* filepath, ma_int32
// set buffer size to appropriate value for given number of channels TODO look at how we are dealing with 1 vs 2 channels
setup->buffer.sz =
setup->info.channels == 2 ? setup->buffer.allocated_sz : setup->buffer.allocated_sz / 2;
memset(setup->buffer.buf, 0, setup->buffer.allocated_sz * sizeof(float));

result = ma_device_init(&setup->context, &config, &setup->device);
if (result != MA_SUCCESS) {
Expand Down Expand Up @@ -307,6 +308,7 @@ ma_int32 jum_startCapture(jum_AudioSetup* setup, ma_int32 device_index) {

// set buffer size to appropriate value for 2 channels
setup->buffer.sz = setup->buffer.allocated_sz;
memset(setup->buffer.buf, 0, setup->buffer.allocated_sz * sizeof(float));

result = ma_device_init(&setup->context, &config, &setup->device);
if (result != MA_SUCCESS) {
Expand Down

0 comments on commit dbc657e

Please sign in to comment.