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

@@ -41,8 +41,7 @@
* Returns 0 on success, or -1 if the multiplication overflows, in which case f1
* does not get modified.
*/
static int
SafeMult(size_t *f1, size_t f2)
static int SafeMult(size_t *f1, size_t f2)
{
if (*f1 > 0 && SIZE_MAX / *f1 <= f2) {
return -1;
@@ -64,21 +63,24 @@ typedef struct ADPCM_DecoderState
void *cstate; /* Decoding state for each channel. */
/* ADPCM data. */
struct {
struct
{
Uint8 *data;
size_t size;
size_t pos;
} input;
/* Current ADPCM block in the ADPCM data above. */
struct {
struct
{
Uint8 *data;
size_t size;
size_t pos;
} block;
/* Decoded 16-bit PCM data. */
struct {
struct
{
Sint16 *data;
size_t size;
size_t pos;
@@ -100,8 +102,7 @@ typedef struct MS_ADPCM_ChannelState
} MS_ADPCM_ChannelState;
#ifdef SDL_WAVE_DEBUG_LOG_FORMAT
static void
WaveDebugLogFormat(WaveFile *file)
static void WaveDebugLogFormat(WaveFile *file)
{
WaveFormat *format = &file->format;
const char *fmtstr = "WAVE file: %s, %u Hz, %s, %u bits, %u %s/s";
@@ -135,55 +136,60 @@ WaveDebugLogFormat(WaveFile *file)
break;
}
#define SDL_WAVE_DEBUG_CHANNELCFG(STR, CODE) case CODE: wavechannel = STR; break;
#define SDL_WAVE_DEBUG_CHANNELSTR(STR, CODE) if (format->channelmask & CODE) { \
SDL_strlcat(channelstr, channelstr[0] ? "-" STR : STR, sizeof(channelstr));}
#define SDL_WAVE_DEBUG_CHANNELCFG(STR, CODE) \
case CODE: \
wavechannel = STR; \
break;
#define SDL_WAVE_DEBUG_CHANNELSTR(STR, CODE) \
if (format->channelmask & CODE) { \
SDL_strlcat(channelstr, channelstr[0] ? "-" STR : STR, sizeof(channelstr)); \
}
if (format->formattag == EXTENSIBLE_CODE && format->channelmask > 0) {
switch (format->channelmask) {
SDL_WAVE_DEBUG_CHANNELCFG("1.0 Mono", 0x4)
SDL_WAVE_DEBUG_CHANNELCFG("1.1 Mono", 0xc)
SDL_WAVE_DEBUG_CHANNELCFG("2.0 Stereo", 0x3)
SDL_WAVE_DEBUG_CHANNELCFG("2.1 Stereo", 0xb)
SDL_WAVE_DEBUG_CHANNELCFG("3.0 Stereo", 0x7)
SDL_WAVE_DEBUG_CHANNELCFG("3.1 Stereo", 0xf)
SDL_WAVE_DEBUG_CHANNELCFG("3.0 Surround", 0x103)
SDL_WAVE_DEBUG_CHANNELCFG("3.1 Surround", 0x10b)
SDL_WAVE_DEBUG_CHANNELCFG("4.0 Quad", 0x33)
SDL_WAVE_DEBUG_CHANNELCFG("4.1 Quad", 0x3b)
SDL_WAVE_DEBUG_CHANNELCFG("4.0 Surround", 0x107)
SDL_WAVE_DEBUG_CHANNELCFG("4.1 Surround", 0x10f)
SDL_WAVE_DEBUG_CHANNELCFG("5.0", 0x37)
SDL_WAVE_DEBUG_CHANNELCFG("5.1", 0x3f)
SDL_WAVE_DEBUG_CHANNELCFG("5.0 Side", 0x607)
SDL_WAVE_DEBUG_CHANNELCFG("5.1 Side", 0x60f)
SDL_WAVE_DEBUG_CHANNELCFG("6.0", 0x137)
SDL_WAVE_DEBUG_CHANNELCFG("6.1", 0x13f)
SDL_WAVE_DEBUG_CHANNELCFG("6.0 Side", 0x707)
SDL_WAVE_DEBUG_CHANNELCFG("6.1 Side", 0x70f)
SDL_WAVE_DEBUG_CHANNELCFG("7.0", 0xf7)
SDL_WAVE_DEBUG_CHANNELCFG("7.1", 0xff)
SDL_WAVE_DEBUG_CHANNELCFG("7.0 Side", 0x6c7)
SDL_WAVE_DEBUG_CHANNELCFG("7.1 Side", 0x6cf)
SDL_WAVE_DEBUG_CHANNELCFG("7.0 Surround", 0x637)
SDL_WAVE_DEBUG_CHANNELCFG("7.1 Surround", 0x63f)
SDL_WAVE_DEBUG_CHANNELCFG("9.0 Surround", 0x5637)
SDL_WAVE_DEBUG_CHANNELCFG("9.1 Surround", 0x563f)
SDL_WAVE_DEBUG_CHANNELCFG("11.0 Surround", 0x56f7)
SDL_WAVE_DEBUG_CHANNELCFG("11.1 Surround", 0x56ff)
SDL_WAVE_DEBUG_CHANNELCFG("1.0 Mono", 0x4)
SDL_WAVE_DEBUG_CHANNELCFG("1.1 Mono", 0xc)
SDL_WAVE_DEBUG_CHANNELCFG("2.0 Stereo", 0x3)
SDL_WAVE_DEBUG_CHANNELCFG("2.1 Stereo", 0xb)
SDL_WAVE_DEBUG_CHANNELCFG("3.0 Stereo", 0x7)
SDL_WAVE_DEBUG_CHANNELCFG("3.1 Stereo", 0xf)
SDL_WAVE_DEBUG_CHANNELCFG("3.0 Surround", 0x103)
SDL_WAVE_DEBUG_CHANNELCFG("3.1 Surround", 0x10b)
SDL_WAVE_DEBUG_CHANNELCFG("4.0 Quad", 0x33)
SDL_WAVE_DEBUG_CHANNELCFG("4.1 Quad", 0x3b)
SDL_WAVE_DEBUG_CHANNELCFG("4.0 Surround", 0x107)
SDL_WAVE_DEBUG_CHANNELCFG("4.1 Surround", 0x10f)
SDL_WAVE_DEBUG_CHANNELCFG("5.0", 0x37)
SDL_WAVE_DEBUG_CHANNELCFG("5.1", 0x3f)
SDL_WAVE_DEBUG_CHANNELCFG("5.0 Side", 0x607)
SDL_WAVE_DEBUG_CHANNELCFG("5.1 Side", 0x60f)
SDL_WAVE_DEBUG_CHANNELCFG("6.0", 0x137)
SDL_WAVE_DEBUG_CHANNELCFG("6.1", 0x13f)
SDL_WAVE_DEBUG_CHANNELCFG("6.0 Side", 0x707)
SDL_WAVE_DEBUG_CHANNELCFG("6.1 Side", 0x70f)
SDL_WAVE_DEBUG_CHANNELCFG("7.0", 0xf7)
SDL_WAVE_DEBUG_CHANNELCFG("7.1", 0xff)
SDL_WAVE_DEBUG_CHANNELCFG("7.0 Side", 0x6c7)
SDL_WAVE_DEBUG_CHANNELCFG("7.1 Side", 0x6cf)
SDL_WAVE_DEBUG_CHANNELCFG("7.0 Surround", 0x637)
SDL_WAVE_DEBUG_CHANNELCFG("7.1 Surround", 0x63f)
SDL_WAVE_DEBUG_CHANNELCFG("9.0 Surround", 0x5637)
SDL_WAVE_DEBUG_CHANNELCFG("9.1 Surround", 0x563f)
SDL_WAVE_DEBUG_CHANNELCFG("11.0 Surround", 0x56f7)
SDL_WAVE_DEBUG_CHANNELCFG("11.1 Surround", 0x56ff)
default:
SDL_WAVE_DEBUG_CHANNELSTR("FL", 0x1)
SDL_WAVE_DEBUG_CHANNELSTR("FR", 0x2)
SDL_WAVE_DEBUG_CHANNELSTR("FC", 0x4)
SDL_WAVE_DEBUG_CHANNELSTR("LF", 0x8)
SDL_WAVE_DEBUG_CHANNELSTR("BL", 0x10)
SDL_WAVE_DEBUG_CHANNELSTR("BR", 0x20)
SDL_WAVE_DEBUG_CHANNELSTR("FL", 0x1)
SDL_WAVE_DEBUG_CHANNELSTR("FR", 0x2)
SDL_WAVE_DEBUG_CHANNELSTR("FC", 0x4)
SDL_WAVE_DEBUG_CHANNELSTR("LF", 0x8)
SDL_WAVE_DEBUG_CHANNELSTR("BL", 0x10)
SDL_WAVE_DEBUG_CHANNELSTR("BR", 0x20)
SDL_WAVE_DEBUG_CHANNELSTR("FLC", 0x40)
SDL_WAVE_DEBUG_CHANNELSTR("FRC", 0x80)
SDL_WAVE_DEBUG_CHANNELSTR("BC", 0x100)
SDL_WAVE_DEBUG_CHANNELSTR("SL", 0x200)
SDL_WAVE_DEBUG_CHANNELSTR("SR", 0x400)
SDL_WAVE_DEBUG_CHANNELSTR("TC", 0x800)
SDL_WAVE_DEBUG_CHANNELSTR("BC", 0x100)
SDL_WAVE_DEBUG_CHANNELSTR("SL", 0x200)
SDL_WAVE_DEBUG_CHANNELSTR("SR", 0x400)
SDL_WAVE_DEBUG_CHANNELSTR("TC", 0x800)
SDL_WAVE_DEBUG_CHANNELSTR("TFL", 0x1000)
SDL_WAVE_DEBUG_CHANNELSTR("TFC", 0x2000)
SDL_WAVE_DEBUG_CHANNELSTR("TFR", 0x4000)
@@ -224,33 +230,32 @@ WaveDebugLogFormat(WaveFile *file)
#endif
#ifdef SDL_WAVE_DEBUG_DUMP_FORMAT
static void
WaveDebugDumpFormat(WaveFile *file, Uint32 rifflen, Uint32 fmtlen, Uint32 datalen)
static void WaveDebugDumpFormat(WaveFile *file, Uint32 rifflen, Uint32 fmtlen, Uint32 datalen)
{
WaveFormat *format = &file->format;
const char *fmtstr1 = "WAVE chunk dump:\n"
"-------------------------------------------\n"
"RIFF %11u\n"
"-------------------------------------------\n"
" fmt %11u\n"
" wFormatTag 0x%04x\n"
" nChannels %11u\n"
" nSamplesPerSec %11u\n"
" nAvgBytesPerSec %11u\n"
" nBlockAlign %11u\n";
"-------------------------------------------\n"
"RIFF %11u\n"
"-------------------------------------------\n"
" fmt %11u\n"
" wFormatTag 0x%04x\n"
" nChannels %11u\n"
" nSamplesPerSec %11u\n"
" nAvgBytesPerSec %11u\n"
" nBlockAlign %11u\n";
const char *fmtstr2 = " wBitsPerSample %11u\n";
const char *fmtstr3 = " cbSize %11u\n";
const char *fmtstr4a = " wValidBitsPerSample %11u\n";
const char *fmtstr4b = " wSamplesPerBlock %11u\n";
const char *fmtstr5 = " dwChannelMask 0x%08x\n"
" SubFormat\n"
" %08x-%04x-%04x-%02x%02x%02x%02x%02x%02x%02x%02x\n";
" SubFormat\n"
" %08x-%04x-%04x-%02x%02x%02x%02x%02x%02x%02x%02x\n";
const char *fmtstr6 = "-------------------------------------------\n"
" fact\n"
" dwSampleLength %11u\n";
" fact\n"
" dwSampleLength %11u\n";
const char *fmtstr7 = "-------------------------------------------\n"
" data %11u\n"
"-------------------------------------------\n";
" data %11u\n"
"-------------------------------------------\n";
char *dumpstr;
size_t dumppos = 0;
const size_t bufsize = 1024;
@@ -315,8 +320,7 @@ WaveDebugDumpFormat(WaveFile *file, Uint32 rifflen, Uint32 fmtlen, Uint32 datale
}
#endif
static Sint64
WaveAdjustToFactValue(WaveFile *file, Sint64 sampleframes)
static Sint64 WaveAdjustToFactValue(WaveFile *file, Sint64 sampleframes)
{
if (file->fact.status == 2) {
if (file->facthint == FactStrict && sampleframes < file->fact.samplelength) {
@@ -329,8 +333,7 @@ WaveAdjustToFactValue(WaveFile *file, Sint64 sampleframes)
return sampleframes;
}
static int
MS_ADPCM_CalculateSampleFrames(WaveFile *file, size_t datalength)
static int MS_ADPCM_CalculateSampleFrames(WaveFile *file, size_t datalength)
{
WaveFormat *format = &file->format;
const size_t blockheadersize = (size_t)file->format.channels * 7;
@@ -369,8 +372,7 @@ MS_ADPCM_CalculateSampleFrames(WaveFile *file, size_t datalength)
return 0;
}
static int
MS_ADPCM_Init(WaveFile *file, size_t datalength)
static int MS_ADPCM_Init(WaveFile *file, size_t datalength)
{
WaveFormat *format = &file->format;
WaveChunk *chunk = &file->chunk;
@@ -378,7 +380,7 @@ MS_ADPCM_Init(WaveFile *file, size_t datalength)
const size_t blockdatasize = (size_t)format->blockalign - blockheadersize;
const size_t blockframebitsize = (size_t)format->bitspersample * format->channels;
const size_t blockdatasamples = (blockdatasize * 8) / blockframebitsize;
const Sint16 presetcoeffs[14] = {256, 0, 512, -256, 0, 0, 192, 64, 240, 0, 460, -208, 392, -232};
const Sint16 presetcoeffs[14] = { 256, 0, 512, -256, 0, 0, 192, 64, 240, 0, 460, -208, 392, -232 };
size_t i, coeffcount;
MS_ADPCM_CoeffData *coeffdata;
@@ -488,8 +490,7 @@ MS_ADPCM_Init(WaveFile *file, size_t datalength)
return 0;
}
static Sint16
MS_ADPCM_ProcessNibble(MS_ADPCM_ChannelState *cstate, Sint32 sample1, Sint32 sample2, Uint8 nybble)
static Sint16 MS_ADPCM_ProcessNibble(MS_ADPCM_ChannelState *cstate, Sint32 sample1, Sint32 sample2, Uint8 nybble)
{
const Sint32 max_audioval = 32767;
const Sint32 min_audioval = -32768;
@@ -525,8 +526,7 @@ MS_ADPCM_ProcessNibble(MS_ADPCM_ChannelState *cstate, Sint32 sample1, Sint32 sam
return (Sint16)new_sample;
}
static int
MS_ADPCM_DecodeBlockHeader(ADPCM_DecoderState *state)
static int MS_ADPCM_DecodeBlockHeader(ADPCM_DecoderState *state)
{
Uint8 coeffindex;
const Uint32 channels = state->channels;
@@ -586,8 +586,7 @@ MS_ADPCM_DecodeBlockHeader(ADPCM_DecoderState *state)
* will always contain full sample frames (same sample count for each channel).
* Incomplete sample frames are discarded.
*/
static int
MS_ADPCM_DecodeBlockData(ADPCM_DecoderState *state)
static int MS_ADPCM_DecodeBlockData(ADPCM_DecoderState *state)
{
Uint16 nybble = 0;
Sint16 sample1, sample2;
@@ -634,8 +633,7 @@ MS_ADPCM_DecodeBlockData(ADPCM_DecoderState *state)
return 0;
}
static int
MS_ADPCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len)
static int MS_ADPCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len)
{
int result;
size_t bytesleft, outputsize;
@@ -734,8 +732,7 @@ MS_ADPCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len)
return 0;
}
static int
IMA_ADPCM_CalculateSampleFrames(WaveFile *file, size_t datalength)
static int IMA_ADPCM_CalculateSampleFrames(WaveFile *file, size_t datalength)
{
WaveFormat *format = &file->format;
const size_t blockheadersize = (size_t)format->channels * 4;
@@ -788,8 +785,7 @@ IMA_ADPCM_CalculateSampleFrames(WaveFile *file, size_t datalength)
return 0;
}
static int
IMA_ADPCM_Init(WaveFile *file, size_t datalength)
static int IMA_ADPCM_Init(WaveFile *file, size_t datalength)
{
WaveFormat *format = &file->format;
WaveChunk *chunk = &file->chunk;
@@ -854,8 +850,7 @@ IMA_ADPCM_Init(WaveFile *file, size_t datalength)
return 0;
}
static Sint16
IMA_ADPCM_ProcessNibble(Sint8 *cindex, Sint16 lastsample, Uint8 nybble)
static Sint16 IMA_ADPCM_ProcessNibble(Sint8 *cindex, Sint16 lastsample, Uint8 nybble)
{
const Sint32 max_audioval = 32767;
const Sint32 min_audioval = -32768;
@@ -924,12 +919,11 @@ IMA_ADPCM_ProcessNibble(Sint8 *cindex, Sint16 lastsample, Uint8 nybble)
return (Sint16)sample;
}
static int
IMA_ADPCM_DecodeBlockHeader(ADPCM_DecoderState *state)
static int IMA_ADPCM_DecodeBlockHeader(ADPCM_DecoderState *state)
{
Sint16 step;
Uint32 c;
Uint8 *cstate = (Uint8 *) state->cstate;
Uint8 *cstate = (Uint8 *)state->cstate;
for (c = 0; c < state->channels; c++) {
size_t o = state->block.pos + c * 4;
@@ -947,7 +941,7 @@ IMA_ADPCM_DecodeBlockHeader(ADPCM_DecoderState *state)
/* Reserved byte in block header, should be 0. */
if (state->block.data[o + 3] != 0) {
/* Uh oh, corrupt data? Buggy code? */ ;
/* Uh oh, corrupt data? Buggy code? */;
}
}
@@ -964,8 +958,7 @@ IMA_ADPCM_DecodeBlockHeader(ADPCM_DecoderState *state)
* contains full sample frames (same sample count for each channel).
* Incomplete sample frames are discarded.
*/
static int
IMA_ADPCM_DecodeBlockData(ADPCM_DecoderState *state)
static int IMA_ADPCM_DecodeBlockData(ADPCM_DecoderState *state)
{
size_t i;
int retval = 0;
@@ -1034,8 +1027,7 @@ IMA_ADPCM_DecodeBlockData(ADPCM_DecoderState *state)
return retval;
}
static int
IMA_ADPCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len)
static int IMA_ADPCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len)
{
int result;
size_t bytesleft, outputsize;
@@ -1138,8 +1130,7 @@ IMA_ADPCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len)
return 0;
}
static int
LAW_Init(WaveFile *file, size_t datalength)
static int LAW_Init(WaveFile *file, size_t datalength)
{
WaveFormat *format = &file->format;
@@ -1167,8 +1158,7 @@ LAW_Init(WaveFile *file, size_t datalength)
return 0;
}
static int
LAW_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len)
static int LAW_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len)
{
#ifdef SDL_WAVE_LAW_LUT
const Sint16 alaw_lut[256] = {
@@ -1310,8 +1300,7 @@ LAW_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len)
return 0;
}
static int
PCM_Init(WaveFile *file, size_t datalength)
static int PCM_Init(WaveFile *file, size_t datalength)
{
WaveFormat *format = &file->format;
@@ -1354,8 +1343,7 @@ PCM_Init(WaveFile *file, size_t datalength)
return 0;
}
static int
PCM_ConvertSint24ToSint32(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len)
static int PCM_ConvertSint24ToSint32(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len)
{
WaveFormat *format = &file->format;
WaveChunk *chunk = &file->chunk;
@@ -1406,8 +1394,7 @@ PCM_ConvertSint24ToSint32(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len)
return 0;
}
static int
PCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len)
static int PCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len)
{
WaveFormat *format = &file->format;
WaveChunk *chunk = &file->chunk;
@@ -1449,8 +1436,7 @@ PCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len)
return 0;
}
static WaveRiffSizeHint
WaveGetRiffSizeHint()
static WaveRiffSizeHint WaveGetRiffSizeHint()
{
const char *hint = SDL_GetHint(SDL_HINT_WAVE_RIFF_CHUNK_SIZE);
@@ -1469,8 +1455,7 @@ WaveGetRiffSizeHint()
return RiffSizeNoHint;
}
static WaveTruncationHint
WaveGetTruncationHint()
static WaveTruncationHint WaveGetTruncationHint()
{
const char *hint = SDL_GetHint(SDL_HINT_WAVE_TRUNCATION);
@@ -1489,8 +1474,7 @@ WaveGetTruncationHint()
return TruncNoHint;
}
static WaveFactChunkHint
WaveGetFactChunkHint()
static WaveFactChunkHint WaveGetFactChunkHint()
{
const char *hint = SDL_GetHint(SDL_HINT_WAVE_FACT_CHUNK);
@@ -1509,8 +1493,7 @@ WaveGetFactChunkHint()
return FactNoHint;
}
static void
WaveFreeChunkData(WaveChunk *chunk)
static void WaveFreeChunkData(WaveChunk *chunk)
{
if (chunk->data != NULL) {
SDL_free(chunk->data);
@@ -1519,8 +1502,7 @@ WaveFreeChunkData(WaveChunk *chunk)
chunk->size = 0;
}
static int
WaveNextChunk(SDL_RWops *src, WaveChunk *chunk)
static int WaveNextChunk(SDL_RWops *src, WaveChunk *chunk)
{
Uint32 chunkheader[2];
Sint64 nextposition = chunk->position + chunk->length;
@@ -1552,8 +1534,7 @@ WaveNextChunk(SDL_RWops *src, WaveChunk *chunk)
return 0;
}
static int
WaveReadPartialChunkData(SDL_RWops *src, WaveChunk *chunk, size_t length)
static int WaveReadPartialChunkData(SDL_RWops *src, WaveChunk *chunk, size_t length)
{
WaveFreeChunkData(chunk);
@@ -1562,7 +1543,7 @@ WaveReadPartialChunkData(SDL_RWops *src, WaveChunk *chunk, size_t length)
}
if (length > 0) {
chunk->data = (Uint8 *) SDL_malloc(length);
chunk->data = (Uint8 *)SDL_malloc(length);
if (chunk->data == NULL) {
return SDL_OutOfMemory();
}
@@ -1581,30 +1562,32 @@ WaveReadPartialChunkData(SDL_RWops *src, WaveChunk *chunk, size_t length)
return 0;
}
static int
WaveReadChunkData(SDL_RWops *src, WaveChunk *chunk)
static int WaveReadChunkData(SDL_RWops *src, WaveChunk *chunk)
{
return WaveReadPartialChunkData(src, chunk, chunk->length);
}
typedef struct WaveExtensibleGUID {
typedef struct WaveExtensibleGUID
{
Uint16 encoding;
Uint8 guid[16];
} WaveExtensibleGUID;
/* Some of the GUIDs that are used by WAVEFORMATEXTENSIBLE. */
#define WAVE_FORMATTAG_GUID(tag) {(tag) & 0xff, (tag) >> 8, 0, 0, 0, 0, 16, 0, 128, 0, 0, 170, 0, 56, 155, 113}
#define WAVE_FORMATTAG_GUID(tag) \
{ \
(tag) & 0xff, (tag) >> 8, 0, 0, 0, 0, 16, 0, 128, 0, 0, 170, 0, 56, 155, 113 \
}
static WaveExtensibleGUID extensible_guids[] = {
{PCM_CODE, WAVE_FORMATTAG_GUID(PCM_CODE)},
{MS_ADPCM_CODE, WAVE_FORMATTAG_GUID(MS_ADPCM_CODE)},
{IEEE_FLOAT_CODE, WAVE_FORMATTAG_GUID(IEEE_FLOAT_CODE)},
{ALAW_CODE, WAVE_FORMATTAG_GUID(ALAW_CODE)},
{MULAW_CODE, WAVE_FORMATTAG_GUID(MULAW_CODE)},
{IMA_ADPCM_CODE, WAVE_FORMATTAG_GUID(IMA_ADPCM_CODE)}
{ PCM_CODE, WAVE_FORMATTAG_GUID(PCM_CODE) },
{ MS_ADPCM_CODE, WAVE_FORMATTAG_GUID(MS_ADPCM_CODE) },
{ IEEE_FLOAT_CODE, WAVE_FORMATTAG_GUID(IEEE_FLOAT_CODE) },
{ ALAW_CODE, WAVE_FORMATTAG_GUID(ALAW_CODE) },
{ MULAW_CODE, WAVE_FORMATTAG_GUID(MULAW_CODE) },
{ IMA_ADPCM_CODE, WAVE_FORMATTAG_GUID(IMA_ADPCM_CODE) }
};
static Uint16
WaveGetFormatGUIDEncoding(WaveFormat *format)
static Uint16 WaveGetFormatGUIDEncoding(WaveFormat *format)
{
size_t i;
for (i = 0; i < SDL_arraysize(extensible_guids); i++) {
@@ -1615,8 +1598,7 @@ WaveGetFormatGUIDEncoding(WaveFormat *format)
return UNKNOWN_CODE;
}
static int
WaveReadFormat(WaveFile *file)
static int WaveReadFormat(WaveFile *file)
{
WaveChunk *chunk = &file->chunk;
WaveFormat *format = &file->format;
@@ -1677,8 +1659,7 @@ WaveReadFormat(WaveFile *file)
return 0;
}
static int
WaveCheckFormat(WaveFile *file, size_t datalength)
static int WaveCheckFormat(WaveFile *file, size_t datalength)
{
WaveFormat *format = &file->format;
@@ -1785,8 +1766,7 @@ WaveCheckFormat(WaveFile *file, size_t datalength)
return 0;
}
static int
WaveLoad(SDL_RWops *src, WaveFile *file, SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len)
static int WaveLoad(SDL_RWops *src, WaveFile *file, SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len)
{
int result;
Uint32 chunkcount = 0;
@@ -2051,7 +2031,7 @@ WaveLoad(SDL_RWops *src, WaveFile *file, SDL_AudioSpec *spec, Uint8 **audio_buf,
SDL_zerop(spec);
spec->freq = format->frequency;
spec->channels = (Uint8)format->channels;
spec->samples = 4096; /* Good default buffer size */
spec->samples = 4096; /* Good default buffer size */
switch (format->encoding) {
case MS_ADPCM_CODE:
@@ -2148,8 +2128,7 @@ SDL_LoadWAV_RW(SDL_RWops *src, int freesrc, SDL_AudioSpec *spec, Uint8 **audio_b
/* Since the WAV memory is allocated in the shared library, it must also
be freed here. (Necessary under Win32, VC++)
*/
void
SDL_FreeWAV(Uint8 *audio_buf)
void SDL_FreeWAV(Uint8 *audio_buf)
{
SDL_free(audio_buf);
}