mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-10-18 15:51:44 +00:00
audio: Use SDL_powerof2 instead of reinventing it.
This commit is contained in:
@@ -1178,13 +1178,7 @@ static void PrepareAudioFormat(SDL_bool iscapture, SDL_AudioSpec *spec)
|
|||||||
|
|
||||||
static int GetDefaultSampleFramesFromFreq(int freq)
|
static int GetDefaultSampleFramesFromFreq(int freq)
|
||||||
{
|
{
|
||||||
// Pick the closest power-of-two to ~46 ms at desired frequency
|
return SDL_powerof2((freq / 1000) * 46); // 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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDL_UpdatedAudioDeviceFormat(SDL_AudioDevice *device)
|
void SDL_UpdatedAudioDeviceFormat(SDL_AudioDevice *device)
|
||||||
|
Reference in New Issue
Block a user