From 5ae972503887785faa22fffa1fa09435a2d4f7f8 Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <[EMAIL REDACTED]>
Date: Sun, 29 Dec 2024 11:03:40 +0300
Subject: [PATCH] remove all bool/int return apologies from header. minor
clean-ups.
---
include/SDL3_mixer/SDL_mixer.h | 29 -----------------------------
src/effect_position.c | 6 +-----
src/effect_stereoreverse.c | 7 +------
src/effects_internal.c | 5 -----
src/effects_internal.h | 2 --
src/mixer.c | 13 +++----------
src/mixer.h | 2 --
src/music.c | 8 ++------
src/music.h | 2 --
9 files changed, 7 insertions(+), 67 deletions(-)
diff --git a/include/SDL3_mixer/SDL_mixer.h b/include/SDL3_mixer/SDL_mixer.h
index 8d700d872..5ed6ca809 100644
--- a/include/SDL3_mixer/SDL_mixer.h
+++ b/include/SDL3_mixer/SDL_mixer.h
@@ -1153,10 +1153,6 @@ typedef void (SDLCALL *Mix_EffectDone_t)(int chan, void *udata);
* through Mix_SetPostMix() runs, and then the stream goes to the audio
* device.
*
- * Note that unlike most SDL and SDL_mixer functions, this function returns
- * zero if there's an error, not on success. We apologize for the API design
- * inconsistency here.
- *
* \param chan the channel to register an effect to, or MIX_CHANNEL_POST.
* \param f effect the callback to run when more of this channel is to be
* mixed.
@@ -1181,10 +1177,6 @@ extern SDL_DECLSPEC bool SDLCALL Mix_RegisterEffect(int chan, Mix_EffectFunc_t f
* unregistered through this function by specifying MIX_CHANNEL_POST for a
* channel.
*
- * Note that unlike most SDL and SDL_mixer functions, this function returns
- * zero if there's an error, not on success. We apologize for the API design
- * inconsistency here.
- *
* \param channel the channel to unregister an effect on, or MIX_CHANNEL_POST.
* \param f effect the callback stop calling in future mixing iterations.
* \returns true on success or false on failure; call SDL_GetError() for more
@@ -1207,10 +1199,6 @@ extern SDL_DECLSPEC bool SDLCALL Mix_UnregisterEffect(int channel, Mix_EffectFun
* explicitly unregistered through this function by specifying
* MIX_CHANNEL_POST for a channel.
*
- * Note that unlike most SDL and SDL_mixer functions, this function returns
- * zero if there's an error, not on success. We apologize for the API design
- * inconsistency here.
- *
* \param channel the channel to unregister all effects on, or
* MIX_CHANNEL_POST.
* \returns true on success or false on failure; call SDL_GetError() for more
@@ -1263,10 +1251,6 @@ extern SDL_DECLSPEC bool SDLCALL Mix_UnregisterAllEffects(int channel);
* return successful in that case. Error messages can be retrieved from
* Mix_GetError().
*
- * Note that unlike most SDL and SDL_mixer functions, this function returns
- * zero if there's an error, not on success. We apologize for the API design
- * inconsistency here.
- *
* \param channel The mixer channel to pan or MIX_CHANNEL_POST.
* \param left Volume of stereo left channel, 0 is silence, 255 is full
* volume.
@@ -1352,10 +1336,6 @@ extern SDL_DECLSPEC bool SDLCALL Mix_SetPosition(int channel, Sint16 angle, Uint
*
* This uses the Mix_RegisterEffect() API internally.
*
- * Note that unlike most SDL and SDL_mixer functions, this function returns
- * zero if there's an error, not on success. We apologize for the API design
- * inconsistency here.
- *
* \param channel The mixer channel to attenuate, or MIX_CHANNEL_POST.
* \param distance distance; 0 is the listener, 255 is maxiumum distance away.
* \returns true on success or false on failure; call SDL_GetError() for more
@@ -1384,10 +1364,6 @@ extern SDL_DECLSPEC bool SDLCALL Mix_SetDistance(int channel, Uint8 distance);
* the final mixed stream before sending it on to the audio device (a
* posteffect).
*
- * Note that unlike most SDL and SDL_mixer functions, this function returns
- * zero if there's an error, not on success. We apologize for the API design
- * inconsistency here.
- *
* \param channel The mixer channel to reverse, or MIX_CHANNEL_POST.
* \param flip non-zero to reverse stereo, zero to disable this effect.
* \returns true on success or false on failure; call SDL_GetError() for more
@@ -2432,10 +2408,6 @@ extern SDL_DECLSPEC bool SDLCALL Mix_PlayingMusic(void);
*
* Passing a NULL path will remove any previously-specified paths.
*
- * Note that unlike most SDL and SDL_mixer functions, this function returns
- * zero if there's an error, not on success. We apologize for the API design
- * inconsistency here.
- *
* \param paths Paths on the filesystem where SoundFonts are available,
* separated by semicolons.
* \returns true on success or false on failure; call SDL_GetError() for more
@@ -2592,7 +2564,6 @@ extern SDL_DECLSPEC void SDLCALL Mix_CloseAudio(void);
#ifdef __cplusplus
}
#endif
-
#include <SDL3/SDL_close_code.h>
#endif /* SDL_MIXER_H_ */
diff --git a/src/effect_position.c b/src/effect_position.c
index d91fd0b43..30b074301 100644
--- a/src/effect_position.c
+++ b/src/effect_position.c
@@ -1613,7 +1613,7 @@ bool Mix_SetPanning(int channel, Uint8 left, Uint8 right)
int channels;
SDL_AudioFormat format;
position_args *args = NULL;
- int retval = 1;
+ bool retval = true;
Mix_QuerySpec(NULL, &format, &channels);
@@ -1794,7 +1794,3 @@ bool Mix_SetPosition(int channel, Sint16 angle, Uint8 distance)
Mix_UnlockAudio();
return retval;
}
-
-/* end of effects_position.c ... */
-
-/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/effect_stereoreverse.c b/src/effect_stereoreverse.c
index 204c3f85a..e57b85905 100644
--- a/src/effect_stereoreverse.c
+++ b/src/effect_stereoreverse.c
@@ -122,8 +122,7 @@ bool Mix_SetReverseStereo(int channel, int flip)
f = _Eff_reversestereo32;
break;
default:
- SDL_SetError("Unsupported audio format");
- return false;
+ return SDL_SetError("Unsupported audio format");
}
if (!flip) {
return Mix_UnregisterEffect(channel, f);
@@ -133,7 +132,3 @@ bool Mix_SetReverseStereo(int channel, int flip)
return SDL_SetError("Trying to reverse stereo on a non-stereo stream");
}
-
-/* end of effect_stereoreverse.c ... */
-
-/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/effects_internal.c b/src/effects_internal.c
index a1d81f779..ebb20bdb6 100644
--- a/src/effects_internal.c
+++ b/src/effects_internal.c
@@ -112,8 +112,3 @@ void *_Eff_build_volume_table_s8(void)
return _Eff_volume_table;
}
-
-
-/* end of effects.c ... */
-
-/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/effects_internal.h b/src/effects_internal.h
index 72d30d815..51bf13fdb 100644
--- a/src/effects_internal.h
+++ b/src/effects_internal.h
@@ -42,5 +42,3 @@ bool _Mix_UnregisterEffect_locked(int channel, Mix_EffectFunc_t f);
bool _Mix_UnregisterAllEffects_locked(int channel);
#endif /* _INCLUDE_EFFECTS_INTERNAL_H_ */
-
-/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/mixer.c b/src/mixer.c
index c5f615243..a4c33e613 100644
--- a/src/mixer.c
+++ b/src/mixer.c
@@ -1687,8 +1687,7 @@ bool _Mix_RegisterEffect_locked(int channel, Mix_EffectFunc_t f, Mix_EffectDone_
e = &posteffects;
} else {
if ((channel < 0) || (channel >= num_channels)) {
- SDL_SetError("Invalid channel number");
- return 0;
+ return SDL_SetError("Invalid channel number");
}
e = &mix_channel[channel].effects;
}
@@ -1716,8 +1715,7 @@ bool _Mix_UnregisterEffect_locked(int channel, Mix_EffectFunc_t f)
e = &posteffects;
} else {
if ((channel < 0) || (channel >= num_channels)) {
- SDL_SetError("Invalid channel number");
- return 0;
+ return SDL_SetError("Invalid channel number");
}
e = &mix_channel[channel].effects;
}
@@ -1743,8 +1741,7 @@ bool _Mix_UnregisterAllEffects_locked(int channel)
e = &posteffects;
} else {
if ((channel < 0) || (channel >= num_channels)) {
- SDL_SetError("Invalid channel number");
- return 0;
+ return SDL_SetError("Invalid channel number");
}
e = &mix_channel[channel].effects;
}
@@ -1783,7 +1780,3 @@ int Mix_MasterVolume(int volume)
SDL_SetAtomicInt(&master_volume, volume);
return prev_volume;
}
-
-/* end of mixer.c ... */
-
-/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/mixer.h b/src/mixer.h
index 7c6edc54c..30e3966f7 100644
--- a/src/mixer.h
+++ b/src/mixer.h
@@ -28,5 +28,3 @@ extern void Mix_UnlockAudio(void);
extern void add_chunk_decoder(const char *decoder);
#endif /* MIXER_H_ */
-
-/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/music.c b/src/music.c
index 04b7ccbe4..8f630edbf 100644
--- a/src/music.c
+++ b/src/music.c
@@ -929,14 +929,12 @@ bool Mix_FadeInMusicPos(Mix_Music *music, int loops, int ms, double position)
bool retval;
if (ms_per_step == 0) {
- SDL_SetError("Audio device hasn't been opened");
- return false;
+ return SDL_SetError("Audio device hasn't been opened");
}
/* Don't play null pointers :-) */
if (music == NULL) {
- SDL_SetError("music parameter was NULL");
- return false;
+ return SDL_SetError("music parameter was NULL");
}
/* Setup the data */
@@ -1522,5 +1520,3 @@ bool Mix_EachSoundFont(Mix_EachSoundFontCallback function, void *data)
SDL_free(paths);
return (soundfonts_found > 0);
}
-
-/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/music.h b/src/music.h
index 8d356d1b9..70f2d7a02 100644
--- a/src/music.h
+++ b/src/music.h
@@ -176,5 +176,3 @@ extern void unload_music(void);
extern SDL_AudioSpec music_spec;
#endif /* MUSIC_H_ */
-
-/* vi: set ts=4 sw=4 expandtab: */