Update for SDL3 coding style (#6717)

I updated .clang-format and ran clang-format 14 over the src and test directories to standardize the code base.

In general I let clang-format have it's way, and added markup to prevent formatting of code that would break or be completely unreadable if formatted.

The script I ran for the src directory is added as build-scripts/clang-format-src.sh

This fixes:
#6592
#6593
#6594
This commit is contained in:
Sam Lantinga
2022-11-30 12:51:59 -08:00
committed by GitHub
parent 14b902faca
commit 5750bcb174
781 changed files with 51659 additions and 55763 deletions

View File

@@ -43,15 +43,12 @@
/* #define DEBUG_AUDIO */
static void
NETBSDAUDIO_DetectDevices(void)
static void NETBSDAUDIO_DetectDevices(void)
{
SDL_EnumUnixAudioDevices(0, NULL);
}
static void
NETBSDAUDIO_Status(_THIS)
static void NETBSDAUDIO_Status(_THIS)
{
#ifdef DEBUG_AUDIO
/* *INDENT-OFF* */ /* clang-format off */
@@ -117,12 +114,11 @@ NETBSDAUDIO_Status(_THIS)
this->spec.format,
this->spec.size);
/* *INDENT-ON* */ /* clang-format on */
#endif /* DEBUG_AUDIO */
}
static void
NETBSDAUDIO_PlayDevice(_THIS)
static void NETBSDAUDIO_PlayDevice(_THIS)
{
struct SDL_PrivateAudioData *h = this->hidden;
int written;
@@ -141,17 +137,14 @@ NETBSDAUDIO_PlayDevice(_THIS)
#endif
}
static Uint8 *
NETBSDAUDIO_GetDeviceBuf(_THIS)
static Uint8 *NETBSDAUDIO_GetDeviceBuf(_THIS)
{
return this->hidden->mixbuf;
}
static int
NETBSDAUDIO_CaptureFromDevice(_THIS, void *_buffer, int buflen)
static int NETBSDAUDIO_CaptureFromDevice(_THIS, void *_buffer, int buflen)
{
Uint8 *buffer = (Uint8 *) _buffer;
Uint8 *buffer = (Uint8 *)_buffer;
int br;
br = read(this->hidden->audio_fd, buffer, buflen);
@@ -167,30 +160,28 @@ NETBSDAUDIO_CaptureFromDevice(_THIS, void *_buffer, int buflen)
return 0;
}
static void
NETBSDAUDIO_FlushCapture(_THIS)
static void NETBSDAUDIO_FlushCapture(_THIS)
{
audio_info_t info;
size_t remain;
Uint8 buf[512];
if (ioctl(this->hidden->audio_fd, AUDIO_GETINFO, &info) < 0) {
return; /* oh well. */
return; /* oh well. */
}
remain = (size_t) (info.record.samples * (SDL_AUDIO_BITSIZE(this->spec.format) / 8));
remain = (size_t)(info.record.samples * (SDL_AUDIO_BITSIZE(this->spec.format) / 8));
while (remain > 0) {
const size_t len = SDL_min(sizeof (buf), remain);
const size_t len = SDL_min(sizeof(buf), remain);
const int br = read(this->hidden->audio_fd, buf, len);
if (br <= 0) {
return; /* oh well. */
return; /* oh well. */
}
remain -= br;
}
}
static void
NETBSDAUDIO_CloseDevice(_THIS)
static void NETBSDAUDIO_CloseDevice(_THIS)
{
if (this->hidden->audio_fd >= 0) {
close(this->hidden->audio_fd);
@@ -199,8 +190,7 @@ NETBSDAUDIO_CloseDevice(_THIS)
SDL_free(this->hidden);
}
static int
NETBSDAUDIO_OpenDevice(_THIS, const char *devname)
static int NETBSDAUDIO_OpenDevice(_THIS, const char *devname)
{
SDL_bool iscapture = this->iscapture;
SDL_AudioFormat test_format;
@@ -239,8 +229,7 @@ NETBSDAUDIO_OpenDevice(_THIS, const char *devname)
* Use the device's native sample rate so the kernel doesn't have to
* resample.
*/
this->spec.freq = iscapture ?
hwinfo.record.sample_rate : hwinfo.play.sample_rate;
this->spec.freq = iscapture ? hwinfo.record.sample_rate : hwinfo.play.sample_rate;
}
#endif
@@ -305,7 +294,7 @@ NETBSDAUDIO_OpenDevice(_THIS, const char *devname)
if (!iscapture) {
/* Allocate mixing buffer */
this->hidden->mixlen = this->spec.size;
this->hidden->mixbuf = (Uint8 *) SDL_malloc(this->hidden->mixlen);
this->hidden->mixbuf = (Uint8 *)SDL_malloc(this->hidden->mixlen);
if (this->hidden->mixbuf == NULL) {
return SDL_OutOfMemory();
}
@@ -318,8 +307,7 @@ NETBSDAUDIO_OpenDevice(_THIS, const char *devname)
return 0;
}
static SDL_bool
NETBSDAUDIO_Init(SDL_AudioDriverImpl * impl)
static SDL_bool NETBSDAUDIO_Init(SDL_AudioDriverImpl *impl)
{
/* Set the function pointers */
impl->DetectDevices = NETBSDAUDIO_DetectDevices;
@@ -333,10 +321,9 @@ NETBSDAUDIO_Init(SDL_AudioDriverImpl * impl)
impl->HasCaptureSupport = SDL_TRUE;
impl->AllowsArbitraryDeviceNames = SDL_TRUE;
return SDL_TRUE; /* this audio target is available. */
return SDL_TRUE; /* this audio target is available. */
}
AudioBootStrap NETBSDAUDIO_bootstrap = {
"netbsd", "NetBSD audio", NETBSDAUDIO_Init, SDL_FALSE
};