SDL_audiocvt.c: minor cleanup.

This commit is contained in:
Ozkan Sezer 2022-03-15 23:10:04 +03:00
parent 61a93d3c46
commit 5905696e66
1 changed files with 39 additions and 26 deletions

View File

@ -801,7 +801,8 @@ ResamplerPadding(const int inrate, const int outrate)
{ {
if (inrate == outrate) { if (inrate == outrate) {
return 0; return 0;
} else if (inrate > outrate) { }
if (inrate > outrate) {
return (int) SDL_ceil(((float) (RESAMPLER_SAMPLES_PER_ZERO_CROSSING * inrate) / ((float) outrate))); return (int) SDL_ceil(((float) (RESAMPLER_SAMPLES_PER_ZERO_CROSSING * inrate) / ((float) outrate)));
} }
return RESAMPLER_SAMPLES_PER_ZERO_CROSSING; return RESAMPLER_SAMPLES_PER_ZERO_CROSSING;
@ -1215,19 +1216,26 @@ SDL_BuildAudioCVT(SDL_AudioCVT * cvt,
if (!SDL_SupportedAudioFormat(src_fmt)) { if (!SDL_SupportedAudioFormat(src_fmt)) {
return SDL_SetError("Invalid source format"); return SDL_SetError("Invalid source format");
} else if (!SDL_SupportedAudioFormat(dst_fmt)) { }
if (!SDL_SupportedAudioFormat(dst_fmt)) {
return SDL_SetError("Invalid destination format"); return SDL_SetError("Invalid destination format");
} else if (!SDL_SupportedChannelCount(src_channels)) { }
if (!SDL_SupportedChannelCount(src_channels)) {
return SDL_SetError("Invalid source channels"); return SDL_SetError("Invalid source channels");
} else if (!SDL_SupportedChannelCount(dst_channels)) { }
if (!SDL_SupportedChannelCount(dst_channels)) {
return SDL_SetError("Invalid destination channels"); return SDL_SetError("Invalid destination channels");
} else if (src_rate <= 0) { }
if (src_rate <= 0) {
return SDL_SetError("Source rate is equal to or less than zero"); return SDL_SetError("Source rate is equal to or less than zero");
} else if (dst_rate <= 0) { }
if (dst_rate <= 0) {
return SDL_SetError("Destination rate is equal to or less than zero"); return SDL_SetError("Destination rate is equal to or less than zero");
} else if (src_rate >= SDL_MAX_SINT32 / RESAMPLER_SAMPLES_PER_ZERO_CROSSING) { }
if (src_rate >= SDL_MAX_SINT32 / RESAMPLER_SAMPLES_PER_ZERO_CROSSING) {
return SDL_SetError("Source rate is too high"); return SDL_SetError("Source rate is too high");
} else if (dst_rate >= SDL_MAX_SINT32 / RESAMPLER_SAMPLES_PER_ZERO_CROSSING) { }
if (dst_rate >= SDL_MAX_SINT32 / RESAMPLER_SAMPLES_PER_ZERO_CROSSING) {
return SDL_SetError("Destination rate is too high"); return SDL_SetError("Destination rate is too high");
} }
@ -1906,11 +1914,14 @@ SDL_AudioStreamPut(SDL_AudioStream *stream, const void *buf, int len)
if (!stream) { if (!stream) {
return SDL_InvalidParamError("stream"); return SDL_InvalidParamError("stream");
} else if (!buf) { }
if (!buf) {
return SDL_InvalidParamError("buf"); return SDL_InvalidParamError("buf");
} else if (len == 0) { }
if (len == 0) {
return 0; /* nothing to do. */ return 0; /* nothing to do. */
} else if ((len % stream->src_sample_frame_size) != 0) { }
if ((len % stream->src_sample_frame_size) != 0) {
return SDL_SetError("Can't add partial sample frames"); return SDL_SetError("Can't add partial sample frames");
} }
@ -2016,11 +2027,14 @@ SDL_AudioStreamGet(SDL_AudioStream *stream, void *buf, int len)
if (!stream) { if (!stream) {
return SDL_InvalidParamError("stream"); return SDL_InvalidParamError("stream");
} else if (!buf) { }
if (!buf) {
return SDL_InvalidParamError("buf"); return SDL_InvalidParamError("buf");
} else if (len <= 0) { }
if (len <= 0) {
return 0; /* nothing to do. */ return 0; /* nothing to do. */
} else if ((len % stream->dst_sample_frame_size) != 0) { }
if ((len % stream->dst_sample_frame_size) != 0) {
return SDL_SetError("Can't request partial sample frames"); return SDL_SetError("Can't request partial sample frames");
} }
@ -2066,4 +2080,3 @@ SDL_FreeAudioStream(SDL_AudioStream *stream)
} }
/* vi: set ts=4 sw=4 expandtab: */ /* vi: set ts=4 sw=4 expandtab: */