From 9d7c57234a2e518ea96c969370bbb8b8b6bc5ac1 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" 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 6c98fa349..720a9e599 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 19991bd96..732b873d2 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 b29046bd1..5fe6df52f 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 1ea9c33dd..42e466650 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 9d73fbb55..f00b8590d 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 #include #include -#include /* For close() */ +#include // 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 6301d07c5..53d451fc1 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 6e3f40327..a357fab9e 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 a8fb65427..deabeee47 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. vst1q_f32(dst, vmulq_f32(vcvtq_f32_s32(vmovl_s16(vget_low_s16(ints))), divby32768)); vst1q_f32(dst + 4, vmulq_f32(vcvtq_f32_s32(vmovl_s16(vget_high_s16(ints))), divby32768)); i -= 8; @@ -686,9 +685,9 @@ static void SDL_Convert_S16_to_F32_NEON(float *dst, const Sint16 *src, int num_s } src += 7; - dst += 7; /* adjust for any scalar finishing. */ + dst += 7; // adjust for any scalar finishing. - /* Finish off any leftovers with scalar operations. */ + // Finish off any leftovers with scalar operations. while (i) { *dst = ((float)*src) * DIVBY32768; i--; @@ -703,20 +702,20 @@ static void SDL_Convert_S32_to_F32_NEON(float *dst, const Sint32 *src, int num_s LOG_DEBUG_AUDIO_CONVERT("S32", "F32 (using NEON)"); - /* Get dst aligned to 16 bytes */ + // Get dst aligned to 16 bytes for (i = num_samples; i && (((size_t)dst) & 15); --i, ++src, ++dst) { *dst = ((float)(*src >> 8)) * DIVBY8388607; } 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 divby8388607 = vdupq_n_f32(DIVBY8388607); const int32_t *mmsrc = (const int32_t *)src; - while (i >= 4) { /* 4 * sint32 */ - /* shift out lowest bits so int fits in a float32. Small precision loss, but much faster. */ + while (i >= 4) { // 4 * sint32 + // shift out lowest bits so int fits in a float32. Small precision loss, but much faster. vst1q_f32(dst, vmulq_f32(vcvtq_f32_s32(vshrq_n_s32(vld1q_s32(mmsrc), 8)), divby8388607)); i -= 4; mmsrc += 4; @@ -725,7 +724,7 @@ static void SDL_Convert_S32_to_F32_NEON(float *dst, const Sint32 *src, int num_s src = (const Sint32 *)mmsrc; } - /* Finish off any leftovers with scalar operations. */ + // Finish off any leftovers with scalar operations. while (i) { *dst = ((float)(*src >> 8)) * DIVBY8388607; i--; @@ -740,7 +739,7 @@ static void SDL_Convert_F32_to_S8_NEON(Sint8 *dst, const float *src, int num_sam LOG_DEBUG_AUDIO_CONVERT("F32", "S8 (using NEON)"); - /* Get dst aligned to 16 bytes */ + // Get dst aligned to 16 bytes for (i = num_samples; i && (((size_t)dst) & 15); --i, ++src, ++dst) { const float sample = *src; if (sample >= 1.0f) { @@ -754,21 +753,21 @@ static void SDL_Convert_F32_to_S8_NEON(Sint8 *dst, const float *src, int num_sam 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 one = vdupq_n_f32(1.0f); const float32x4_t negone = vdupq_n_f32(-1.0f); const float32x4_t mulby127 = vdupq_n_f32(127.0f); int8_t *mmdst = (int8_t *)dst; - while (i >= 16) { /* 16 * float32 */ - const int32x4_t ints1 = vcvtq_s32_f32(vmulq_f32(vminq_f32(vmaxq_f32(negone, vld1q_f32(src)), one), mulby127)); /* load 4 floats, clamp, convert to sint32 */ - const int32x4_t ints2 = vcvtq_s32_f32(vmulq_f32(vminq_f32(vmaxq_f32(negone, vld1q_f32(src + 4)), one), mulby127)); /* load 4 floats, clamp, convert to sint32 */ - const int32x4_t ints3 = vcvtq_s32_f32(vmulq_f32(vminq_f32(vmaxq_f32(negone, vld1q_f32(src + 8)), one), mulby127)); /* load 4 floats, clamp, convert to sint32 */ - const int32x4_t ints4 = vcvtq_s32_f32(vmulq_f32(vminq_f32(vmaxq_f32(negone, vld1q_f32(src + 12)), one), mulby127)); /* load 4 floats, clamp, convert to sint32 */ - const int8x8_t i8lo = vmovn_s16(vcombine_s16(vmovn_s32(ints1), vmovn_s32(ints2))); /* narrow to sint16, combine, narrow to sint8 */ - const int8x8_t i8hi = vmovn_s16(vcombine_s16(vmovn_s32(ints3), vmovn_s32(ints4))); /* narrow to sint16, combine, narrow to sint8 */ - vst1q_s8(mmdst, vcombine_s8(i8lo, i8hi)); /* combine to int8x16_t, store out */ + while (i >= 16) { // 16 * float32 + const int32x4_t ints1 = vcvtq_s32_f32(vmulq_f32(vminq_f32(vmaxq_f32(negone, vld1q_f32(src)), one), mulby127)); // load 4 floats, clamp, convert to sint32 + const int32x4_t ints2 = vcvtq_s32_f32(vmulq_f32(vminq_f32(vmaxq_f32(negone, vld1q_f32(src + 4)), one), mulby127)); // load 4 floats, clamp, convert to sint32 + const int32x4_t ints3 = vcvtq_s32_f32(vmulq_f32(vminq_f32(vmaxq_f32(negone, vld1q_f32(src + 8)), one), mulby127)); // load 4 floats, clamp, convert to sint32 + const int32x4_t ints4 = vcvtq_s32_f32(vmulq_f32(vminq_f32(vmaxq_f32(negone, vld1q_f32(src + 12)), one), mulby127)); // load 4 floats, clamp, convert to sint32 + const int8x8_t i8lo = vmovn_s16(vcombine_s16(vmovn_s32(ints1), vmovn_s32(ints2))); // narrow to sint16, combine, narrow to sint8 + const int8x8_t i8hi = vmovn_s16(vcombine_s16(vmovn_s32(ints3), vmovn_s32(ints4))); // narrow to sint16, combine, narrow to sint8 + vst1q_s8(mmdst, vcombine_s8(i8lo, i8hi)); // combine to int8x16_t, store out i -= 16; src += 16; mmdst += 16; @@ -776,7 +775,7 @@ static void SDL_Convert_F32_to_S8_NEON(Sint8 *dst, const float *src, int num_sam dst = (Sint8 *)mmdst; } - /* Finish off any leftovers with scalar operations. */ + // Finish off any leftovers with scalar operations. while (i) { const float sample = *src; if (sample >= 1.0f) { @@ -798,7 +797,7 @@ static void SDL_Convert_F32_to_U8_NEON(Uint8 *dst, const float *src, int num_sam LOG_DEBUG_AUDIO_CONVERT("F32", "U8 (using NEON)"); - /* Get dst aligned to 16 bytes */ + // Get dst aligned to 16 bytes for (i = num_samples; i && (((size_t)dst) & 15); --i, ++src, ++dst) { const float sample = *src; if (sample >= 1.0f) { @@ -812,21 +811,21 @@ static void SDL_Convert_F32_to_U8_NEON(Uint8 *dst, const float *src, int num_sam 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 one = vdupq_n_f32(1.0f); const float32x4_t negone = vdupq_n_f32(-1.0f); const float32x4_t mulby127 = vdupq_n_f32(127.0f); uint8_t *mmdst = (uint8_t *)dst; - while (i >= 16) { /* 16 * float32 */ - const uint32x4_t uints1 = vcvtq_u32_f32(vmulq_f32(vaddq_f32(vminq_f32(vmaxq_f32(negone, vld1q_f32(src)), one), one), mulby127)); /* load 4 floats, clamp, convert to uint32 */ - const uint32x4_t uints2 = vcvtq_u32_f32(vmulq_f32(vaddq_f32(vminq_f32(vmaxq_f32(negone, vld1q_f32(src + 4)), one), one), mulby127)); /* load 4 floats, clamp, convert to uint32 */ - const uint32x4_t uints3 = vcvtq_u32_f32(vmulq_f32(vaddq_f32(vminq_f32(vmaxq_f32(negone, vld1q_f32(src + 8)), one), one), mulby127)); /* load 4 floats, clamp, convert to uint32 */ - const uint32x4_t uints4 = vcvtq_u32_f32(vmulq_f32(vaddq_f32(vminq_f32(vmaxq_f32(negone, vld1q_f32(src + 12)), one), one), mulby127)); /* load 4 floats, clamp, convert to uint32 */ - const uint8x8_t ui8lo = vmovn_u16(vcombine_u16(vmovn_u32(uints1), vmovn_u32(uints2))); /* narrow to uint16, combine, narrow to uint8 */ - const uint8x8_t ui8hi = vmovn_u16(vcombine_u16(vmovn_u32(uints3), vmovn_u32(uints4))); /* narrow to uint16, combine, narrow to uint8 */ - vst1q_u8(mmdst, vcombine_u8(ui8lo, ui8hi)); /* combine to uint8x16_t, store out */ + while (i >= 16) { // 16 * float32 + const uint32x4_t uints1 = vcvtq_u32_f32(vmulq_f32(vaddq_f32(vminq_f32(vmaxq_f32(negone, vld1q_f32(src)), one), one), mulby127)); // load 4 floats, clamp, convert to uint32 + const uint32x4_t uints2 = vcvtq_u32_f32(vmulq_f32(vaddq_f32(vminq_f32(vmaxq_f32(negone, vld1q_f32(src + 4)), one), one), mulby127)); // load 4 floats, clamp, convert to uint32 + const uint32x4_t uints3 = vcvtq_u32_f32(vmulq_f32(vaddq_f32(vminq_f32(vmaxq_f32(negone, vld1q_f32(src + 8)), one), one), mulby127)); // load 4 floats, clamp, convert to uint32 + const uint32x4_t uints4 = vcvtq_u32_f32(vmulq_f32(vaddq_f32(vminq_f32(vmaxq_f32(negone, vld1q_f32(src + 12)), one), one), mulby127)); // load 4 floats, clamp, convert to uint32 + const uint8x8_t ui8lo = vmovn_u16(vcombine_u16(vmovn_u32(uints1), vmovn_u32(uints2))); // narrow to uint16, combine, narrow to uint8 + const uint8x8_t ui8hi = vmovn_u16(vcombine_u16(vmovn_u32(uints3), vmovn_u32(uints4))); // narrow to uint16, combine, narrow to uint8 + vst1q_u8(mmdst, vcombine_u8(ui8lo, ui8hi)); // combine to uint8x16_t, store out i -= 16; src += 16; mmdst += 16; @@ -835,7 +834,7 @@ static void SDL_Convert_F32_to_U8_NEON(Uint8 *dst, const float *src, int num_sam dst = (Uint8 *)mmdst; } - /* Finish off any leftovers with scalar operations. */ + // Finish off any leftovers with scalar operations. while (i) { const float sample = *src; if (sample >= 1.0f) { @@ -857,7 +856,7 @@ static void SDL_Convert_F32_to_S16_NEON(Sint16 *dst, const float *src, int num_s LOG_DEBUG_AUDIO_CONVERT("F32", "S16 (using NEON)"); - /* Get dst aligned to 16 bytes */ + // Get dst aligned to 16 bytes for (i = num_samples; i && (((size_t)dst) & 15); --i, ++src, ++dst) { const float sample = *src; if (sample >= 1.0f) { @@ -871,17 +870,17 @@ static void SDL_Convert_F32_to_S16_NEON(Sint16 *dst, const float *src, int num_s 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 one = vdupq_n_f32(1.0f); const float32x4_t negone = vdupq_n_f32(-1.0f); const float32x4_t mulby32767 = vdupq_n_f32(32767.0f); int16_t *mmdst = (int16_t *)dst; - while (i >= 8) { /* 8 * float32 */ - const int32x4_t ints1 = vcvtq_s32_f32(vmulq_f32(vminq_f32(vmaxq_f32(negone, vld1q_f32(src)), one), mulby32767)); /* load 4 floats, clamp, convert to sint32 */ - const int32x4_t ints2 = vcvtq_s32_f32(vmulq_f32(vminq_f32(vmaxq_f32(negone, vld1q_f32(src + 4)), one), mulby32767)); /* load 4 floats, clamp, convert to sint32 */ - vst1q_s16(mmdst, vcombine_s16(vmovn_s32(ints1), vmovn_s32(ints2))); /* narrow to sint16, combine, store out. */ + while (i >= 8) { // 8 * float32 + const int32x4_t ints1 = vcvtq_s32_f32(vmulq_f32(vminq_f32(vmaxq_f32(negone, vld1q_f32(src)), one), mulby32767)); // load 4 floats, clamp, convert to sint32 + const int32x4_t ints2 = vcvtq_s32_f32(vmulq_f32(vminq_f32(vmaxq_f32(negone, vld1q_f32(src + 4)), one), mulby32767)); // load 4 floats, clamp, convert to sint32 + vst1q_s16(mmdst, vcombine_s16(vmovn_s32(ints1), vmovn_s32(ints2))); // narrow to sint16, combine, store out. i -= 8; src += 8; mmdst += 8; @@ -889,7 +888,7 @@ static void SDL_Convert_F32_to_S16_NEON(Sint16 *dst, const float *src, int num_s dst = (Sint16 *)mmdst; } - /* Finish off any leftovers with scalar operations. */ + // Finish off any leftovers with scalar operations. while (i) { const float sample = *src; if (sample >= 1.0f) { @@ -911,7 +910,7 @@ static void SDL_Convert_F32_to_S32_NEON(Sint32 *dst, const float *src, int num_s LOG_DEBUG_AUDIO_CONVERT("F32", "S32 (using NEON)"); - /* Get dst aligned to 16 bytes */ + // Get dst aligned to 16 bytes for (i = num_samples; i && (((size_t)dst) & 15); --i, ++src, ++dst) { const float sample = *src; if (sample >= 1.0f) { @@ -927,12 +926,12 @@ static void SDL_Convert_F32_to_S32_NEON(Sint32 *dst, const float *src, int num_s SDL_assert(!i || !(((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 one = vdupq_n_f32(1.0f); const float32x4_t negone = vdupq_n_f32(-1.0f); const float32x4_t mulby8388607 = vdupq_n_f32(8388607.0f); int32_t *mmdst = (int32_t *)dst; - while (i >= 4) { /* 4 * float32 */ + while (i >= 4) { // 4 * float32 vst1q_s32(mmdst, vshlq_n_s32(vcvtq_s32_f32(vmulq_f32(vminq_f32(vmaxq_f32(negone, vld1q_f32(src)), one), mulby8388607)), 8)); i -= 4; src += 4; @@ -941,7 +940,7 @@ static void SDL_Convert_F32_to_S32_NEON(Sint32 *dst, const float *src, int num_s dst = (Sint32 *)mmdst; } - /* Finish off any leftovers with scalar operations. */ + // Finish off any leftovers with scalar operations. while (i) { const float sample = *src; if (sample >= 1.0f) { @@ -958,7 +957,7 @@ static void SDL_Convert_F32_to_S32_NEON(Sint32 *dst, const float *src, int num_s } #endif -/* Function pointers set to a CPU-specific implementation. */ +// Function pointers set to a CPU-specific implementation. void (*SDL_Convert_S8_to_F32)(float *dst, const Sint8 *src, int num_samples) = NULL; void (*SDL_Convert_U8_to_F32)(float *dst, const Uint8 *src, int num_samples) = NULL; void (*SDL_Convert_S16_to_F32)(float *dst, const Sint16 *src, int num_samples) = NULL; diff --git a/src/audio/SDL_mixer.c b/src/audio/SDL_mixer.c index 0a4992d82..30b099346 100644 --- a/src/audio/SDL_mixer.c +++ b/src/audio/SDL_mixer.c @@ -20,7 +20,7 @@ */ #include "SDL_internal.h" -/* This provides the default mixing callback for the SDL audio routines */ +// This provides the default mixing callback for the SDL audio routines #include "SDL_sysaudio.h" @@ -77,12 +77,12 @@ static const Uint8 mix8[] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; -/* The volume ranges from 0 - 128 */ +// The volume ranges from 0 - 128 #define ADJUST_VOLUME(type, s, v) ((s) = (type)(((s) * (v)) / SDL_MIX_MAXVOLUME)) #define ADJUST_VOLUME_U8(s, v) ((s) = (Uint8)(((((s) - 128) * (v)) / SDL_MIX_MAXVOLUME) + 128)) -/* !!! FIXME: this needs some SIMD magic. */ +// !!! FIXME: this needs some SIMD magic. int SDL_MixAudioFormat(Uint8 *dst, const Uint8 *src, SDL_AudioFormat format, Uint32 len, int volume) @@ -237,7 +237,7 @@ int SDL_MixAudioFormat(Uint8 *dst, const Uint8 *src, SDL_AudioFormat format, float *dst32 = (float *)dst; float src1, src2; double dst_sample; - /* !!! FIXME: are these right? */ + // !!! FIXME: are these right? const double max_audioval = 3.402823466e+38F; const double min_audioval = -3.402823466e+38F; @@ -265,7 +265,7 @@ int SDL_MixAudioFormat(Uint8 *dst, const Uint8 *src, SDL_AudioFormat format, float *dst32 = (float *)dst; float src1, src2; double dst_sample; - /* !!! FIXME: are these right? */ + // !!! FIXME: are these right? const double max_audioval = 3.402823466e+38F; const double min_audioval = -3.402823466e+38F; @@ -285,7 +285,7 @@ int SDL_MixAudioFormat(Uint8 *dst, const Uint8 *src, SDL_AudioFormat format, } } break; - default: /* If this happens... FIXME! */ + default: // If this happens... FIXME! return SDL_SetError("SDL_MixAudioFormat(): unknown audio format"); } diff --git a/src/audio/aaudio/SDL_aaudio.h b/src/audio/aaudio/SDL_aaudio.h index b866f2ede..61cce54cf 100644 --- a/src/audio/aaudio/SDL_aaudio.h +++ b/src/audio/aaudio/SDL_aaudio.h @@ -35,4 +35,4 @@ void AAUDIO_PauseDevices(void); #endif -#endif /* SDL_aaudio_h_ */ +#endif // SDL_aaudio_h_ diff --git a/src/audio/aaudio/SDL_aaudiofuncs.h b/src/audio/aaudio/SDL_aaudiofuncs.h index febbb89da..0fba87d1e 100644 --- a/src/audio/aaudio/SDL_aaudiofuncs.h +++ b/src/audio/aaudio/SDL_aaudiofuncs.h @@ -33,18 +33,18 @@ SDL_PROC_UNUSED(void, AAudioStreamBuilder_setSharingMode, (AAudioStreamBuilder * SDL_PROC(void, AAudioStreamBuilder_setDirection, (AAudioStreamBuilder * builder, aaudio_direction_t direction)) SDL_PROC_UNUSED(void, AAudioStreamBuilder_setBufferCapacityInFrames, (AAudioStreamBuilder * builder, int32_t numFrames)) SDL_PROC(void, AAudioStreamBuilder_setPerformanceMode, (AAudioStreamBuilder * builder, aaudio_performance_mode_t mode)) -SDL_PROC_UNUSED(void, AAudioStreamBuilder_setUsage, (AAudioStreamBuilder * builder, aaudio_usage_t usage)) /* API 28 */ -SDL_PROC_UNUSED(void, AAudioStreamBuilder_setContentType, (AAudioStreamBuilder * builder, aaudio_content_type_t contentType)) /* API 28 */ -SDL_PROC_UNUSED(void, AAudioStreamBuilder_setInputPreset, (AAudioStreamBuilder * builder, aaudio_input_preset_t inputPreset)) /* API 28 */ -SDL_PROC_UNUSED(void, AAudioStreamBuilder_setAllowedCapturePolicy, (AAudioStreamBuilder * builder, aaudio_allowed_capture_policy_t capturePolicy)) /* API 29 */ -SDL_PROC_UNUSED(void, AAudioStreamBuilder_setSessionId, (AAudioStreamBuilder * builder, aaudio_session_id_t sessionId)) /* API 28 */ -SDL_PROC_UNUSED(void, AAudioStreamBuilder_setPrivacySensitive, (AAudioStreamBuilder * builder, bool privacySensitive)) /* API 30 */ +SDL_PROC_UNUSED(void, AAudioStreamBuilder_setUsage, (AAudioStreamBuilder * builder, aaudio_usage_t usage)) // API 28 +SDL_PROC_UNUSED(void, AAudioStreamBuilder_setContentType, (AAudioStreamBuilder * builder, aaudio_content_type_t contentType)) // API 28 +SDL_PROC_UNUSED(void, AAudioStreamBuilder_setInputPreset, (AAudioStreamBuilder * builder, aaudio_input_preset_t inputPreset)) // API 28 +SDL_PROC_UNUSED(void, AAudioStreamBuilder_setAllowedCapturePolicy, (AAudioStreamBuilder * builder, aaudio_allowed_capture_policy_t capturePolicy)) // API 29 +SDL_PROC_UNUSED(void, AAudioStreamBuilder_setSessionId, (AAudioStreamBuilder * builder, aaudio_session_id_t sessionId)) // API 28 +SDL_PROC_UNUSED(void, AAudioStreamBuilder_setPrivacySensitive, (AAudioStreamBuilder * builder, bool privacySensitive)) // API 30 SDL_PROC(void, AAudioStreamBuilder_setDataCallback, (AAudioStreamBuilder * builder, AAudioStream_dataCallback callback, void *userData)) SDL_PROC(void, AAudioStreamBuilder_setFramesPerDataCallback, (AAudioStreamBuilder * builder, int32_t numFrames)) SDL_PROC(void, AAudioStreamBuilder_setErrorCallback, (AAudioStreamBuilder * builder, AAudioStream_errorCallback callback, void *userData)) SDL_PROC(aaudio_result_t, AAudioStreamBuilder_openStream, (AAudioStreamBuilder * builder, AAudioStream **stream)) SDL_PROC(aaudio_result_t, AAudioStreamBuilder_delete, (AAudioStreamBuilder * builder)) -SDL_PROC_UNUSED(aaudio_result_t, AAudioStream_release, (AAudioStream * stream)) /* API 30 */ +SDL_PROC_UNUSED(aaudio_result_t, AAudioStream_release, (AAudioStream * stream)) // API 30 SDL_PROC(aaudio_result_t, AAudioStream_close, (AAudioStream * stream)) SDL_PROC(aaudio_result_t, AAudioStream_requestStart, (AAudioStream * stream)) SDL_PROC(aaudio_result_t, AAudioStream_requestPause, (AAudioStream * stream)) @@ -70,13 +70,13 @@ SDL_PROC_UNUSED(aaudio_performance_mode_t, AAudioStream_getPerformanceMode, (AAu SDL_PROC_UNUSED(aaudio_direction_t, AAudioStream_getDirection, (AAudioStream * stream)) SDL_PROC_UNUSED(int64_t, AAudioStream_getFramesWritten, (AAudioStream * stream)) SDL_PROC_UNUSED(int64_t, AAudioStream_getFramesRead, (AAudioStream * stream)) -SDL_PROC_UNUSED(aaudio_session_id_t, AAudioStream_getSessionId, (AAudioStream * stream)) /* API 28 */ +SDL_PROC_UNUSED(aaudio_session_id_t, AAudioStream_getSessionId, (AAudioStream * stream)) // API 28 SDL_PROC(aaudio_result_t, AAudioStream_getTimestamp, (AAudioStream * stream, clockid_t clockid, int64_t *framePosition, int64_t *timeNanoseconds)) -SDL_PROC_UNUSED(aaudio_usage_t, AAudioStream_getUsage, (AAudioStream * stream)) /* API 28 */ -SDL_PROC_UNUSED(aaudio_content_type_t, AAudioStream_getContentType, (AAudioStream * stream)) /* API 28 */ -SDL_PROC_UNUSED(aaudio_input_preset_t, AAudioStream_getInputPreset, (AAudioStream * stream)) /* API 28 */ -SDL_PROC_UNUSED(aaudio_allowed_capture_policy_t, AAudioStream_getAllowedCapturePolicy, (AAudioStream * stream)) /* API 29 */ -SDL_PROC_UNUSED(bool, AAudioStream_isPrivacySensitive, (AAudioStream * stream)) /* API 30 */ +SDL_PROC_UNUSED(aaudio_usage_t, AAudioStream_getUsage, (AAudioStream * stream)) // API 28 +SDL_PROC_UNUSED(aaudio_content_type_t, AAudioStream_getContentType, (AAudioStream * stream)) // API 28 +SDL_PROC_UNUSED(aaudio_input_preset_t, AAudioStream_getInputPreset, (AAudioStream * stream)) // API 28 +SDL_PROC_UNUSED(aaudio_allowed_capture_policy_t, AAudioStream_getAllowedCapturePolicy, (AAudioStream * stream)) // API 29 +SDL_PROC_UNUSED(bool, AAudioStream_isPrivacySensitive, (AAudioStream * stream)) // API 30 #undef SDL_PROC #undef SDL_PROC_UNUSED diff --git a/src/audio/alsa/SDL_alsa_audio.h b/src/audio/alsa/SDL_alsa_audio.h index ef7ce1bb5..2d41b3f1c 100644 --- a/src/audio/alsa/SDL_alsa_audio.h +++ b/src/audio/alsa/SDL_alsa_audio.h @@ -29,14 +29,14 @@ struct SDL_PrivateAudioData { - /* The audio device handle */ + // The audio device handle snd_pcm_t *pcm_handle; - /* Raw mixing buffer */ + // Raw mixing buffer Uint8 *mixbuf; - /* swizzle function */ + // swizzle function void (*swizzle_func)(SDL_AudioDevice *_this, void *buffer, Uint32 bufferlen); }; -#endif /* SDL_ALSA_audio_h_ */ +#endif // SDL_ALSA_audio_h_ diff --git a/src/audio/android/SDL_androidaudio.h b/src/audio/android/SDL_androidaudio.h index 759951129..5efdc419d 100644 --- a/src/audio/android/SDL_androidaudio.h +++ b/src/audio/android/SDL_androidaudio.h @@ -35,4 +35,4 @@ static void ANDROIDAUDIO_PauseDevices(void) {} #endif -#endif /* SDL_androidaudio_h_ */ +#endif // SDL_androidaudio_h_ diff --git a/src/audio/coreaudio/SDL_coreaudio.h b/src/audio/coreaudio/SDL_coreaudio.h index 4b7f81bf0..6c4891da2 100644 --- a/src/audio/coreaudio/SDL_coreaudio.h +++ b/src/audio/coreaudio/SDL_coreaudio.h @@ -39,7 +39,7 @@ #include #include -/* Things named "Master" were renamed to "Main" in macOS 12.0's SDK. */ +// Things named "Master" were renamed to "Main" in macOS 12.0's SDK. #ifdef MACOSX_COREAUDIO #include #ifndef MAC_OS_VERSION_12_0 @@ -65,4 +65,4 @@ struct SDL_PrivateAudioData #endif }; -#endif /* SDL_coreaudio_h_ */ +#endif // SDL_coreaudio_h_ diff --git a/src/audio/coreaudio/SDL_coreaudio.m b/src/audio/coreaudio/SDL_coreaudio.m index 998bda154..923eb8fe6 100644 --- a/src/audio/coreaudio/SDL_coreaudio.m +++ b/src/audio/coreaudio/SDL_coreaudio.m @@ -79,9 +79,9 @@ static OSStatus DeviceAliveNotification(AudioObjectID devid, UInt32 num_addr, co SDL_bool dead = SDL_FALSE; if (error == kAudioHardwareBadDeviceError) { - dead = SDL_TRUE; /* device was unplugged. */ + dead = SDL_TRUE; // device was unplugged. } else if ((error == kAudioHardwareNoError) && (!alive)) { - dead = SDL_TRUE; /* device died in some other way. */ + dead = SDL_TRUE; // device died in some other way. } if (dead) { @@ -263,7 +263,7 @@ static void COREAUDIO_DetectDevices(SDL_AudioDevice **default_output, SDL_AudioD AudioObjectAddPropertyListener(kAudioObjectSystemObject, &devlist_address, DeviceListChangedNotification, NULL); - /* Get the Device ID */ + // Get the Device ID UInt32 size; AudioDeviceID devid; @@ -428,7 +428,7 @@ static SDL_bool UpdateAudioSession(SDL_AudioDevice *device, SDL_bool open, SDL_b /* AVAudioSessionCategoryOptionAllowBluetooth isn't available in the SDK for Apple TV but is still needed in order to output to Bluetooth devices. */ - options |= 0x4; /* AVAudioSessionCategoryOptionAllowBluetooth; */ + options |= 0x4; // AVAudioSessionCategoryOptionAllowBluetooth; } if (category == AVAudioSessionCategoryPlayAndRecord) { options |= AVAudioSessionCategoryOptionAllowBluetoothA2DP | @@ -441,7 +441,7 @@ static SDL_bool UpdateAudioSession(SDL_AudioDevice *device, SDL_bool open, SDL_b if ([session respondsToSelector:@selector(setCategory:mode:options:error:)]) { if (![session.category isEqualToString:category] || session.categoryOptions != options) { - /* Stop the current session so we don't interrupt other application audio */ + // Stop the current session so we don't interrupt other application audio PauseAudioDevices(); [session setActive:NO error:nil]; session_active = SDL_FALSE; @@ -454,7 +454,7 @@ static SDL_bool UpdateAudioSession(SDL_AudioDevice *device, SDL_bool open, SDL_b } } else { if (![session.category isEqualToString:category]) { - /* Stop the current session so we don't interrupt other application audio */ + // Stop the current session so we don't interrupt other application audio PauseAudioDevices(); [session setActive:NO error:nil]; session_active = SDL_FALSE; @@ -498,7 +498,7 @@ static SDL_bool UpdateAudioSession(SDL_AudioDevice *device, SDL_bool open, SDL_b /* An interruption end notification is not guaranteed to be sent if we were previously interrupted... resuming if needed when the app becomes active seems to be the way to go. */ - // Note: object: below needs to be nil, as otherwise it filters by the object, and session doesn't send foreground / active notifications. johna + // Note: object: below needs to be nil, as otherwise it filters by the object, and session doesn't send foreground / active notifications. [center addObserver:listener selector:@selector(applicationBecameActive:) name:UIApplicationDidBecomeActiveNotification @@ -717,7 +717,7 @@ static int PrepareAudioQueue(SDL_AudioDevice *device) SDL_UpdatedAudioDeviceFormat(device); // make sure this is correct. - /* Set the channel layout for the audio queue */ + // Set the channel layout for the audio queue AudioChannelLayout layout; SDL_zero(layout); switch (device->spec.channels) { @@ -740,7 +740,7 @@ static int PrepareAudioQueue(SDL_AudioDevice *device) layout.mChannelLayoutTag = kAudioChannelLayoutTag_MPEG_5_1_A; break; case 7: - /* FIXME: Need to move channel[4] (BC) to channel[6] */ + // FIXME: Need to move channel[4] (BC) to channel[6] layout.mChannelLayoutTag = kAudioChannelLayoutTag_MPEG_6_1_A; break; case 8: @@ -763,7 +763,7 @@ static int PrepareAudioQueue(SDL_AudioDevice *device) int numAudioBuffers = 2; const double msecs = (device->sample_frames / ((double)device->spec.freq)) * 1000.0; - if (msecs < MINIMUM_AUDIO_BUFFER_TIME_MS) { /* use more buffers if we have a VERY small sample set. */ + if (msecs < MINIMUM_AUDIO_BUFFER_TIME_MS) { // use more buffers if we have a VERY small sample set. numAudioBuffers = ((int)SDL_ceil(MINIMUM_AUDIO_BUFFER_TIME_MS / msecs) * 2); } @@ -782,7 +782,7 @@ static int PrepareAudioQueue(SDL_AudioDevice *device) CHECK_RESULT("AudioQueueAllocateBuffer"); SDL_memset(device->hidden->audioBuffer[i]->mAudioData, device->silence_value, device->hidden->audioBuffer[i]->mAudioDataBytesCapacity); device->hidden->audioBuffer[i]->mAudioDataByteSize = device->hidden->audioBuffer[i]->mAudioDataBytesCapacity; - /* !!! FIXME: should we use AudioQueueEnqueueBufferWithParameters and specify all frames be "trimmed" so these are immediately ready to refill with SDL callback data? */ + // !!! FIXME: should we use AudioQueueEnqueueBufferWithParameters and specify all frames be "trimmed" so these are immediately ready to refill with SDL callback data? result = AudioQueueEnqueueBuffer(device->hidden->audioQueue, device->hidden->audioBuffer[i], 0, NULL); CHECK_RESULT("AudioQueueEnqueueBuffer"); } @@ -831,7 +831,7 @@ static int AudioQueueThreadEntry(void *arg) static int COREAUDIO_OpenDevice(SDL_AudioDevice *device) { - /* Initialize all variables that we clean on shutdown */ + // Initialize all variables that we clean on shutdown device->hidden = (struct SDL_PrivateAudioData *)SDL_calloc(1, sizeof(*device->hidden)); if (device->hidden == NULL) { return SDL_OutOfMemory(); @@ -842,7 +842,7 @@ static int COREAUDIO_OpenDevice(SDL_AudioDevice *device) return -1; } - /* Stop CoreAudio from doing expensive audio rate conversion */ + // Stop CoreAudio from doing expensive audio rate conversion @autoreleasepool { AVAudioSession *session = [AVAudioSession sharedInstance]; [session setPreferredSampleRate:device->spec.freq error:nil]; @@ -856,12 +856,12 @@ static int COREAUDIO_OpenDevice(SDL_AudioDevice *device) device->spec.channels = session.preferredOutputNumberOfChannels; } #else - /* Calling setPreferredOutputNumberOfChannels seems to break audio output on iOS */ - #endif /* TARGET_OS_TV */ + // Calling setPreferredOutputNumberOfChannels seems to break audio output on iOS + #endif // TARGET_OS_TV } #endif - /* Setup a AudioStreamBasicDescription with the requested format */ + // Setup a AudioStreamBasicDescription with the requested format AudioStreamBasicDescription *strdesc = &device->hidden->strdesc; strdesc->mFormatID = kAudioFormatLinearPCM; strdesc->mFormatFlags = kLinearPCMFormatFlagIsPacked; @@ -872,7 +872,7 @@ static int COREAUDIO_OpenDevice(SDL_AudioDevice *device) const SDL_AudioFormat *closefmts = SDL_ClosestAudioFormats(device->spec.format); SDL_AudioFormat test_format; while ((test_format = *(closefmts++)) != 0) { - /* CoreAudio handles most of SDL's formats natively. */ + // CoreAudio handles most of SDL's formats natively. switch (test_format) { case SDL_AUDIO_U8: case SDL_AUDIO_S8: @@ -890,7 +890,7 @@ static int COREAUDIO_OpenDevice(SDL_AudioDevice *device) break; } - if (!test_format) { /* shouldn't happen, but just in case... */ + if (!test_format) { // shouldn't happen, but just in case... return SDL_SetError("%s: Unsupported audio format", "coreaudio"); } device->spec.format = test_format; @@ -914,10 +914,10 @@ static int COREAUDIO_OpenDevice(SDL_AudioDevice *device) } #endif - /* This has to init in a new thread so it can get its own CFRunLoop. :/ */ + // This has to init in a new thread so it can get its own CFRunLoop. :/ device->hidden->ready_semaphore = SDL_CreateSemaphore(0); if (!device->hidden->ready_semaphore) { - return -1; /* oh well. */ + return -1; // oh well. } char threadname[64]; @@ -951,7 +951,6 @@ static void COREAUDIO_DeinitializeStart(void) static SDL_bool COREAUDIO_Init(SDL_AudioDriverImpl *impl) { - /* Set the function pointers */ impl->OpenDevice = COREAUDIO_OpenDevice; impl->PlayDevice = COREAUDIO_PlayDevice; impl->GetDeviceBuf = COREAUDIO_GetDeviceBuf; @@ -971,11 +970,11 @@ static SDL_bool COREAUDIO_Init(SDL_AudioDriverImpl *impl) impl->ProvidesOwnCallbackThread = SDL_TRUE; impl->HasCaptureSupport = SDL_TRUE; - return SDL_TRUE; /* this audio target is available. */ + return SDL_TRUE; } AudioBootStrap COREAUDIO_bootstrap = { "coreaudio", "CoreAudio", COREAUDIO_Init, SDL_FALSE }; -#endif /* SDL_AUDIO_DRIVER_COREAUDIO */ +#endif // SDL_AUDIO_DRIVER_COREAUDIO diff --git a/src/audio/disk/SDL_diskaudio.h b/src/audio/disk/SDL_diskaudio.h index bdc734bdf..97930b0b1 100644 --- a/src/audio/disk/SDL_diskaudio.h +++ b/src/audio/disk/SDL_diskaudio.h @@ -27,10 +27,10 @@ struct SDL_PrivateAudioData { - /* The file descriptor for the audio device */ + // The file descriptor for the audio device SDL_RWops *io; Uint32 io_delay; Uint8 *mixbuf; }; -#endif /* SDL_diskaudio_h_ */ +#endif // SDL_diskaudio_h_ diff --git a/src/audio/dsp/SDL_dspaudio.c b/src/audio/dsp/SDL_dspaudio.c index b75b6d9f2..22d3923d7 100644 --- a/src/audio/dsp/SDL_dspaudio.c +++ b/src/audio/dsp/SDL_dspaudio.c @@ -24,8 +24,8 @@ #ifdef SDL_AUDIO_DRIVER_OSS -#include /* For perror() */ -#include /* For strerror() */ +#include // For perror() +#include // For strerror() #include #include #include @@ -97,7 +97,7 @@ static int DSP_OpenDevice(SDL_AudioDevice *device) return SDL_SetError("Couldn't get audio format list"); } - /* Try for a closest match on audio format */ + // Try for a closest match on audio format int format = 0; SDL_AudioFormat test_format; const SDL_AudioFormat *closefmts = SDL_ClosestAudioFormats(device->spec.format); @@ -156,7 +156,7 @@ static int DSP_OpenDevice(SDL_AudioDevice *device) } device->spec.freq = value; - /* Calculate the final parameters for this audio specification */ + // Calculate the final parameters for this audio specification SDL_UpdatedAudioDeviceFormat(device); /* Determine the power of two of the fragment size @@ -168,9 +168,9 @@ static int DSP_OpenDevice(SDL_AudioDevice *device) while ((0x01U << frag_spec) < device->buffer_size) { frag_spec++; } - frag_spec |= 0x00020000; /* two fragments, for low latency */ + frag_spec |= 0x00020000; // two fragments, for low latency - /* Set the audio buffering parameters */ + // Set the audio buffering parameters #ifdef DEBUG_AUDIO fprintf(stderr, "Requesting %d fragments of size %d\n", (frag_spec >> 16), 1 << (frag_spec & 0xFFFF)); @@ -189,7 +189,7 @@ static int DSP_OpenDevice(SDL_AudioDevice *device) } #endif - /* Allocate mixing buffer */ + // Allocate mixing buffer if (!device->iscapture) { device->hidden->mixbuf = (Uint8 *)SDL_malloc(device->buffer_size); if (device->hidden->mixbuf == NULL) { @@ -269,8 +269,8 @@ static void DSP_FlushCapture(SDL_AudioDevice *device) static SDL_bool InitTimeDevicesExist = SDL_FALSE; static SDL_bool look_for_devices_test(int fd) { - InitTimeDevicesExist = SDL_TRUE; /* note that _something_ exists. */ - /* Don't add to the device list, we're just seeing if any devices exist. */ + InitTimeDevicesExist = SDL_TRUE; // note that _something_ exists. + // Don't add to the device list, we're just seeing if any devices exist. return SDL_FALSE; } @@ -280,10 +280,9 @@ static SDL_bool DSP_Init(SDL_AudioDriverImpl *impl) SDL_EnumUnixAudioDevices(SDL_FALSE, look_for_devices_test); if (!InitTimeDevicesExist) { SDL_SetError("dsp: No such audio device"); - return SDL_FALSE; /* maybe try a different backend. */ + return SDL_FALSE; // maybe try a different backend. } - /* Set the function pointers */ impl->DetectDevices = DSP_DetectDevices; impl->OpenDevice = DSP_OpenDevice; impl->WaitDevice = DSP_WaitDevice; @@ -296,11 +295,11 @@ static SDL_bool DSP_Init(SDL_AudioDriverImpl *impl) impl->HasCaptureSupport = SDL_TRUE; - return SDL_TRUE; /* this audio target is available. */ + return SDL_TRUE; } AudioBootStrap DSP_bootstrap = { "dsp", "Open Sound System (/dev/dsp)", DSP_Init, SDL_FALSE }; -#endif /* SDL_AUDIO_DRIVER_OSS */ +#endif // SDL_AUDIO_DRIVER_OSS diff --git a/src/audio/dsp/SDL_dspaudio.h b/src/audio/dsp/SDL_dspaudio.h index abe0c347d..00d329be5 100644 --- a/src/audio/dsp/SDL_dspaudio.h +++ b/src/audio/dsp/SDL_dspaudio.h @@ -27,11 +27,11 @@ struct SDL_PrivateAudioData { - /* The file descriptor for the audio device */ + // The file descriptor for the audio device int audio_fd; - /* Raw mixing buffer */ + // Raw mixing buffer Uint8 *mixbuf; }; -#endif /* SDL_dspaudio_h_ */ +#endif // SDL_dspaudio_h_ diff --git a/src/audio/emscripten/SDL_emscriptenaudio.h b/src/audio/emscripten/SDL_emscriptenaudio.h index cc2f49b27..89a08a965 100644 --- a/src/audio/emscripten/SDL_emscriptenaudio.h +++ b/src/audio/emscripten/SDL_emscriptenaudio.h @@ -30,4 +30,4 @@ struct SDL_PrivateAudioData Uint8 *mixbuf; }; -#endif /* SDL_emscriptenaudio_h_ */ +#endif // SDL_emscriptenaudio_h_ diff --git a/src/audio/haiku/SDL_haikuaudio.h b/src/audio/haiku/SDL_haikuaudio.h index c78c6061d..9187ef642 100644 --- a/src/audio/haiku/SDL_haikuaudio.h +++ b/src/audio/haiku/SDL_haikuaudio.h @@ -32,4 +32,4 @@ struct SDL_PrivateAudioData int current_buffer_len; }; -#endif /* SDL_haikuaudio_h_ */ +#endif // SDL_haikuaudio_h_ diff --git a/src/audio/jack/SDL_jackaudio.c b/src/audio/jack/SDL_jackaudio.c index 4f0691bc3..1521eb697 100644 --- a/src/audio/jack/SDL_jackaudio.c +++ b/src/audio/jack/SDL_jackaudio.c @@ -53,19 +53,19 @@ static int load_jack_syms(void); static const char *jack_library = SDL_AUDIO_DRIVER_JACK_DYNAMIC; static void *jack_handle = NULL; -/* !!! FIXME: this is copy/pasted in several places now */ +// !!! FIXME: this is copy/pasted in several places now static int load_jack_sym(const char *fn, void **addr) { *addr = SDL_LoadFunction(jack_handle, fn); if (*addr == NULL) { - /* Don't call SDL_SetError(): SDL_LoadFunction already did. */ + // Don't call SDL_SetError(): SDL_LoadFunction already did. return 0; } return 1; } -/* cast funcs to char* first, to please GCC's strict aliasing rules. */ +// cast funcs to char* first, to please GCC's strict aliasing rules. #define SDL_JACK_SYM(x) \ if (!load_jack_sym(#x, (void **)(char *)&JACK_##x)) \ return -1 @@ -85,7 +85,7 @@ static int LoadJackLibrary(void) jack_handle = SDL_LoadObject(jack_library); if (jack_handle == NULL) { retval = -1; - /* Don't call SDL_SetError(): SDL_LoadObject already did. */ + // Don't call SDL_SetError(): SDL_LoadObject already did. } else { retval = load_jack_syms(); if (retval < 0) { @@ -110,7 +110,7 @@ static int LoadJackLibrary(void) return 0; } -#endif /* SDL_AUDIO_DRIVER_JACK_DYNAMIC */ +#endif // SDL_AUDIO_DRIVER_JACK_DYNAMIC static int load_jack_syms(void) { @@ -137,7 +137,7 @@ static int load_jack_syms(void) return 0; } -static void jackShutdownCallback(void *arg) /* JACK went away; device is lost. */ +static void jackShutdownCallback(void *arg) // JACK went away; device is lost. { SDL_AudioDeviceDisconnected((SDL_AudioDevice *)arg); } @@ -294,7 +294,7 @@ static int JACK_OpenDevice(SDL_AudioDevice *device) int ports = 0; int i; - /* Initialize all variables that we clean on shutdown */ + // Initialize all variables that we clean on shutdown device->hidden = (struct SDL_PrivateAudioData *)SDL_calloc(1, sizeof(*device->hidden)); if (device->hidden == NULL) { return SDL_OutOfMemory(); @@ -314,16 +314,16 @@ static int JACK_OpenDevice(SDL_AudioDevice *device) } while (devports[++ports]) { - /* spin to count devports */ + // spin to count devports } - /* Filter out non-audio ports */ + // Filter out non-audio ports audio_ports = SDL_calloc(ports, sizeof(*audio_ports)); for (i = 0; i < ports; i++) { const jack_port_t *dport = JACK_jack_port_by_name(client, devports[i]); const char *type = JACK_jack_port_type(dport); const int len = SDL_strlen(type); - /* See if type ends with "audio" */ + // See if type ends with "audio" if (len >= 5 && !SDL_memcmp(type + len - 5, "audio", 5)) { audio_ports[channels++] = i; } @@ -335,7 +335,7 @@ static int JACK_OpenDevice(SDL_AudioDevice *device) /* !!! FIXME: docs say about buffer size: "This size may change, clients that depend on it must register a bufsize_callback so they will be notified if it does." */ - /* Jack pretty much demands what it wants. */ + // Jack pretty much demands what it wants. device->spec.format = SDL_AUDIO_F32; device->spec.freq = JACK_jack_get_sample_rate(client); device->spec.channels = channels; @@ -351,7 +351,7 @@ static int JACK_OpenDevice(SDL_AudioDevice *device) } } - /* Build SDL's ports, which we will connect to the device ports. */ + // Build SDL's ports, which we will connect to the device ports. device->hidden->sdlports = (jack_port_t **)SDL_calloc(channels, sizeof(jack_port_t *)); if (device->hidden->sdlports == NULL) { SDL_free(audio_ports); @@ -386,7 +386,7 @@ static int JACK_OpenDevice(SDL_AudioDevice *device) return SDL_SetError("Failed to activate JACK client"); } - /* once activated, we can connect all the ports. */ + // once activated, we can connect all the ports. for (i = 0; i < channels; i++) { const char *sdlport = JACK_jack_port_name(device->hidden->sdlports[i]); const char *srcport = iscapture ? devports[audio_ports[i]] : sdlport; @@ -397,11 +397,11 @@ static int JACK_OpenDevice(SDL_AudioDevice *device) } } - /* don't need these anymore. */ + // don't need these anymore. JACK_jack_free(devports); SDL_free(audio_ports); - /* We're ready to rock and roll. :-) */ + // We're ready to rock and roll. :-) return 0; } @@ -415,7 +415,7 @@ static SDL_bool JACK_Init(SDL_AudioDriverImpl *impl) if (LoadJackLibrary() < 0) { return SDL_FALSE; } else { - /* Make sure a JACK server is running and available. */ + // Make sure a JACK server is running and available. jack_status_t status; jack_client_t *client = JACK_jack_client_open("SDL", JackNoStartServer, &status, NULL); if (client == NULL) { @@ -425,7 +425,6 @@ static SDL_bool JACK_Init(SDL_AudioDriverImpl *impl) JACK_jack_client_close(client); } - /* Set the function pointers */ impl->OpenDevice = JACK_OpenDevice; impl->GetDeviceBuf = JACK_GetDeviceBuf; impl->PlayDevice = JACK_PlayDevice; @@ -438,11 +437,11 @@ static SDL_bool JACK_Init(SDL_AudioDriverImpl *impl) impl->HasCaptureSupport = SDL_TRUE; impl->ProvidesOwnCallbackThread = SDL_TRUE; - return SDL_TRUE; /* this audio target is available. */ + return SDL_TRUE; } AudioBootStrap JACK_bootstrap = { "jack", "JACK Audio Connection Kit", JACK_Init, SDL_FALSE }; -#endif /* SDL_AUDIO_DRIVER_JACK */ +#endif // SDL_AUDIO_DRIVER_JACK diff --git a/src/audio/jack/SDL_jackaudio.h b/src/audio/jack/SDL_jackaudio.h index a8cf81d4f..9a9d082f8 100644 --- a/src/audio/jack/SDL_jackaudio.h +++ b/src/audio/jack/SDL_jackaudio.h @@ -32,4 +32,4 @@ struct SDL_PrivateAudioData float *iobuffer; }; -#endif /* SDL_jackaudio_h_ */ +#endif // SDL_jackaudio_h_ diff --git a/src/audio/n3ds/SDL_n3dsaudio.h b/src/audio/n3ds/SDL_n3dsaudio.h index 83f9ca83c..eb47ab19e 100644 --- a/src/audio/n3ds/SDL_n3dsaudio.h +++ b/src/audio/n3ds/SDL_n3dsaudio.h @@ -24,11 +24,11 @@ #include <3ds.h> -#define NUM_BUFFERS 2 /* -- Don't lower this! */ +#define NUM_BUFFERS 2 // -- Don't lower this! struct SDL_PrivateAudioData { - /* Speaker data */ + // Speaker data Uint8 *mixbuf; Uint32 nextbuf; ndspWaveBuf waveBuf[NUM_BUFFERS]; @@ -37,4 +37,4 @@ struct SDL_PrivateAudioData SDL_bool isCancelled; }; -#endif /* SDL_n3dsaudio_h */ +#endif // SDL_n3dsaudio_h diff --git a/src/audio/netbsd/SDL_netbsdaudio.c b/src/audio/netbsd/SDL_netbsdaudio.c index 0340bfb23..4aba643a6 100644 --- a/src/audio/netbsd/SDL_netbsdaudio.c +++ b/src/audio/netbsd/SDL_netbsdaudio.c @@ -135,7 +135,7 @@ static int NETBSDAUDIO_WaitDevice(SDL_AudioDevice *device) } else if (iscapture && (remain < device->buffer_size)) { SDL_Delay(10); } else { - break; /* ready to go! */ + break; // ready to go! } } diff --git a/src/audio/netbsd/SDL_netbsdaudio.h b/src/audio/netbsd/SDL_netbsdaudio.h index 9c1d93c52..72bbacfe9 100644 --- a/src/audio/netbsd/SDL_netbsdaudio.h +++ b/src/audio/netbsd/SDL_netbsdaudio.h @@ -27,18 +27,18 @@ struct SDL_PrivateAudioData { - /* The file descriptor for the audio device */ + // The file descriptor for the audio device int audio_fd; - /* Raw mixing buffer */ + // Raw mixing buffer Uint8 *mixbuf; int mixlen; - /* Support for audio timing using a timer, in addition to SDL_IOReady() */ + // Support for audio timing using a timer, in addition to SDL_IOReady() float frame_ticks; float next_frame; }; -#define FUDGE_TICKS 10 /* The scheduler overhead ticks per frame */ +#define FUDGE_TICKS 10 // The scheduler overhead ticks per frame -#endif /* SDL_netbsdaudio_h_ */ +#endif // SDL_netbsdaudio_h_ diff --git a/src/audio/openslES/SDL_openslES.h b/src/audio/openslES/SDL_openslES.h index 74d0da445..a13e11129 100644 --- a/src/audio/openslES/SDL_openslES.h +++ b/src/audio/openslES/SDL_openslES.h @@ -35,4 +35,4 @@ static void OPENSLES_PauseDevices(void) {} #endif -#endif /* SDL_openslesaudio_h_ */ +#endif // SDL_openslesaudio_h_ diff --git a/src/audio/pipewire/SDL_pipewire.c b/src/audio/pipewire/SDL_pipewire.c index b5cbbe74c..9c46d770b 100644 --- a/src/audio/pipewire/SDL_pipewire.c +++ b/src/audio/pipewire/SDL_pipewire.c @@ -63,7 +63,7 @@ * This seems to be a sane lower limit as Pipewire * uses it in several of it's own modules. */ -#define PW_MIN_SAMPLES 32 /* About 0.67ms at 48kHz */ +#define PW_MIN_SAMPLES 32 // About 0.67ms at 48kHz #define PW_BASE_CLOCK_RATE 48000 #define PW_POD_BUFFER_LENGTH 1024 @@ -82,7 +82,7 @@ enum PW_READY_FLAGS static SDL_bool pipewire_initialized = SDL_FALSE; -/* Pipewire entry points */ +// Pipewire entry points static const char *(*PIPEWIRE_pw_get_library_version)(void); static void (*PIPEWIRE_pw_init)(int *, char ***); static void (*PIPEWIRE_pw_deinit)(void); @@ -127,7 +127,7 @@ static int pipewire_dlsym(const char *fn, void **addr) { *addr = SDL_LoadFunction(pipewire_handle, fn); if (*addr == NULL) { - /* Don't call SDL_SetError(): SDL_LoadFunction already did. */ + // Don't call SDL_SetError(): SDL_LoadFunction already did. return 0; } @@ -163,10 +163,11 @@ static int load_pipewire_library(void) } static void unload_pipewire_library(void) -{ /* Nothing to do */ +{ + // Nothing to do } -#endif /* SDL_AUDIO_DRIVER_PIPEWIRE_DYNAMIC */ +#endif // SDL_AUDIO_DRIVER_PIPEWIRE_DYNAMIC static int load_pipewire_syms(void) { @@ -220,7 +221,7 @@ static int init_pipewire_library(void) return -1; } - /* SDL can build against 0.3.20, but requires 0.3.24 */ + // SDL can build against 0.3.20, but requires 0.3.24 if (pipewire_version_at_least(0, 3, 24)) { PIPEWIRE_pw_init(NULL, NULL); return 0; @@ -237,7 +238,7 @@ static void deinit_pipewire_library(void) unload_pipewire_library(); } -/* A generic Pipewire node object used for enumeration. */ +// A generic Pipewire node object used for enumeration. struct node_object { struct spa_list link; @@ -260,7 +261,7 @@ struct node_object struct spa_hook core_listener; }; -/* A sink/source node used for stream I/O. */ +// A sink/source node used for stream I/O. struct io_node { struct spa_list link; @@ -269,13 +270,13 @@ struct io_node SDL_bool is_capture; SDL_AudioSpec spec; - const char *name; /* Friendly name */ - const char *path; /* OS identifier (i.e. ALSA endpoint) */ + const char *name; // Friendly name + const char *path; // OS identifier (i.e. ALSA endpoint) - char buf[]; /* Buffer to hold the name and path strings. */ + char buf[]; // Buffer to hold the name and path strings. }; -/* The global hotplug thread and associated objects. */ +// The global hotplug thread and associated objects. static struct pw_thread_loop *hotplug_loop; static struct pw_core *hotplug_core; static struct pw_context *hotplug_context; @@ -291,13 +292,13 @@ static SDL_bool hotplug_events_enabled; static char *pipewire_default_sink_id = NULL; static char *pipewire_default_source_id = NULL; -/* The active node list */ +// The active node list static SDL_bool io_list_check_add(struct io_node *node) { struct io_node *n; SDL_bool ret = SDL_TRUE; - /* See if the node is already in the list */ + // See if the node is already in the list spa_list_for_each (n, &hotplug_io_list, link) { if (n->id == node->id) { ret = SDL_FALSE; @@ -305,7 +306,7 @@ static SDL_bool io_list_check_add(struct io_node *node) } } - /* Add to the list if the node doesn't already exist */ + // Add to the list if the node doesn't already exist spa_list_append(&hotplug_io_list, &node->link); if (hotplug_events_enabled) { @@ -321,7 +322,7 @@ static void io_list_remove(Uint32 id) { struct io_node *n, *temp; - /* Find and remove the node from the list */ + // Find and remove the node from the list spa_list_for_each_safe (n, temp, &hotplug_io_list, link) { if (n->id == id) { spa_list_remove(&n->link); @@ -369,7 +370,7 @@ static void node_object_destroy(struct node_object *node) PIPEWIRE_pw_proxy_destroy(node->proxy); } -/* The pending node list */ +// The pending node list static void pending_list_add(struct node_object *node) { SDL_assert(node); @@ -401,7 +402,7 @@ static void *node_object_new(Uint32 id, const char *type, Uint32 version, const struct pw_proxy *proxy; struct node_object *node; - /* Create the proxy object */ + // Create the proxy object proxy = pw_registry_bind(hotplug_registry, id, type, version, sizeof(struct node_object)); if (proxy == NULL) { SDL_SetError("Pipewire: Failed to create proxy object (%i)", errno); @@ -414,24 +415,24 @@ static void *node_object_new(Uint32 id, const char *type, Uint32 version, const node->id = id; node->proxy = proxy; - /* Add the callbacks */ + // Add the callbacks pw_core_add_listener(hotplug_core, &node->core_listener, core_events, node); PIPEWIRE_pw_proxy_add_object_listener(node->proxy, &node->node_listener, funcs, node); - /* Add the node to the active list */ + // Add the node to the active list pending_list_add(node); return node; } -/* Core sync points */ +// Core sync points static void core_events_hotplug_init_callback(void *object, uint32_t id, int seq) { if (id == PW_ID_CORE && seq == hotplug_init_seq_val) { - /* This core listener is no longer needed. */ + // This core listener is no longer needed. spa_hook_remove(&hotplug_core_listener); - /* Signal that the initial I/O list is populated */ + // Signal that the initial I/O list is populated hotplug_init_complete = SDL_TRUE; PIPEWIRE_pw_thread_loop_signal(hotplug_loop, false); } @@ -483,7 +484,7 @@ static void hotplug_core_sync(struct node_object *node) } } -/* Helpers for retrieving values from params */ +// Helpers for retrieving values from params static SDL_bool get_range_param(const struct spa_pod *param, Uint32 key, int *def, int *min, int *max) { const struct spa_pod_prop *prop; @@ -535,7 +536,7 @@ static SDL_bool get_int_param(const struct spa_pod *param, Uint32 key, int *val) return SDL_FALSE; } -/* Interface node callbacks */ +// Interface node callbacks static void node_event_info(void *object, const struct pw_node_info *info) { struct node_object *node = object; @@ -549,7 +550,7 @@ static void node_event_info(void *object, const struct pw_node_info *info) io->spec.channels = (Uint8)SDL_atoi(prop_val); } - /* Need to parse the parameters to get the sample rate */ + // Need to parse the parameters to get the sample rate for (i = 0; i < info->n_params; ++i) { pw_node_enum_params(node->proxy, 0, info->params[i].id, 0, 0, NULL); } @@ -563,7 +564,7 @@ static void node_event_param(void *object, int seq, uint32_t id, uint32_t index, struct node_object *node = object; struct io_node *io = node->userdata; - /* Get the default frequency */ + // Get the default frequency if (io->spec.freq == 0) { get_range_param(param, SPA_FORMAT_AUDIO_rate, &io->spec.freq, NULL, NULL); } @@ -586,19 +587,19 @@ static const struct pw_node_events interface_node_events = { PW_VERSION_NODE_EVE static char *get_name_from_json(const char *json) { struct spa_json parser[2]; - char key[7]; /* "name" */ + char key[7]; // "name" char value[PW_MAX_IDENTIFIER_LENGTH]; spa_json_init(&parser[0], json, SDL_strlen(json)); if (spa_json_enter_object(&parser[0], &parser[1]) <= 0) { - /* Not actually JSON */ + // Not actually JSON return NULL; } if (spa_json_get_string(&parser[1], key, sizeof(key)) <= 0) { - /* Not actually a key/value pair */ + // Not actually a key/value pair return NULL; } if (spa_json_get_string(&parser[1], value, sizeof(value)) <= 0) { - /* Somehow had a key with no value? */ + // Somehow had a key with no value? return NULL; } return SDL_strdup(value); @@ -617,7 +618,7 @@ static void change_default_device(const char *path) } } -/* Metadata node callback */ +// Metadata node callback static int metadata_property(void *object, Uint32 subject, const char *key, const char *type, const char *value) { struct node_object *node = object; @@ -645,13 +646,13 @@ static int metadata_property(void *object, Uint32 subject, const char *key, cons static const struct pw_metadata_events metadata_node_events = { PW_VERSION_METADATA_EVENTS, .property = metadata_property }; -/* Global registry callbacks */ +// Global registry callbacks static void registry_event_global_callback(void *object, uint32_t id, uint32_t permissions, const char *type, uint32_t version, const struct spa_dict *props) { struct node_object *node; - /* We're only interested in interface and metadata nodes. */ + // We're only interested in interface and metadata nodes. if (!SDL_strcmp(type, PW_TYPE_INTERFACE_Node)) { const char *media_class = spa_dict_lookup(props, PW_KEY_MEDIA_CLASS); @@ -663,7 +664,7 @@ static void registry_event_global_callback(void *object, uint32_t id, uint32_t p int desc_buffer_len; int path_buffer_len; - /* Just want sink and capture */ + // Just want sink and capture if (!SDL_strcasecmp(media_class, "Audio/Sink")) { is_capture = SDL_FALSE; } else if (!SDL_strcasecmp(media_class, "Audio/Source")) { @@ -682,7 +683,7 @@ static void registry_event_global_callback(void *object, uint32_t id, uint32_t p return; } - /* Allocate and initialize the I/O node information struct */ + // Allocate and initialize the I/O node information struct desc_buffer_len = SDL_strlen(node_desc) + 1; path_buffer_len = SDL_strlen(node_path) + 1; node->userdata = io = SDL_calloc(1, sizeof(struct io_node) + desc_buffer_len + path_buffer_len); @@ -692,16 +693,16 @@ static void registry_event_global_callback(void *object, uint32_t id, uint32_t p return; } - /* Begin setting the node properties */ + // Begin setting the node properties io->id = id; io->is_capture = is_capture; - io->spec.format = SDL_AUDIO_F32; /* Pipewire uses floats internally, other formats require conversion. */ + io->spec.format = SDL_AUDIO_F32; // Pipewire uses floats internally, other formats require conversion. io->name = io->buf; io->path = io->buf + desc_buffer_len; SDL_strlcpy(io->buf, node_desc, desc_buffer_len); SDL_strlcpy(io->buf + desc_buffer_len, node_path, path_buffer_len); - /* Update sync points */ + // Update sync points hotplug_core_sync(node); } } @@ -712,7 +713,7 @@ static void registry_event_global_callback(void *object, uint32_t id, uint32_t p return; } - /* Update sync points */ + // Update sync points hotplug_core_sync(node); } } @@ -726,7 +727,7 @@ static void registry_event_remove_callback(void *object, uint32_t id) static const struct pw_registry_events registry_events = { PW_VERSION_REGISTRY_EVENTS, .global = registry_event_global_callback, .global_remove = registry_event_remove_callback }; -/* The hotplug thread */ +// The hotplug thread static int hotplug_loop_init(void) { int res; @@ -818,7 +819,7 @@ static void PIPEWIRE_DetectDevices(SDL_AudioDevice **default_output, SDL_AudioDe PIPEWIRE_pw_thread_loop_lock(hotplug_loop); - /* Wait until the initial registry enumeration is complete */ + // Wait until the initial registry enumeration is complete if (!hotplug_init_complete) { PIPEWIRE_pw_thread_loop_wait(hotplug_loop); } @@ -839,7 +840,7 @@ static void PIPEWIRE_DetectDevices(SDL_AudioDevice **default_output, SDL_AudioDe PIPEWIRE_pw_thread_loop_unlock(hotplug_loop); } -/* Channel maps that match the order in SDL_Audio.h */ +// Channel maps that match the order in SDL_Audio.h static const enum spa_audio_channel PIPEWIRE_channel_map_1[] = { SPA_AUDIO_CHANNEL_MONO }; static const enum spa_audio_channel PIPEWIRE_channel_map_2[] = { SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FR }; static const enum spa_audio_channel PIPEWIRE_channel_map_3[] = { SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FR, SPA_AUDIO_CHANNEL_LFE }; @@ -890,7 +891,7 @@ static void initialize_spa_info(const SDL_AudioSpec *spec, struct spa_audio_info break; } - /* Pipewire natively supports all of SDL's sample formats */ + // Pipewire natively supports all of SDL's sample formats switch (spec->format) { case SDL_AUDIO_U8: info->format = SPA_AUDIO_FORMAT_U8; @@ -1065,10 +1066,10 @@ static int PIPEWIRE_OpenDevice(SDL_AudioDevice *device) const SDL_bool iscapture = device->iscapture; int res; - /* Clamp the period size to sane values */ + // Clamp the period size to sane values const int min_period = PW_MIN_SAMPLES * SPA_MAX(device->spec.freq / PW_BASE_CLOCK_RATE, 1); - /* Get the hints for the application name, stream name and role */ + // Get the hints for the application name, stream name and role app_name = SDL_GetHint(SDL_HINT_AUDIO_DEVICE_APP_NAME); if (app_name == NULL || *app_name == '\0') { app_name = SDL_GetHint(SDL_HINT_APP_NAME); @@ -1077,7 +1078,7 @@ static int PIPEWIRE_OpenDevice(SDL_AudioDevice *device) } } - /* App ID. Default to NULL if not available. */ + // App ID. Default to NULL if not available. app_id = SDL_GetHint(SDL_HINT_APP_ID); stream_name = SDL_GetHint(SDL_HINT_AUDIO_DEVICE_STREAM_NAME); @@ -1094,7 +1095,7 @@ static int PIPEWIRE_OpenDevice(SDL_AudioDevice *device) stream_role = "Game"; } - /* Initialize the Pipewire stream info from the SDL audio spec */ + // Initialize the Pipewire stream info from the SDL audio spec initialize_spa_info(&device->spec, &spa_info); params = spa_format_audio_raw_build(&b, SPA_PARAM_EnumFormat, &spa_info); if (params == NULL) { @@ -1107,7 +1108,7 @@ static int PIPEWIRE_OpenDevice(SDL_AudioDevice *device) return SDL_OutOfMemory(); } - /* Size of a single audio frame in bytes */ + // Size of a single audio frame in bytes priv->stride = SDL_AUDIO_FRAMESIZE(device->spec); if (device->sample_frames < min_period) { @@ -1122,7 +1123,7 @@ static int PIPEWIRE_OpenDevice(SDL_AudioDevice *device) return SDL_SetError("Pipewire: Failed to create stream loop (%i)", errno); } - /* Load the realtime module so Pipewire can set the loop thread to the appropriate priority. */ + // Load the realtime module so Pipewire can set the loop thread to the appropriate priority. props = PIPEWIRE_pw_properties_new(PW_KEY_CONFIG_NAME, "client-rt.conf", NULL); if (props == NULL) { return SDL_SetError("Pipewire: Failed to create stream context properties (%i)", errno); @@ -1173,7 +1174,7 @@ static int PIPEWIRE_OpenDevice(SDL_AudioDevice *device) } } - /* Create the new stream */ + // Create the new stream priv->stream = PIPEWIRE_pw_stream_new_simple(PIPEWIRE_pw_thread_loop_get_loop(priv->loop), stream_name, props, iscapture ? &stream_input_events : &stream_output_events, device); if (priv->stream == NULL) { @@ -1191,7 +1192,7 @@ static int PIPEWIRE_OpenDevice(SDL_AudioDevice *device) return SDL_SetError("Pipewire: Failed to start stream loop"); } - /* Wait until all init flags are set or the stream has failed. */ + // Wait until all init flags are set or the stream has failed. PIPEWIRE_pw_thread_loop_lock(priv->loop); while (priv->stream_init_status != PW_READY_FLAG_ALL_BITS && PIPEWIRE_pw_stream_get_state(priv->stream, NULL) != PW_STREAM_STATE_ERROR) { @@ -1264,7 +1265,6 @@ static SDL_bool PIPEWIRE_Init(SDL_AudioDriverImpl *impl) } } - /* Set the function pointers */ impl->DetectDevices = PIPEWIRE_DetectDevices; impl->OpenDevice = PIPEWIRE_OpenDevice; impl->DeinitializeStart = PIPEWIRE_DeinitializeStart; @@ -1283,4 +1283,4 @@ static SDL_bool PIPEWIRE_Init(SDL_AudioDriverImpl *impl) AudioBootStrap PIPEWIRE_bootstrap = { "pipewire", "Pipewire", PIPEWIRE_Init, SDL_FALSE }; -#endif /* SDL_AUDIO_DRIVER_PIPEWIRE */ +#endif // SDL_AUDIO_DRIVER_PIPEWIRE diff --git a/src/audio/pipewire/SDL_pipewire.h b/src/audio/pipewire/SDL_pipewire.h index 5a6772ab5..1350fffb1 100644 --- a/src/audio/pipewire/SDL_pipewire.h +++ b/src/audio/pipewire/SDL_pipewire.h @@ -33,11 +33,11 @@ struct SDL_PrivateAudioData struct pw_stream *stream; struct pw_context *context; - Sint32 stride; /* Bytes-per-frame */ + Sint32 stride; // Bytes-per-frame int stream_init_status; // Set in GetDeviceBuf, filled in AudioThreadIterate, queued in PlayDevice struct pw_buffer *pw_buf; }; -#endif /* SDL_pipewire_h_ */ +#endif // SDL_pipewire_h_ diff --git a/src/audio/ps2/SDL_ps2audio.h b/src/audio/ps2/SDL_ps2audio.h index b4ed26f10..5b5f71a8c 100644 --- a/src/audio/ps2/SDL_ps2audio.h +++ b/src/audio/ps2/SDL_ps2audio.h @@ -29,14 +29,14 @@ struct SDL_PrivateAudioData { - /* The hardware output channel. */ + // The hardware output channel. int channel; - /* The raw allocated mixing buffer. */ + // The raw allocated mixing buffer. Uint8 *rawbuf; - /* Individual mixing buffers. */ + // Individual mixing buffers. Uint8 *mixbufs[NUM_BUFFERS]; - /* Index of the next available mixing buffer. */ + // Index of the next available mixing buffer. int next_buffer; }; -#endif /* SDL_ps2audio_h_ */ +#endif // SDL_ps2audio_h_ diff --git a/src/audio/psp/SDL_pspaudio.h b/src/audio/psp/SDL_pspaudio.h index c030db82e..da535e2a7 100644 --- a/src/audio/psp/SDL_pspaudio.h +++ b/src/audio/psp/SDL_pspaudio.h @@ -28,14 +28,14 @@ struct SDL_PrivateAudioData { - /* The hardware output channel. */ + // The hardware output channel. int channel; - /* The raw allocated mixing buffer. */ + // The raw allocated mixing buffer. Uint8 *rawbuf; - /* Individual mixing buffers. */ + // Individual mixing buffers. Uint8 *mixbufs[NUM_BUFFERS]; - /* Index of the next available mixing buffer. */ + // Index of the next available mixing buffer. int next_buffer; }; -#endif /* SDL_pspaudio_h_ */ +#endif // SDL_pspaudio_h_ diff --git a/src/audio/pulseaudio/SDL_pulseaudio.c b/src/audio/pulseaudio/SDL_pulseaudio.c index 0703fc740..2022156ea 100644 --- a/src/audio/pulseaudio/SDL_pulseaudio.c +++ b/src/audio/pulseaudio/SDL_pulseaudio.c @@ -23,7 +23,7 @@ #ifdef SDL_AUDIO_DRIVER_PULSEAUDIO -/* Allow access to a raw mixing buffer */ +// Allow access to a raw mixing buffer #ifdef HAVE_SIGNAL_H #include @@ -39,7 +39,7 @@ typedef void (*pa_operation_notify_cb_t) (pa_operation *o, void *userdata); #endif -/* should we include monitors in the device list? Set at SDL_Init time */ +// should we include monitors in the device list? Set at SDL_Init time static SDL_bool include_monitors = SDL_FALSE; static pa_threaded_mainloop *pulseaudio_threaded_mainloop = NULL; @@ -128,14 +128,14 @@ static int load_pulseaudio_sym(const char *fn, void **addr) { *addr = SDL_LoadFunction(pulseaudio_handle, fn); if (*addr == NULL) { - /* Don't call SDL_SetError(): SDL_LoadFunction already did. */ + // Don't call SDL_SetError(): SDL_LoadFunction already did. return 0; } return 1; } -/* cast funcs to char* first, to please GCC's strict aliasing rules. */ +// cast funcs to char* first, to please GCC's strict aliasing rules. #define SDL_PULSEAUDIO_SYM(x) \ if (!load_pulseaudio_sym(#x, (void **)(char *)&PULSEAUDIO_##x)) \ return -1 @@ -155,7 +155,7 @@ static int LoadPulseAudioLibrary(void) pulseaudio_handle = SDL_LoadObject(pulseaudio_library); if (pulseaudio_handle == NULL) { retval = -1; - /* Don't call SDL_SetError(): SDL_LoadObject already did. */ + // Don't call SDL_SetError(): SDL_LoadObject already did. } else { retval = load_pulseaudio_syms(); if (retval < 0) { @@ -180,7 +180,7 @@ static int LoadPulseAudioLibrary(void) return 0; } -#endif /* SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC */ +#endif // SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC static int load_pulseaudio_syms(void) { @@ -231,7 +231,7 @@ static int load_pulseaudio_syms(void) SDL_PULSEAUDIO_SYM(pa_stream_set_read_callback); SDL_PULSEAUDIO_SYM(pa_context_get_server_info); - /* optional */ + // optional #ifdef SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC load_pulseaudio_sym("pa_operation_set_state_callback", (void **)(char *)&PULSEAUDIO_pa_operation_set_state_callback); // needs pulseaudio 4.0 load_pulseaudio_sym("pa_threaded_mainloop_set_name", (void **)(char *)&PULSEAUDIO_pa_threaded_mainloop_set_name); // needs pulseaudio 5.0 @@ -254,7 +254,7 @@ static SDL_INLINE int squashVersion(const int major, const int minor, const int return ((major & 0xFF) << 16) | ((minor & 0xFF) << 8) | (patch & 0xFF); } -/* Workaround for older pulse: pa_context_new() must have non-NULL appname */ +// Workaround for older pulse: pa_context_new() must have non-NULL appname static const char *getAppName(void) { const char *retval = SDL_GetHint(SDL_HINT_AUDIO_DEVICE_APP_NAME); @@ -266,12 +266,12 @@ static const char *getAppName(void) return retval; } else { const char *verstr = PULSEAUDIO_pa_get_library_version(); - retval = "SDL Application"; /* the "oh well" default. */ + retval = "SDL Application"; // the "oh well" default. if (verstr != NULL) { int maj, min, patch; if (SDL_sscanf(verstr, "%d.%d.%d", &maj, &min, &patch) == 3) { if (squashVersion(maj, min, patch) >= squashVersion(0, 9, 15)) { - retval = NULL; /* 0.9.15+ handles NULL correctly. */ + retval = NULL; // 0.9.15+ handles NULL correctly. } } } @@ -288,7 +288,7 @@ static void OperationStateChangeCallback(pa_operation *o, void *userdata) you did the work in the callback and just want to know it's done, though. */ static void WaitForPulseOperation(pa_operation *o) { - /* This checks for NO errors currently. Either fix that, check results elsewhere, or do things you don't care about. */ + // This checks for NO errors currently. Either fix that, check results elsewhere, or do things you don't care about. SDL_assert(pulseaudio_threaded_mainloop != NULL); if (o) { // note that if PULSEAUDIO_pa_operation_set_state_callback == NULL, then `o` must have a callback that will signal pulseaudio_threaded_mainloop. @@ -299,7 +299,7 @@ static void WaitForPulseOperation(pa_operation *o) PULSEAUDIO_pa_operation_set_state_callback(o, OperationStateChangeCallback, NULL); } while (PULSEAUDIO_pa_operation_get_state(o) == PA_OPERATION_RUNNING) { - PULSEAUDIO_pa_threaded_mainloop_wait(pulseaudio_threaded_mainloop); /* this releases the lock and blocks on an internal condition variable. */ + PULSEAUDIO_pa_threaded_mainloop_wait(pulseaudio_threaded_mainloop); // this releases the lock and blocks on an internal condition variable. } PULSEAUDIO_pa_operation_unref(o); } @@ -323,7 +323,7 @@ static void DisconnectFromPulseServer(void) static void PulseContextStateChangeCallback(pa_context *context, void *userdata) { - PULSEAUDIO_pa_threaded_mainloop_signal(pulseaudio_threaded_mainloop, 0); /* just signal any waiting code, it can look up the details. */ + PULSEAUDIO_pa_threaded_mainloop_signal(pulseaudio_threaded_mainloop, 0); // just signal any waiting code, it can look up the details. } static int ConnectToPulseServer(void) @@ -334,7 +334,7 @@ static int ConnectToPulseServer(void) SDL_assert(pulseaudio_threaded_mainloop == NULL); SDL_assert(pulseaudio_context == NULL); - /* Set up a new main loop */ + // Set up a new main loop if (!(pulseaudio_threaded_mainloop = PULSEAUDIO_pa_threaded_mainloop_new())) { return SDL_SetError("pa_threaded_mainloop_new() failed"); } @@ -352,7 +352,7 @@ static int ConnectToPulseServer(void) PULSEAUDIO_pa_threaded_mainloop_lock(pulseaudio_threaded_mainloop); mainloop_api = PULSEAUDIO_pa_threaded_mainloop_get_api(pulseaudio_threaded_mainloop); - SDL_assert(mainloop_api); /* this never fails, right? */ + SDL_assert(mainloop_api); // this never fails, right? pulseaudio_context = PULSEAUDIO_pa_context_new(mainloop_api, getAppName()); if (pulseaudio_context == NULL) { @@ -362,7 +362,7 @@ static int ConnectToPulseServer(void) PULSEAUDIO_pa_context_set_state_callback(pulseaudio_context, PulseContextStateChangeCallback, NULL); - /* Connect to the PulseAudio server */ + // Connect to the PulseAudio server if (PULSEAUDIO_pa_context_connect(pulseaudio_context, NULL, 0, NULL) < 0) { SDL_SetError("Could not setup connection to PulseAudio"); goto failed; @@ -381,7 +381,7 @@ static int ConnectToPulseServer(void) PULSEAUDIO_pa_threaded_mainloop_unlock(pulseaudio_threaded_mainloop); - return 0; /* connected and ready! */ + return 0; // connected and ready! failed: PULSEAUDIO_pa_threaded_mainloop_unlock(pulseaudio_threaded_mainloop); @@ -392,27 +392,27 @@ failed: static void WriteCallback(pa_stream *p, size_t nbytes, void *userdata) { struct SDL_PrivateAudioData *h = (struct SDL_PrivateAudioData *)userdata; - /*printf("PULSEAUDIO WRITE CALLBACK! nbytes=%u\n", (unsigned int) nbytes);*/ + //printf("PULSEAUDIO WRITE CALLBACK! nbytes=%u\n", (unsigned int) nbytes); h->bytes_requested += nbytes; PULSEAUDIO_pa_threaded_mainloop_signal(pulseaudio_threaded_mainloop, 0); } -/* This function waits until it is possible to write a full sound buffer */ +// This function waits until it is possible to write a full sound buffer static int PULSEAUDIO_WaitDevice(SDL_AudioDevice *device) { struct SDL_PrivateAudioData *h = device->hidden; int retval = 0; - /*printf("PULSEAUDIO PLAYDEVICE START! mixlen=%d\n", available);*/ + //printf("PULSEAUDIO PLAYDEVICE START! mixlen=%d\n", available); PULSEAUDIO_pa_threaded_mainloop_lock(pulseaudio_threaded_mainloop); while (!SDL_AtomicGet(&device->shutdown) && (h->bytes_requested == 0)) { - /*printf("PULSEAUDIO WAIT IN WAITDEVICE!\n");*/ + //printf("PULSEAUDIO WAIT IN WAITDEVICE!\n"); PULSEAUDIO_pa_threaded_mainloop_wait(pulseaudio_threaded_mainloop); if ((PULSEAUDIO_pa_context_get_state(pulseaudio_context) != PA_CONTEXT_READY) || (PULSEAUDIO_pa_stream_get_state(h->stream) != PA_STREAM_READY)) { - /*printf("PULSEAUDIO DEVICE FAILURE IN WAITDEVICE!\n");*/ + //printf("PULSEAUDIO DEVICE FAILURE IN WAITDEVICE!\n"); retval = -1; break; } @@ -427,7 +427,7 @@ static int PULSEAUDIO_PlayDevice(SDL_AudioDevice *device, const Uint8 *buffer, i { struct SDL_PrivateAudioData *h = device->hidden; - /*printf("PULSEAUDIO PLAYDEVICE START! mixlen=%d\n", available);*/ + //printf("PULSEAUDIO PLAYDEVICE START! mixlen=%d\n", available); SDL_assert(h->bytes_requested >= buffer_size); @@ -439,10 +439,10 @@ static int PULSEAUDIO_PlayDevice(SDL_AudioDevice *device, const Uint8 *buffer, i return -1; } - /*printf("PULSEAUDIO FEED! nbytes=%d\n", buffer_size);*/ + //printf("PULSEAUDIO FEED! nbytes=%d\n", buffer_size); h->bytes_requested -= buffer_size; - /*printf("PULSEAUDIO PLAYDEVICE END! written=%d\n", written);*/ + //printf("PULSEAUDIO PLAYDEVICE END! written=%d\n", written); return 0; } @@ -464,8 +464,8 @@ static Uint8 *PULSEAUDIO_GetDeviceBuf(SDL_AudioDevice *device, int *buffer_size) static void ReadCallback(pa_stream *p, size_t nbytes, void *userdata) { - /*printf("PULSEAUDIO READ CALLBACK! nbytes=%u\n", (unsigned int) nbytes);*/ - PULSEAUDIO_pa_threaded_mainloop_signal(pulseaudio_threaded_mainloop, 0); /* the capture code queries what it needs, we just need to signal to end any wait */ + //printf("PULSEAUDIO READ CALLBACK! nbytes=%u\n", (unsigned int) nbytes); + PULSEAUDIO_pa_threaded_mainloop_signal(pulseaudio_threaded_mainloop, 0); // the capture code queries what it needs, we just need to signal to end any wait } static int PULSEAUDIO_WaitCaptureDevice(SDL_AudioDevice *device) @@ -527,7 +527,7 @@ static int PULSEAUDIO_CaptureFromDevice(SDL_AudioDevice *device, void *buffer, i PULSEAUDIO_pa_stream_drop(h->stream); // done with this fragment. PULSEAUDIO_pa_threaded_mainloop_unlock(pulseaudio_threaded_mainloop); } - return cpy; /* new data, return it. */ + return cpy; // new data, return it. } return 0; @@ -550,15 +550,15 @@ static void PULSEAUDIO_FlushCapture(SDL_AudioDevice *device) while (!SDL_AtomicGet(&device->shutdown) && (PULSEAUDIO_pa_stream_readable_size(h->stream) > 0)) { PULSEAUDIO_pa_threaded_mainloop_wait(pulseaudio_threaded_mainloop); if ((PULSEAUDIO_pa_context_get_state(pulseaudio_context) != PA_CONTEXT_READY) || (PULSEAUDIO_pa_stream_get_state(h->stream) != PA_STREAM_READY)) { - /*printf("PULSEAUDIO DEVICE FAILURE IN FLUSHCAPTURE!\n");*/ + //printf("PULSEAUDIO DEVICE FAILURE IN FLUSHCAPTURE!\n"); SDL_AudioDeviceDisconnected(device); break; } if (PULSEAUDIO_pa_stream_readable_size(h->stream) > 0) { - /* a new fragment is available! Just dump it. */ + // a new fragment is available! Just dump it. PULSEAUDIO_pa_stream_peek(h->stream, &data, &nbytes); - PULSEAUDIO_pa_stream_drop(h->stream); /* drop this fragment. */ + PULSEAUDIO_pa_stream_drop(h->stream); // drop this fragment. } } @@ -619,7 +619,7 @@ static SDL_bool FindDeviceName(SDL_AudioDevice *device) static void PulseStreamStateChangeCallback(pa_stream *stream, void *userdata) { - PULSEAUDIO_pa_threaded_mainloop_signal(pulseaudio_threaded_mainloop, 0); /* just signal any waiting code, it can look up the details. */ + PULSEAUDIO_pa_threaded_mainloop_signal(pulseaudio_threaded_mainloop, 0); // just signal any waiting code, it can look up the details. } static int PULSEAUDIO_OpenDevice(SDL_AudioDevice *device) @@ -638,13 +638,13 @@ static int PULSEAUDIO_OpenDevice(SDL_AudioDevice *device) SDL_assert(pulseaudio_threaded_mainloop != NULL); SDL_assert(pulseaudio_context != NULL); - /* Initialize all variables that we clean on shutdown */ + // Initialize all variables that we clean on shutdown h = device->hidden = (struct SDL_PrivateAudioData *)SDL_calloc(1, sizeof(*device->hidden)); if (device->hidden == NULL) { return SDL_OutOfMemory(); } - /* Try for a closest match on audio format */ + // Try for a closest match on audio format closefmts = SDL_ClosestAudioFormats(device->spec.format); while ((test_format = *(closefmts++)) != 0) { #ifdef DEBUG_AUDIO @@ -683,10 +683,10 @@ static int PULSEAUDIO_OpenDevice(SDL_AudioDevice *device) device->spec.format = test_format; paspec.format = format; - /* Calculate the final parameters for this audio specification */ + // Calculate the final parameters for this audio specification SDL_UpdatedAudioDeviceFormat(device); - /* Allocate mixing buffer */ + // Allocate mixing buffer if (!iscapture) { h->mixbuf = (Uint8 *)SDL_malloc(device->buffer_size); if (h->mixbuf == NULL) { @@ -698,7 +698,7 @@ static int PULSEAUDIO_OpenDevice(SDL_AudioDevice *device) paspec.channels = device->spec.channels; paspec.rate = device->spec.freq; - /* Reduced prebuffering compared to the defaults. */ + // Reduced prebuffering compared to the defaults. paattr.fragsize = device->buffer_size; // despite the name, this is only used for capture devices, according to PulseAudio docs! paattr.tlength = device->buffer_size; paattr.prebuf = -1; @@ -712,15 +712,15 @@ static int PULSEAUDIO_OpenDevice(SDL_AudioDevice *device) retval = SDL_SetError("Requested PulseAudio sink/source missing?"); } else { const char *name = SDL_GetHint(SDL_HINT_AUDIO_DEVICE_STREAM_NAME); - /* The SDL ALSA output hints us that we use Windows' channel mapping */ - /* https://bugzilla.libsdl.org/show_bug.cgi?id=110 */ + // The SDL ALSA output hints us that we use Windows' channel mapping + // https://bugzilla.libsdl.org/show_bug.cgi?id=110 PULSEAUDIO_pa_channel_map_init_auto(&pacmap, device->spec.channels, PA_CHANNEL_MAP_WAVEEX); h->stream = PULSEAUDIO_pa_stream_new( pulseaudio_context, - (name && *name) ? name : "Audio Stream", /* stream description */ - &paspec, /* sample format spec */ - &pacmap /* channel map */ + (name && *name) ? name : "Audio Stream", // stream description + &paspec, // sample format spec + &pacmap // channel map ); if (h->stream == NULL) { @@ -767,11 +767,11 @@ static int PULSEAUDIO_OpenDevice(SDL_AudioDevice *device) PULSEAUDIO_pa_threaded_mainloop_unlock(pulseaudio_threaded_mainloop); - /* We're (hopefully) ready to rock and roll. :-) */ + // We're (hopefully) ready to rock and roll. :-) return retval; } -/* device handles are device index + 1, cast to void*, so we never pass a NULL. */ +// device handles are device index + 1, cast to void*, so we never pass a NULL. static SDL_AudioFormat PulseFormatToSDLFormat(pa_sample_format_t format) { @@ -817,11 +817,11 @@ static void SinkInfoCallback(pa_context *c, const pa_sink_info *i, int is_last, PULSEAUDIO_pa_threaded_mainloop_signal(pulseaudio_threaded_mainloop, 0); } -/* This is called when PulseAudio adds a capture ("source") device. */ +// This is called when PulseAudio adds a capture ("source") device. // !!! FIXME: this is almost identical to SinkInfoCallback, merge the two. static void SourceInfoCallback(pa_context *c, const pa_source_info *i, int is_last, void *data) { - /* Maybe skip "monitor" sources. These are just output from other sinks. */ + // Maybe skip "monitor" sources. These are just output from other sinks. if (i && (include_monitors || (i->monitor_of_sink == PA_INVALID_INDEX))) { const SDL_bool add = (SDL_bool) ((intptr_t)data); @@ -843,13 +843,13 @@ static void SourceInfoCallback(pa_context *c, const pa_source_info *i, int is_la static void ServerInfoCallback(pa_context *c, const pa_server_info *i, void *data) { if (!default_sink_path || (SDL_strcmp(i->default_sink_name, default_sink_path) != 0)) { - /*printf("DEFAULT SINK PATH CHANGED TO '%s'\n", i->default_sink_name);*/ + //printf("DEFAULT SINK PATH CHANGED TO '%s'\n", i->default_sink_name); SDL_free(default_sink_path); default_sink_path = SDL_strdup(i->default_sink_name); } if (!default_source_path || (SDL_strcmp(i->default_source_name, default_source_path) != 0)) { - /*printf("DEFAULT SOURCE PATH CHANGED TO '%s'\n", i->default_source_name);*/ + //printf("DEFAULT SOURCE PATH CHANGED TO '%s'\n", i->default_source_name); SDL_free(default_source_path); default_source_path = SDL_strdup(i->default_source_name); } @@ -857,14 +857,14 @@ static void ServerInfoCallback(pa_context *c, const pa_server_info *i, void *dat PULSEAUDIO_pa_threaded_mainloop_signal(pulseaudio_threaded_mainloop, 0); } -// This is called when PulseAudio has a device connected/removed/changed. */ +// This is called when PulseAudio has a device connected/removed/changed. static void HotplugCallback(pa_context *c, pa_subscription_event_type_t t, uint32_t idx, void *data) { const SDL_bool added = ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_NEW); const SDL_bool removed = ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE); const SDL_bool changed = ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_CHANGE); - if (added || removed || changed) { /* we only care about add/remove events. */ + if (added || removed || changed) { // we only care about add/remove events. const SDL_bool sink = ((t & PA_SUBSCRIPTION_EVENT_FACILITY_MASK) == PA_SUBSCRIPTION_EVENT_SINK); const SDL_bool source = ((t & PA_SUBSCRIPTION_EVENT_FACILITY_MASK) == PA_SUBSCRIPTION_EVENT_SOURCE); @@ -909,7 +909,7 @@ static int SDLCALL HotplugThread(void *data) PULSEAUDIO_pa_threaded_mainloop_lock(pulseaudio_threaded_mainloop); PULSEAUDIO_pa_context_set_subscribe_callback(pulseaudio_context, HotplugCallback, NULL); - /* don't WaitForPulseOperation on the subscription; when it's done we'll be able to get hotplug events, but waiting doesn't changing anything. */ + // don't WaitForPulseOperation on the subscription; when it's done we'll be able to get hotplug events, but waiting doesn't changing anything. op = PULSEAUDIO_pa_context_subscribe(pulseaudio_context, PA_SUBSCRIPTION_MASK_SINK | PA_SUBSCRIPTION_MASK_SOURCE | PA_SUBSCRIPTION_MASK_SERVER, NULL, NULL); SDL_PostSemaphore((SDL_Semaphore *) data); @@ -961,7 +961,7 @@ static void PULSEAUDIO_DetectDevices(SDL_AudioDevice **default_output, SDL_Audio *default_capture = device; } - /* ok, we have a sane list, let's set up hotplug notifications now... */ + // ok, we have a sane list, let's set up hotplug notifications now... SDL_AtomicSet(&pulseaudio_hotplug_thread_active, 1); pulseaudio_hotplug_thread = SDL_CreateThreadInternal(HotplugThread, "PulseHotplug", 256 * 1024, ready_sem); // !!! FIXME: this can probably survive in significantly less stack space. SDL_WaitSemaphore(ready_sem); @@ -1006,7 +1006,6 @@ static SDL_bool PULSEAUDIO_Init(SDL_AudioDriverImpl *impl) include_monitors = SDL_GetHintBoolean(SDL_HINT_AUDIO_INCLUDE_MONITORS, SDL_FALSE); - /* Set the function pointers */ impl->DetectDevices = PULSEAUDIO_DetectDevices; impl->OpenDevice = PULSEAUDIO_OpenDevice; impl->PlayDevice = PULSEAUDIO_PlayDevice; @@ -1021,11 +1020,11 @@ static SDL_bool PULSEAUDIO_Init(SDL_AudioDriverImpl *impl) impl->HasCaptureSupport = SDL_TRUE; - return SDL_TRUE; /* this audio target is available. */ + return SDL_TRUE; } AudioBootStrap PULSEAUDIO_bootstrap = { "pulseaudio", "PulseAudio", PULSEAUDIO_Init, SDL_FALSE }; -#endif /* SDL_AUDIO_DRIVER_PULSEAUDIO */ +#endif // SDL_AUDIO_DRIVER_PULSEAUDIO diff --git a/src/audio/pulseaudio/SDL_pulseaudio.h b/src/audio/pulseaudio/SDL_pulseaudio.h index 10a7d9d12..6a0328e3f 100644 --- a/src/audio/pulseaudio/SDL_pulseaudio.h +++ b/src/audio/pulseaudio/SDL_pulseaudio.h @@ -31,16 +31,16 @@ struct SDL_PrivateAudioData { char *device_name; - /* pulseaudio structures */ + // pulseaudio structures pa_stream *stream; - /* Raw mixing buffer */ + // Raw mixing buffer Uint8 *mixbuf; - int bytes_requested; /* bytes of data the hardware wants _now_. */ + int bytes_requested; // bytes of data the hardware wants _now_. const Uint8 *capturebuf; int capturelen; }; -#endif /* SDL_pulseaudio_h_ */ +#endif // SDL_pulseaudio_h_ diff --git a/src/audio/qnx/SDL_qsa_audio.h b/src/audio/qnx/SDL_qsa_audio.h index 29dba24fd..e092612e0 100644 --- a/src/audio/qnx/SDL_qsa_audio.h +++ b/src/audio/qnx/SDL_qsa_audio.h @@ -36,6 +36,5 @@ struct SDL_PrivateAudioData Uint8 *pcm_buf; // Raw mixing buffer }; -#endif /* __SDL_QSA_AUDIO_H__ */ +#endif // __SDL_QSA_AUDIO_H__ -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/audio/sndio/SDL_sndioaudio.h b/src/audio/sndio/SDL_sndioaudio.h index 6a36b7df0..3337b1845 100644 --- a/src/audio/sndio/SDL_sndioaudio.h +++ b/src/audio/sndio/SDL_sndioaudio.h @@ -35,4 +35,4 @@ struct SDL_PrivateAudioData struct pollfd *pfd; // Polling structures for non-blocking sndio devices }; -#endif /* SDL_sndioaudio_h_ */ +#endif // SDL_sndioaudio_h_ diff --git a/src/audio/vita/SDL_vitaaudio.h b/src/audio/vita/SDL_vitaaudio.h index 1046fd57d..00b6d4812 100644 --- a/src/audio/vita/SDL_vitaaudio.h +++ b/src/audio/vita/SDL_vitaaudio.h @@ -28,14 +28,14 @@ struct SDL_PrivateAudioData { - /* The hardware input/output port. */ + // The hardware input/output port. int port; - /* The raw allocated mixing buffer. */ + // The raw allocated mixing buffer. Uint8 *rawbuf; - /* Individual mixing buffers. */ + // Individual mixing buffers. Uint8 *mixbufs[NUM_BUFFERS]; - /* Index of the next available mixing buffer. */ + // Index of the next available mixing buffer. int next_buffer; }; -#endif /* SDL_vitaaudio_h */ +#endif // SDL_vitaaudio_h diff --git a/src/audio/wasapi/SDL_wasapi.h b/src/audio/wasapi/SDL_wasapi.h index 00f80a08a..8207c32ce 100644 --- a/src/audio/wasapi/SDL_wasapi.h +++ b/src/audio/wasapi/SDL_wasapi.h @@ -45,7 +45,7 @@ struct SDL_PrivateAudioData void *activation_handler; }; -/* win32 and winrt implementations call into these. */ +// win32 and winrt implementations call into these. int WASAPI_PrepDevice(SDL_AudioDevice *device); void WASAPI_DisconnectDevice(SDL_AudioDevice *device); // don't hold the device lock when calling this! @@ -54,7 +54,7 @@ void WASAPI_DisconnectDevice(SDL_AudioDevice *device); // don't hold the device typedef int (*ManagementThreadTask)(void *userdata); int WASAPI_ProxyToManagementThread(ManagementThreadTask task, void *userdata, int *wait_until_complete); -/* These are functions that are implemented differently for Windows vs WinRT. */ +// These are functions that are implemented differently for Windows vs WinRT. // UNLESS OTHERWISE NOTED THESE ALL HAPPEN ON THE MANAGEMENT THREAD. int WASAPI_PlatformInit(void); void WASAPI_PlatformDeinit(void); @@ -70,4 +70,4 @@ void WASAPI_PlatformFreeDeviceHandle(SDL_AudioDevice *device); } #endif -#endif /* SDL_wasapi_h_ */ +#endif // SDL_wasapi_h_ diff --git a/src/audio/wasapi/SDL_wasapi_win32.c b/src/audio/wasapi/SDL_wasapi_win32.c index b43e07941..f128509a3 100644 --- a/src/audio/wasapi/SDL_wasapi_win32.c +++ b/src/audio/wasapi/SDL_wasapi_win32.c @@ -37,7 +37,7 @@ #include "SDL_wasapi.h" -/* handle to Avrt.dll--Vista and later!--for flagging the callback thread as "Pro Audio" (low latency). */ +// handle to Avrt.dll--Vista and later!--for flagging the callback thread as "Pro Audio" (low latency). static HMODULE libavrt = NULL; typedef HANDLE(WINAPI *pfnAvSetMmThreadCharacteristicsW)(LPCWSTR, LPDWORD); typedef BOOL(WINAPI *pfnAvRevertMmThreadCharacteristics)(HANDLE); @@ -46,7 +46,7 @@ static pfnAvRevertMmThreadCharacteristics pAvRevertMmThreadCharacteristics = NUL static SDL_bool immdevice_initialized = SDL_FALSE; -/* Some GUIDs we need to know without linking to libraries that aren't available before Vista. */ +// Some GUIDs we need to know without linking to libraries that aren't available before Vista. static const IID SDL_IID_IAudioClient = { 0x1cb9ad4c, 0xdbfa, 0x4c32, { 0xb1, 0x78, 0xc2, 0xf5, 0x68, 0xa7, 0x03, 0xb2 } }; int WASAPI_PlatformInit(void) @@ -59,7 +59,7 @@ int WASAPI_PlatformInit(void) immdevice_initialized = SDL_TRUE; - libavrt = LoadLibrary(TEXT("avrt.dll")); /* this library is available in Vista and later. No WinXP, so have to LoadLibrary to use it for now! */ + libavrt = LoadLibrary(TEXT("avrt.dll")); // this library is available in Vista and later. No WinXP, so have to LoadLibrary to use it for now! if (libavrt) { pAvSetMmThreadCharacteristicsW = (pfnAvSetMmThreadCharacteristicsW)GetProcAddress(libavrt, "AvSetMmThreadCharacteristicsW"); pAvRevertMmThreadCharacteristics = (pfnAvRevertMmThreadCharacteristics)GetProcAddress(libavrt, "AvRevertMmThreadCharacteristics"); @@ -98,12 +98,12 @@ void WASAPI_PlatformDeinitializeStart(void) void WASAPI_PlatformThreadInit(SDL_AudioDevice *device) { - /* this thread uses COM. */ - if (SUCCEEDED(WIN_CoInitialize())) { /* can't report errors, hope it worked! */ + // this thread uses COM. + if (SUCCEEDED(WIN_CoInitialize())) { // can't report errors, hope it worked! device->hidden->coinitialized = SDL_TRUE; } - /* Set this thread to very high "Pro Audio" priority. */ + // Set this thread to very high "Pro Audio" priority. if (pAvSetMmThreadCharacteristicsW) { DWORD idx = 0; device->hidden->task = pAvSetMmThreadCharacteristicsW(L"Pro Audio", &idx); @@ -115,7 +115,7 @@ void WASAPI_PlatformThreadInit(SDL_AudioDevice *device) void WASAPI_PlatformThreadDeinit(SDL_AudioDevice *device) { - /* Set this thread back to normal priority. */ + // Set this thread back to normal priority. if (device->hidden->task && pAvRevertMmThreadCharacteristics) { pAvRevertMmThreadCharacteristics(device->hidden->task); device->hidden->task = NULL; @@ -132,10 +132,10 @@ int WASAPI_ActivateDevice(SDL_AudioDevice *device) IMMDevice *immdevice = NULL; if (SDL_IMMDevice_Get(device, &immdevice, device->iscapture) < 0) { device->hidden->client = NULL; - return -1; /* This is already set by SDL_IMMDevice_Get */ + return -1; // This is already set by SDL_IMMDevice_Get } - /* this is _not_ async in standard win32, yay! */ + // this is _not_ async in standard win32, yay! HRESULT ret = IMMDevice_Activate(immdevice, &SDL_IID_IAudioClient, CLSCTX_ALL, NULL, (void **)&device->hidden->client); IMMDevice_Release(immdevice); @@ -145,11 +145,11 @@ int WASAPI_ActivateDevice(SDL_AudioDevice *device) } SDL_assert(device->hidden->client != NULL); - if (WASAPI_PrepDevice(device) == -1) { /* not async, fire it right away. */ + if (WASAPI_PrepDevice(device) == -1) { // not async, fire it right away. return -1; } - return 0; /* good to go. */ + return 0; // good to go. } void WASAPI_EnumerateEndpoints(SDL_AudioDevice **default_output, SDL_AudioDevice **default_capture) @@ -159,7 +159,7 @@ void WASAPI_EnumerateEndpoints(SDL_AudioDevice **default_output, SDL_AudioDevice void WASAPI_PlatformDeleteActivationHandler(void *handler) { - /* not asynchronous. */ + // not asynchronous. SDL_assert(!"This function should have only been called on WinRT."); } @@ -168,4 +168,4 @@ void WASAPI_PlatformFreeDeviceHandle(SDL_AudioDevice *device) SDL_IMMDevice_FreeDeviceHandle(device); } -#endif /* SDL_AUDIO_DRIVER_WASAPI && !defined(__WINRT__) */ +#endif // SDL_AUDIO_DRIVER_WASAPI && !defined(__WINRT__)