Skip to content

Commit

Permalink
Workaround for silent audio on macOS (re: SDL_MixAudioFormat not work…
Browse files Browse the repository at this point in the history
…ing?)
  • Loading branch information
sofakng authored and sofakng committed Apr 4, 2023
1 parent 757b665 commit 60f0ac1
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/pc/audio/audio_sdl2.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,14 @@ static int audio_sdl_get_desired_buffered(void) {

static void audio_sdl_play(const uint8_t *buf, size_t len) {
if (configOverallVolume > 0 && audio_sdl_buffered() < 6000) {
#if TARGET_MACOS
SDL_QueueAudio(dev, buf, len);
#else
uint8_t *mix_buf[len];
SDL_memset(mix_buf, 0, len);
SDL_MixAudioFormat(mix_buf, buf, AUDIO_S16, len, SDL_MIX_MAXVOLUME * configOverallVolume);
SDL_QueueAudio(dev, mix_buf, len);
#endif
}
}

Expand All @@ -55,4 +59,4 @@ struct AudioAPI audio_sdl = {
audio_sdl_buffered,
audio_sdl_get_desired_buffered,
audio_sdl_play
};
};

0 comments on commit 60f0ac1

Please sign in to comment.