From 9d7c57234a2e518ea96c969370bbb8b8b6bc5ac1 Mon Sep 17 00:00:00 2001
From: "Ryan C. Gordon" <[EMAIL REDACTED]>
Date: Wed, 18 Oct 2023 15:35:09 -0400
Subject: [PATCH] audio: Cleaned out most remaining `/* */` comments for `//`
style.
Fully committing to it...!
This left SDL_wave.* alone for now, since there's a ton of comments in there
and this code hasn't changed much from SDL2 so far. But as SDL2 ages out a
little more, I'll likely switch this over, too.
---
build-scripts/gen_audio_channel_conversion.c | 4 +-
build-scripts/gen_audio_resampler_filter.c | 4 +-
src/audio/SDL_audio_channel_converters.h | 58 +++---
src/audio/SDL_audio_resampler_filter.h | 2 +-
src/audio/SDL_audiodev.c | 10 +-
src/audio/SDL_audiodev_c.h | 6 +-
src/audio/SDL_audioresample.c | 8 +-
src/audio/SDL_audiotypecvt.c | 177 +++++++++----------
src/audio/SDL_mixer.c | 12 +-
src/audio/aaudio/SDL_aaudio.h | 2 +-
src/audio/aaudio/SDL_aaudiofuncs.h | 26 +--
src/audio/alsa/SDL_alsa_audio.h | 8 +-
src/audio/android/SDL_androidaudio.h | 2 +-
src/audio/coreaudio/SDL_coreaudio.h | 4 +-
src/audio/coreaudio/SDL_coreaudio.m | 45 +++--
src/audio/disk/SDL_diskaudio.h | 4 +-
src/audio/dsp/SDL_dspaudio.c | 25 ++-
src/audio/dsp/SDL_dspaudio.h | 6 +-
src/audio/emscripten/SDL_emscriptenaudio.h | 2 +-
src/audio/haiku/SDL_haikuaudio.h | 2 +-
src/audio/jack/SDL_jackaudio.c | 37 ++--
src/audio/jack/SDL_jackaudio.h | 2 +-
src/audio/n3ds/SDL_n3dsaudio.h | 6 +-
src/audio/netbsd/SDL_netbsdaudio.c | 2 +-
src/audio/netbsd/SDL_netbsdaudio.h | 10 +-
src/audio/openslES/SDL_openslES.h | 2 +-
src/audio/pipewire/SDL_pipewire.c | 108 +++++------
src/audio/pipewire/SDL_pipewire.h | 4 +-
src/audio/ps2/SDL_ps2audio.h | 10 +-
src/audio/psp/SDL_pspaudio.h | 10 +-
src/audio/pulseaudio/SDL_pulseaudio.c | 109 ++++++------
src/audio/pulseaudio/SDL_pulseaudio.h | 8 +-
src/audio/qnx/SDL_qsa_audio.h | 3 +-
src/audio/sndio/SDL_sndioaudio.h | 2 +-
src/audio/vita/SDL_vitaaudio.h | 10 +-
src/audio/wasapi/SDL_wasapi.h | 6 +-
src/audio/wasapi/SDL_wasapi_win32.c | 26 +--
37 files changed, 378 insertions(+), 384 deletions(-)
diff --git a/build-scripts/gen_audio_channel_conversion.c b/build-scripts/gen_audio_channel_conversion.c
index 6c98fa3494f0..720a9e5997ce 100644
--- a/build-scripts/gen_audio_channel_conversion.c
+++ b/build-scripts/gen_audio_channel_conversion.c
@@ -269,7 +269,7 @@ static void write_converter(const int fromchans, const int tochans)
"\n", lowercase(fromstr), lowercase(tostr));
if (convert_backwards) { /* must convert backwards when growing the output in-place. */
- printf(" /* convert backwards, since output is growing in-place. */\n");
+ printf(" // convert backwards, since output is growing in-place.\n");
printf(" src += (num_frames-1)");
if (fromchans != 1) {
printf(" * %d", fromchans);
@@ -425,7 +425,7 @@ int main(void)
" 3. This notice may not be removed or altered from any source distribution.\n"
"*/\n"
"\n"
- "/* DO NOT EDIT, THIS FILE WAS GENERATED BY build-scripts/gen_audio_channel_conversion.c */\n"
+ "// DO NOT EDIT, THIS FILE WAS GENERATED BY build-scripts/gen_audio_channel_conversion.c\n"
"\n"
"\n"
"typedef void (*SDL_AudioChannelConverter)(float *dst, const float *src, int num_frames);\n"
diff --git a/build-scripts/gen_audio_resampler_filter.c b/build-scripts/gen_audio_resampler_filter.c
index 19991bd964b1..732b873d2347 100644
--- a/build-scripts/gen_audio_resampler_filter.c
+++ b/build-scripts/gen_audio_resampler_filter.c
@@ -25,7 +25,7 @@ Built with:
gcc -o genfilter build-scripts/gen_audio_resampler_filter.c -lm && ./genfilter > src/audio/SDL_audio_resampler_filter.h
- */
+*/
/*
SDL's resampler uses a "bandlimited interpolation" algorithm:
@@ -128,7 +128,7 @@ int main(void)
" 3. This notice may not be removed or altered from any source distribution.\n"
"*/\n"
"\n"
- "/* DO NOT EDIT, THIS FILE WAS GENERATED BY build-scripts/gen_audio_resampler_filter.c */\n"
+ "// DO NOT EDIT, THIS FILE WAS GENERATED BY build-scripts/gen_audio_resampler_filter.c\n"
"\n"
"#define RESAMPLER_ZERO_CROSSINGS %d\n"
"#define RESAMPLER_BITS_PER_SAMPLE %d\n"
diff --git a/src/audio/SDL_audio_channel_converters.h b/src/audio/SDL_audio_channel_converters.h
index b29046bd1788..5fe6df52fb4a 100644
--- a/src/audio/SDL_audio_channel_converters.h
+++ b/src/audio/SDL_audio_channel_converters.h
@@ -19,7 +19,7 @@
3. This notice may not be removed or altered from any source distribution.
*/
-/* DO NOT EDIT, THIS FILE WAS GENERATED BY build-scripts/gen_audio_channel_conversion.c */
+// DO NOT EDIT, THIS FILE WAS GENERATED BY build-scripts/gen_audio_channel_conversion.c
typedef void (*SDL_AudioChannelConverter)(float *dst, const float *src, int num_frames);
@@ -30,7 +30,7 @@ static void SDL_ConvertMonoToStereo(float *dst, const float *src, int num_frames
LOG_DEBUG_AUDIO_CONVERT("mono", "stereo");
- /* convert backwards, since output is growing in-place. */
+ // convert backwards, since output is growing in-place.
src += (num_frames-1);
dst += (num_frames-1) * 2;
for (i = num_frames; i; i--, src--, dst -= 2) {
@@ -47,7 +47,7 @@ static void SDL_ConvertMonoTo21(float *dst, const float *src, int num_frames)
LOG_DEBUG_AUDIO_CONVERT("mono", "2.1");
- /* convert backwards, since output is growing in-place. */
+ // convert backwards, since output is growing in-place.
src += (num_frames-1);
dst += (num_frames-1) * 3;
for (i = num_frames; i; i--, src--, dst -= 3) {
@@ -65,7 +65,7 @@ static void SDL_ConvertMonoToQuad(float *dst, const float *src, int num_frames)
LOG_DEBUG_AUDIO_CONVERT("mono", "quad");
- /* convert backwards, since output is growing in-place. */
+ // convert backwards, since output is growing in-place.
src += (num_frames-1);
dst += (num_frames-1) * 4;
for (i = num_frames; i; i--, src--, dst -= 4) {
@@ -84,7 +84,7 @@ static void SDL_ConvertMonoTo41(float *dst, const float *src, int num_frames)
LOG_DEBUG_AUDIO_CONVERT("mono", "4.1");
- /* convert backwards, since output is growing in-place. */
+ // convert backwards, since output is growing in-place.
src += (num_frames-1);
dst += (num_frames-1) * 5;
for (i = num_frames; i; i--, src--, dst -= 5) {
@@ -104,7 +104,7 @@ static void SDL_ConvertMonoTo51(float *dst, const float *src, int num_frames)
LOG_DEBUG_AUDIO_CONVERT("mono", "5.1");
- /* convert backwards, since output is growing in-place. */
+ // convert backwards, since output is growing in-place.
src += (num_frames-1);
dst += (num_frames-1) * 6;
for (i = num_frames; i; i--, src--, dst -= 6) {
@@ -125,7 +125,7 @@ static void SDL_ConvertMonoTo61(float *dst, const float *src, int num_frames)
LOG_DEBUG_AUDIO_CONVERT("mono", "6.1");
- /* convert backwards, since output is growing in-place. */
+ // convert backwards, since output is growing in-place.
src += (num_frames-1);
dst += (num_frames-1) * 7;
for (i = num_frames; i; i--, src--, dst -= 7) {
@@ -147,7 +147,7 @@ static void SDL_ConvertMonoTo71(float *dst, const float *src, int num_frames)
LOG_DEBUG_AUDIO_CONVERT("mono", "7.1");
- /* convert backwards, since output is growing in-place. */
+ // convert backwards, since output is growing in-place.
src += (num_frames-1);
dst += (num_frames-1) * 8;
for (i = num_frames; i; i--, src--, dst -= 8) {
@@ -182,7 +182,7 @@ static void SDL_ConvertStereoTo21(float *dst, const float *src, int num_frames)
LOG_DEBUG_AUDIO_CONVERT("stereo", "2.1");
- /* convert backwards, since output is growing in-place. */
+ // convert backwards, since output is growing in-place.
src += (num_frames-1) * 2;
dst += (num_frames-1) * 3;
for (i = num_frames; i; i--, src -= 2, dst -= 3) {
@@ -199,7 +199,7 @@ static void SDL_ConvertStereoToQuad(float *dst, const float *src, int num_frames
LOG_DEBUG_AUDIO_CONVERT("stereo", "quad");
- /* convert backwards, since output is growing in-place. */
+ // convert backwards, since output is growing in-place.
src += (num_frames-1) * 2;
dst += (num_frames-1) * 4;
for (i = num_frames; i; i--, src -= 2, dst -= 4) {
@@ -217,7 +217,7 @@ static void SDL_ConvertStereoTo41(float *dst, const float *src, int num_frames)
LOG_DEBUG_AUDIO_CONVERT("stereo", "4.1");
- /* convert backwards, since output is growing in-place. */
+ // convert backwards, since output is growing in-place.
src += (num_frames-1) * 2;
dst += (num_frames-1) * 5;
for (i = num_frames; i; i--, src -= 2, dst -= 5) {
@@ -236,7 +236,7 @@ static void SDL_ConvertStereoTo51(float *dst, const float *src, int num_frames)
LOG_DEBUG_AUDIO_CONVERT("stereo", "5.1");
- /* convert backwards, since output is growing in-place. */
+ // convert backwards, since output is growing in-place.
src += (num_frames-1) * 2;
dst += (num_frames-1) * 6;
for (i = num_frames; i; i--, src -= 2, dst -= 6) {
@@ -256,7 +256,7 @@ static void SDL_ConvertStereoTo61(float *dst, const float *src, int num_frames)
LOG_DEBUG_AUDIO_CONVERT("stereo", "6.1");
- /* convert backwards, since output is growing in-place. */
+ // convert backwards, since output is growing in-place.
src += (num_frames-1) * 2;
dst += (num_frames-1) * 7;
for (i = num_frames; i; i--, src -= 2, dst -= 7) {
@@ -277,7 +277,7 @@ static void SDL_ConvertStereoTo71(float *dst, const float *src, int num_frames)
LOG_DEBUG_AUDIO_CONVERT("stereo", "7.1");
- /* convert backwards, since output is growing in-place. */
+ // convert backwards, since output is growing in-place.
src += (num_frames-1) * 2;
dst += (num_frames-1) * 8;
for (i = num_frames; i; i--, src -= 2, dst -= 8) {
@@ -325,7 +325,7 @@ static void SDL_Convert21ToQuad(float *dst, const float *src, int num_frames)
LOG_DEBUG_AUDIO_CONVERT("2.1", "quad");
- /* convert backwards, since output is growing in-place. */
+ // convert backwards, since output is growing in-place.
src += (num_frames-1) * 3;
dst += (num_frames-1) * 4;
for (i = num_frames; i; i--, src -= 3, dst -= 4) {
@@ -344,7 +344,7 @@ static void SDL_Convert21To41(float *dst, const float *src, int num_frames)
LOG_DEBUG_AUDIO_CONVERT("2.1", "4.1");
- /* convert backwards, since output is growing in-place. */
+ // convert backwards, since output is growing in-place.
src += (num_frames-1) * 3;
dst += (num_frames-1) * 5;
for (i = num_frames; i; i--, src -= 3, dst -= 5) {
@@ -363,7 +363,7 @@ static void SDL_Convert21To51(float *dst, const float *src, int num_frames)
LOG_DEBUG_AUDIO_CONVERT("2.1", "5.1");
- /* convert backwards, since output is growing in-place. */
+ // convert backwards, since output is growing in-place.
src += (num_frames-1) * 3;
dst += (num_frames-1) * 6;
for (i = num_frames; i; i--, src -= 3, dst -= 6) {
@@ -383,7 +383,7 @@ static void SDL_Convert21To61(float *dst, const float *src, int num_frames)
LOG_DEBUG_AUDIO_CONVERT("2.1", "6.1");
- /* convert backwards, since output is growing in-place. */
+ // convert backwards, since output is growing in-place.
src += (num_frames-1) * 3;
dst += (num_frames-1) * 7;
for (i = num_frames; i; i--, src -= 3, dst -= 7) {
@@ -404,7 +404,7 @@ static void SDL_Convert21To71(float *dst, const float *src, int num_frames)
LOG_DEBUG_AUDIO_CONVERT("2.1", "7.1");
- /* convert backwards, since output is growing in-place. */
+ // convert backwards, since output is growing in-place.
src += (num_frames-1) * 3;
dst += (num_frames-1) * 8;
for (i = num_frames; i; i--, src -= 3, dst -= 8) {
@@ -469,7 +469,7 @@ static void SDL_ConvertQuadTo41(float *dst, const float *src, int num_frames)
LOG_DEBUG_AUDIO_CONVERT("quad", "4.1");
- /* convert backwards, since output is growing in-place. */
+ // convert backwards, since output is growing in-place.
src += (num_frames-1) * 4;
dst += (num_frames-1) * 5;
for (i = num_frames; i; i--, src -= 4, dst -= 5) {
@@ -488,7 +488,7 @@ static void SDL_ConvertQuadTo51(float *dst, const float *src, int num_frames)
LOG_DEBUG_AUDIO_CONVERT("quad", "5.1");
- /* convert backwards, since output is growing in-place. */
+ // convert backwards, since output is growing in-place.
src += (num_frames-1) * 4;
dst += (num_frames-1) * 6;
for (i = num_frames; i; i--, src -= 4, dst -= 6) {
@@ -508,7 +508,7 @@ static void SDL_ConvertQuadTo61(float *dst, const float *src, int num_frames)
LOG_DEBUG_AUDIO_CONVERT("quad", "6.1");
- /* convert backwards, since output is growing in-place. */
+ // convert backwards, since output is growing in-place.
src += (num_frames-1) * 4;
dst += (num_frames-1) * 7;
for (i = num_frames; i; i--, src -= 4, dst -= 7) {
@@ -531,7 +531,7 @@ static void SDL_ConvertQuadTo71(float *dst, const float *src, int num_frames)
LOG_DEBUG_AUDIO_CONVERT("quad", "7.1");
- /* convert backwards, since output is growing in-place. */
+ // convert backwards, since output is growing in-place.
src += (num_frames-1) * 4;
dst += (num_frames-1) * 8;
for (i = num_frames; i; i--, src -= 4, dst -= 8) {
@@ -613,7 +613,7 @@ static void SDL_Convert41To51(float *dst, const float *src, int num_frames)
LOG_DEBUG_AUDIO_CONVERT("4.1", "5.1");
- /* convert backwards, since output is growing in-place. */
+ // convert backwards, since output is growing in-place.
src += (num_frames-1) * 5;
dst += (num_frames-1) * 6;
for (i = num_frames; i; i--, src -= 5, dst -= 6) {
@@ -633,7 +633,7 @@ static void SDL_Convert41To61(float *dst, const float *src, int num_frames)
LOG_DEBUG_AUDIO_CONVERT("4.1", "6.1");
- /* convert backwards, since output is growing in-place. */
+ // convert backwards, since output is growing in-place.
src += (num_frames-1) * 5;
dst += (num_frames-1) * 7;
for (i = num_frames; i; i--, src -= 5, dst -= 7) {
@@ -656,7 +656,7 @@ static void SDL_Convert41To71(float *dst, const float *src, int num_frames)
LOG_DEBUG_AUDIO_CONVERT("4.1", "7.1");
- /* convert backwards, since output is growing in-place. */
+ // convert backwards, since output is growing in-place.
src += (num_frames-1) * 5;
dst += (num_frames-1) * 8;
for (i = num_frames; i; i--, src -= 5, dst -= 8) {
@@ -758,7 +758,7 @@ static void SDL_Convert51To61(float *dst, const float *src, int num_frames)
LOG_DEBUG_AUDIO_CONVERT("5.1", "6.1");
- /* convert backwards, since output is growing in-place. */
+ // convert backwards, since output is growing in-place.
src += (num_frames-1) * 6;
dst += (num_frames-1) * 7;
for (i = num_frames; i; i--, src -= 6, dst -= 7) {
@@ -781,7 +781,7 @@ static void SDL_Convert51To71(float *dst, const float *src, int num_frames)
LOG_DEBUG_AUDIO_CONVERT("5.1", "7.1");
- /* convert backwards, since output is growing in-place. */
+ // convert backwards, since output is growing in-place.
src += (num_frames-1) * 6;
dst += (num_frames-1) * 8;
for (i = num_frames; i; i--, src -= 6, dst -= 8) {
@@ -911,7 +911,7 @@ static void SDL_Convert61To71(float *dst, const float *src, int num_frames)
LOG_DEBUG_AUDIO_CONVERT("6.1", "7.1");
- /* convert backwards, since output is growing in-place. */
+ // convert backwards, since output is growing in-place.
src += (num_frames-1) * 7;
dst += (num_frames-1) * 8;
for (i = num_frames; i; i--, src -= 7, dst -= 8) {
diff --git a/src/audio/SDL_audio_resampler_filter.h b/src/audio/SDL_audio_resampler_filter.h
index 1ea9c33ddec2..42e4666506c5 100644
--- a/src/audio/SDL_audio_resampler_filter.h
+++ b/src/audio/SDL_audio_resampler_filter.h
@@ -19,7 +19,7 @@
3. This notice may not be removed or altered from any source distribution.
*/
-/* DO NOT EDIT, THIS FILE WAS GENERATED BY build-scripts/gen_audio_resampler_filter.c */
+// DO NOT EDIT, THIS FILE WAS GENERATED BY build-scripts/gen_audio_resampler_filter.c
#define RESAMPLER_ZERO_CROSSINGS 5
#define RESAMPLER_BITS_PER_SAMPLE 16
diff --git a/src/audio/SDL_audiodev.c b/src/audio/SDL_audiodev.c
index 9d73fbb55cec..f00b8590dd5e 100644
--- a/src/audio/SDL_audiodev.c
+++ b/src/audio/SDL_audiodev.c
@@ -20,14 +20,14 @@
*/
#include "SDL_internal.h"
-/* Get the name of the audio device we use for output */
+// Get the name of the audio device we use for output
#if defined(SDL_AUDIO_DRIVER_NETBSD) || defined(SDL_AUDIO_DRIVER_OSS)
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
-#include <unistd.h> /* For close() */
+#include <unistd.h> // For close()
#include "SDL_audiodev_c.h"
@@ -84,7 +84,7 @@ static void SDL_EnumUnixAudioDevices_Internal(const SDL_bool iscapture, const SD
test = test_stub;
}
- /* Figure out what our audio device is */
+ // Figure out what our audio device is
audiodev = SDL_getenv("SDL_PATH_DSP");
if (audiodev == NULL) {
audiodev = SDL_getenv("AUDIODEV");
@@ -95,7 +95,7 @@ static void SDL_EnumUnixAudioDevices_Internal(const SDL_bool iscapture, const SD
} else {
struct stat sb;
- /* Added support for /dev/sound/\* in Linux 2.4 */
+ // Added support for /dev/sound/\* in Linux 2.4
if (((stat("/dev/sound", &sb) == 0) && S_ISDIR(sb.st_mode)) && ((stat(SDL_PATH_DEV_DSP24, &sb) == 0) && S_ISCHR(sb.st_mode))) {
audiodev = SDL_PATH_DEV_DSP24;
} else {
@@ -122,4 +122,4 @@ void SDL_EnumUnixAudioDevices(const SDL_bool classic, SDL_bool (*test)(int))
SDL_EnumUnixAudioDevices_Internal(SDL_FALSE, classic, test);
}
-#endif /* Audio driver selection */
+#endif // Audio device selection
diff --git a/src/audio/SDL_audiodev_c.h b/src/audio/SDL_audiodev_c.h
index 6301d07c54ba..53d451fc10bd 100644
--- a/src/audio/SDL_audiodev_c.h
+++ b/src/audio/SDL_audiodev_c.h
@@ -25,8 +25,8 @@
#include "SDL_internal.h"
#include "SDL_sysaudio.h"
-/* Open the audio device for playback, and don't block if busy */
-/* #define USE_BLOCKING_WRITES */
+// Open the audio device for playback, and don't block if busy
+//#define USE_BLOCKING_WRITES
#ifdef USE_BLOCKING_WRITES
#define OPEN_FLAGS_OUTPUT O_WRONLY
@@ -38,4 +38,4 @@
extern void SDL_EnumUnixAudioDevices(const SDL_bool classic, SDL_bool (*test)(int));
-#endif /* SDL_audiodev_c_h_ */
+#endif // SDL_audiodev_c_h_
diff --git a/src/audio/SDL_audioresample.c b/src/audio/SDL_audioresample.c
index 6e3f40327232..a357fab9e306 100644
--- a/src/audio/SDL_audioresample.c
+++ b/src/audio/SDL_audioresample.c
@@ -23,13 +23,13 @@
#include "SDL_sysaudio.h"
#include "SDL_audioresample.h"
-/* SDL's resampler uses a "bandlimited interpolation" algorithm:
- https://ccrma.stanford.edu/~jos/resample/ */
+// SDL's resampler uses a "bandlimited interpolation" algorithm:
+// https://ccrma.stanford.edu/~jos/resample/
#include "SDL_audio_resampler_filter.h"
-/* For a given srcpos, `srcpos + frame` are sampled, where `-RESAMPLER_ZERO_CROSSINGS < frame <= RESAMPLER_ZERO_CROSSINGS`.
- * Note, when upsampling, it is also possible to start sampling from `srcpos = -1`. */
+// For a given srcpos, `srcpos + frame` are sampled, where `-RESAMPLER_ZERO_CROSSINGS < frame <= RESAMPLER_ZERO_CROSSINGS`.
+// Note, when upsampling, it is also possible to start sampling from `srcpos = -1`.
#define RESAMPLER_MAX_PADDING_FRAMES (RESAMPLER_ZERO_CROSSINGS + 1)
#define RESAMPLER_FILTER_INTERP_BITS (32 - RESAMPLER_BITS_PER_ZERO_CROSSING)
diff --git a/src/audio/SDL_audiotypecvt.c b/src/audio/SDL_audiotypecvt.c
index a8fb65427f5e..deabeee474b9 100644
--- a/src/audio/SDL_audiotypecvt.c
+++ b/src/audio/SDL_audiotypecvt.c
@@ -22,32 +22,31 @@
#include "SDL_audio_c.h"
-/* TODO: NEON is disabled until https://github.com/libsdl-org/SDL/issues/8352
- * can be fixed */
+// TODO: NEON is disabled until https://github.com/libsdl-org/SDL/issues/8352 can be fixed
#undef SDL_NEON_INTRINSICS
#ifndef SDL_CPUINFO_DISABLED
#if defined(__x86_64__) && defined(SDL_SSE2_INTRINSICS)
-#define NEED_SCALAR_CONVERTER_FALLBACKS 0 /* x86_64 guarantees SSE2. */
+#define NEED_SCALAR_CONVERTER_FALLBACKS 0 // x86_64 guarantees SSE2.
#elif defined(__MACOS__) && defined(SDL_SSE2_INTRINSICS)
-#define NEED_SCALAR_CONVERTER_FALLBACKS 0 /* macOS/Intel guarantees SSE2. */
+#define NEED_SCALAR_CONVERTER_FALLBACKS 0 // macOS/Intel guarantees SSE2.
#elif defined(__ARM_ARCH) && (__ARM_ARCH >= 8) && defined(SDL_NEON_INTRINSICS)
-#define NEED_SCALAR_CONVERTER_FALLBACKS 0 /* ARMv8+ promise NEON. */
+#define NEED_SCALAR_CONVERTER_FALLBACKS 0 // ARMv8+ promise NEON.
#elif defined(__APPLE__) && defined(__ARM_ARCH) && (__ARM_ARCH >= 7) && defined(SDL_NEON_INTRINSICS)
-#define NEED_SCALAR_CONVERTER_FALLBACKS 0 /* All Apple ARMv7 chips promise NEON support. */
+#define NEED_SCALAR_CONVERTER_FALLBACKS 0 // All Apple ARMv7 chips promise NEON support.
#endif
#endif
-/* Set to zero if platform is guaranteed to use a SIMD codepath here. */
+// Set to zero if platform is guaranteed to use a SIMD codepath here.
#if !defined(NEED_SCALAR_CONVERTER_FALLBACKS) || defined(SDL_CPUINFO_DISABLED)
#define NEED_SCALAR_CONVERTER_FALLBACKS 1
#endif
-#define DIVBY2147483648 0.0000000004656612873077392578125f /* 0x1p-31f */
+#define DIVBY2147483648 0.0000000004656612873077392578125f // 0x1p-31f
#if NEED_SCALAR_CONVERTER_FALLBACKS
-/* This code requires that floats are in the IEEE-754 binary32 format */
+// This code requires that floats are in the IEEE-754 binary32 format
SDL_COMPILE_TIME_ASSERT(float_bits, sizeof(float) == sizeof(Uint32));
union float_bits {
@@ -111,7 +110,7 @@ static void SDL_Convert_S32_to_F32_Scalar(float *dst, const Sint32 *src, int num
}
}
-/* Create a bit-mask based on the sign-bit. Should optimize to a single arithmetic-shift-right */
+// Create a bit-mask based on the sign-bit. Should optimize to a single arithmetic-shift-right
#define SIGNMASK(x) (Uint32)(0u - ((Uint32)(x) >> 31))
static void SDL_Convert_F32_to_S8_Scalar(Sint8 *dst, const float *src, int num_samples)
@@ -202,7 +201,7 @@ static void SDL_Convert_F32_to_S32_Scalar(Sint32 *dst, const float *src, int num
#undef SIGNMASK
-#endif /* NEED_SCALAR_CONVERTER_FALLBACKS */
+#endif // NEED_SCALAR_CONVERTER_FALLBACKS
#ifdef SDL_SSE2_INTRINSICS
static void SDL_TARGETING("sse2") SDL_Convert_S8_to_F32_SSE2(float *dst, const Sint8 *src, int num_samples)
@@ -324,7 +323,7 @@ static void SDL_TARGETING("sse2") SDL_Convert_S32_to_F32_SSE2(float *dst, const
{
int i = num_samples;
- /* dst[i] = f32(src[i]) / f32(0x80000000) */
+ // dst[i] = f32(src[i]) / f32(0x80000000)
const __m128 scaler = _mm_set1_ps(DIVBY2147483648);
LOG_DEBUG_AUDIO_CONVERT("S32", "F32 (using SSE2)");
@@ -543,9 +542,9 @@ static void SDL_TARGETING("sse2") SDL_Convert_F32_to_S32_SSE2(Sint32 *dst, const
#endif
#ifdef SDL_NEON_INTRINSICS
-#define DIVBY128 0.0078125f /* 0x1p-7f */
-#define DIVBY32768 0.000030517578125f /* 0x1p-15f */
-#define DIVBY8388607 0.00000011920930376163766f /* 0x1.000002p-23f */
+#define DIVBY128 0.0078125f // 0x1p-7f
+#define DIVBY32768 0.000030517578125f // 0x1p-15f
+#define DIVBY8388607 0.00000011920930376163766f // 0x1.000002p-23f
static void SDL_Convert_S8_to_F32_NEON(float *dst, const Sint8 *src, int num_samples)
{
@@ -556,25 +555,25 @@ static void SDL_Convert_S8_to_F32_NEON(float *dst, const Sint8 *src, int num_sam
src += num_samples - 1;
dst += num_samples - 1;
- /* Get dst aligned to 16 bytes (since buffer is growing, we don't have to worry about overreading from src) */
+ // Get dst aligned to 16 bytes (since buffer is growing, we don't have to worry about overreading from src)
for (i = num_samples; i && (((size_t)(dst - 15)) & 15); --i, --src, --dst) {
*dst = ((float)*src) * DIVBY128;
}
src -= 15;
- dst -= 15; /* adjust to read NEON blocks from the start. */
+ dst -= 15; // adjust to read NEON blocks from the start.
SDL_assert(!i || !(((size_t)dst) & 15));
- /* Make sure src is aligned too. */
+ // Make sure src is aligned too.
if (!(((size_t)src) & 15)) {
- /* Aligned! Do NEON blocks as long as we have 16 bytes available. */
+ // Aligned! Do NEON blocks as long as we have 16 bytes available.
const int8_t *mmsrc = (const int8_t *)src;
const float32x4_t divby128 = vdupq_n_f32(DIVBY128);
- while (i >= 16) { /* 16 * 8-bit */
- const int8x16_t bytes = vld1q_s8(mmsrc); /* get 16 sint8 into a NEON register. */
- const int16x8_t int16hi = vmovl_s8(vget_high_s8(bytes)); /* convert top 8 bytes to 8 int16 */
- const int16x8_t int16lo = vmovl_s8(vget_low_s8(bytes)); /* convert bottom 8 bytes to 8 int16 */
- /* split int16 to two int32, then convert to float, then multiply to normalize, store. */
+ while (i >= 16) { // 16 * 8-bit
+ const int8x16_t bytes = vld1q_s8(mmsrc); // get 16 sint8 into a NEON register.
+ const int16x8_t int16hi = vmovl_s8(vget_high_s8(bytes)); // convert top 8 bytes to 8 int16
+ const int16x8_t int16lo = vmovl_s8(vget_low_s8(bytes)); // convert bottom 8 bytes to 8 int16
+ // split int16 to two int32, then convert to float, then multiply to normalize, store.
vst1q_f32(dst, vmulq_f32(vcvtq_f32_s32(vmovl_s16(vget_low_s16(int16lo))), divby128));
vst1q_f32(dst + 4, vmulq_f32(vcvtq_f32_s32(vmovl_s16(vget_high_s16(int16lo))), divby128));
vst1q_f32(dst + 8, vmulq_f32(vcvtq_f32_s32(vmovl_s16(vget_low_s16(int16hi))), divby128));
@@ -588,9 +587,9 @@ static void SDL_Convert_S8_to_F32_NEON(float *dst, const Sint8 *src, int num_sam
}
src += 15;
- dst += 15; /* adjust for any scalar finishing. */
+ dst += 15; // adjust for any scalar finishing.
- /* Finish off any leftovers with scalar operations. */
+ // Finish off any leftovers with scalar operations.
while (i) {
*dst = ((float)*src) * DIVBY128;
i--;
@@ -608,26 +607,26 @@ static void SDL_Convert_U8_to_F32_NEON(float *dst, const Uint8 *src, int num_sam
src += num_samples - 1;
dst += num_samples - 1;
- /* Get dst aligned to 16 bytes (since buffer is growing, we don't have to worry about overreading from src) */
+ // Get dst aligned to 16 bytes (since buffer is growing, we don't have to worry about overreading from src)
for (i = num_samples; i && (((size_t)(dst - 15)) & 15); --i, --src, --dst) {
*dst = (((float)*src) * DIVBY128) - 1.0f;
}
src -= 15;
- dst -= 15; /* adjust to read NEON blocks from the start. */
+ dst -= 15; // adjust to read NEON blocks from the start.
SDL_assert(!i || !(((size_t)dst) & 15));
- /* Make sure src is aligned too. */
+ // Make sure src is aligned too.
if (!(((size_t)src) & 15)) {
- /* Aligned! Do NEON blocks as long as we have 16 bytes available. */
+ // Aligned! Do NEON blocks as long as we have 16 bytes available.
const uint8_t *mmsrc = (const uint8_t *)src;
const float32x4_t divby128 = vdupq_n_f32(DIVBY128);
const float32x4_t negone = vdupq_n_f32(-1.0f);
- while (i >= 16) { /* 16 * 8-bit */
- const uint8x16_t bytes = vld1q_u8(mmsrc); /* get 16 uint8 into a NEON register. */
- const uint16x8_t uint16hi = vmovl_u8(vget_high_u8(bytes)); /* convert top 8 bytes to 8 uint16 */
- const uint16x8_t uint16lo = vmovl_u8(vget_low_u8(bytes)); /* convert bottom 8 bytes to 8 uint16 */
- /* split uint16 to two uint32, then convert to float, then multiply to normalize, subtract to adjust for sign, store. */
+ while (i >= 16) { // 16 * 8-bit
+ const uint8x16_t bytes = vld1q_u8(mmsrc); // get 16 uint8 into a NEON register.
+ const uint16x8_t uint16hi = vmovl_u8(vget_high_u8(bytes)); // convert top 8 bytes to 8 uint16
+ const uint16x8_t uint16lo = vmovl_u8(vget_low_u8(bytes)); // convert bottom 8 bytes to 8 uint16
+ // split uint16 to two uint32, then convert to float, then multiply to normalize, subtract to adjust for sign, store.
vst1q_f32(dst, vmlaq_f32(negone, vcvtq_f32_u32(vmovl_u16(vget_low_u16(uint16lo))), divby128));
vst1q_f32(dst + 4, vmlaq_f32(negone, vcvtq_f32_u32(vmovl_u16(vget_high_u16(uint16lo))), divby128));
vst1q_f32(dst + 8, vmlaq_f32(negone, vcvtq_f32_u32(vmovl_u16(vget_low_u16(uint16hi))), divby128));
@@ -641,9 +640,9 @@ static void SDL_Convert_U8_to_F32_NEON(float *dst, const Uint8 *src, int num_sam
}
src += 15;
- dst += 15; /* adjust for any scalar finishing. */
+ dst += 15; // adjust for any scalar finishing.
- /* Finish off any leftovers with scalar operations. */
+ // Finish off any leftovers with scalar operations.
while (i) {
*dst = (((float)*src) * DIVBY128) - 1.0f;
i--;
@@ -661,22 +660,22 @@ static void SDL_Convert_S16_to_F32_NEON(float *dst, const Sint16 *src, int num_s
src += num_samples - 1;
dst += num_samples - 1;
- /* Get dst aligned to 16 bytes (since buffer is growing, we don't have to worry about overreading from src) */
+ // Get dst aligned to 16 bytes (since buffer is growing, we don't have to worry about overreading from src)
for (i = num_samples; i && (((size_t)(dst - 7)) & 15); --i, --src, --dst) {
*dst = ((float)*src) * DIVBY32768;
}
src -= 7;
- dst -= 7; /* adjust to read NEON blocks from the start. */
+ dst -= 7; // adjust to read NEON blocks from the start.
SDL_assert(!i || !(((size_t)dst) & 15));
- /* Make sure src is aligned too. */
+ // Make sure src is aligned too.
if (!(((size_t)src) & 15)) {
- /* Aligned! Do NEON blocks as long as we have 16 bytes available. */
+ // Aligned! Do NEON blocks as long as we have 16 bytes available.
const float32x4_t divby32768 = vdupq_n_f32(DIVBY32768);
- while (i >= 8) { /* 8 * 16-bit */
- const int16x8_t ints = vld1q_s16((int16_t const *)src); /* get 8 sint16 into a NEON register. */
- /* split int16 to two int32, then convert to float, then multiply to normalize, store. */
+ while (i >= 8) { // 8 * 16-bit
+ const int16x8_t ints = vld1q_s16((int16_t const *)src); // get 8 sint16 into a NEON register.
+ // split int16 to two int32, then convert to float, then multiply to normalize, store.
vst
(Patch may be truncated, please check the link at the top of this post.)