Skip to content

Commit

Permalink
audio: Remove resampling limits.
Browse files Browse the repository at this point in the history
Audio streams used to accept audio with a src or dest frequency between
4000Hz and 384000Hz. It was arbitrary (or perhaps a relic of older
resampler revisions), and testing shows unnecessary, so remove it.

Fixes libsdl-org#12098.
  • Loading branch information
icculus committed Jan 27, 2025
1 parent 5f8e0eb commit 09f900f
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions src/audio/SDL_audiocvt.c
Original file line number Diff line number Diff line change
Expand Up @@ -558,9 +558,9 @@ bool SDL_SetAudioStreamFormat(SDL_AudioStream *stream, const SDL_AudioSpec *src_
return SDL_InvalidParamError("stream");
}

// Picked mostly arbitrarily.
static const int min_freq = 4000;
static const int max_freq = 384000;
// note that while we've removed the maximum frequency checks, SDL _will_
// fail to resample to extremely high sample rates correctly. Really high,
// like 196608000Hz. File a bug. :P

if (src_spec) {
if (!SDL_IsSupportedAudioFormat(src_spec->format)) {
Expand All @@ -569,10 +569,6 @@ bool SDL_SetAudioStreamFormat(SDL_AudioStream *stream, const SDL_AudioSpec *src_
return SDL_InvalidParamError("src_spec->channels");
} else if (src_spec->freq <= 0) {
return SDL_InvalidParamError("src_spec->freq");
} else if (src_spec->freq < min_freq) {
return SDL_SetError("Source rate is too low");
} else if (src_spec->freq > max_freq) {
return SDL_SetError("Source rate is too high");
}
}

Expand All @@ -583,10 +579,6 @@ bool SDL_SetAudioStreamFormat(SDL_AudioStream *stream, const SDL_AudioSpec *src_
return SDL_InvalidParamError("dst_spec->channels");
} else if (dst_spec->freq <= 0) {
return SDL_InvalidParamError("dst_spec->freq");
} else if (dst_spec->freq < min_freq) {
return SDL_SetError("Destination rate is too low");
} else if (dst_spec->freq > max_freq) {
return SDL_SetError("Destination rate is too high");
}
}

Expand Down

0 comments on commit 09f900f

Please sign in to comment.