From 65d296ef1a21353f5f1d06f7c191e100c36229ca Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Tue, 4 Jul 2023 19:26:41 -0400 Subject: [PATCH] audio: Use SDL_powerof2 instead of reinventing it. --- src/audio/SDL_audio.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/audio/SDL_audio.c b/src/audio/SDL_audio.c index aea09ff807..bca3513612 100644 --- a/src/audio/SDL_audio.c +++ b/src/audio/SDL_audio.c @@ -1178,13 +1178,7 @@ static void PrepareAudioFormat(SDL_bool iscapture, SDL_AudioSpec *spec) static int GetDefaultSampleFramesFromFreq(int freq) { - // Pick the closest power-of-two to ~46 ms at desired frequency - const int max_sample = ((freq / 1000) * 46); - int current_sample = 1; - while (current_sample < max_sample) { - current_sample *= 2; - } - return current_sample; + return SDL_powerof2((freq / 1000) * 46); // Pick the closest power-of-two to ~46 ms at desired frequency } void SDL_UpdatedAudioDeviceFormat(SDL_AudioDevice *device)