Procházet zdrojové kódy

audio: Use SDL_powerof2 instead of reinventing it.

Ryan C. Gordon před 1 rokem
rodič
revize
65d296ef1a
1 změnil soubory, kde provedl 1 přidání a 7 odebrání
  1. 1 7
      src/audio/SDL_audio.c

+ 1 - 7
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)