Skip to content

Commit 45d6bcb

Browse files
Try to fix .wavs accidentally being generated/read with wrong endianness on big endian systems
1 parent f93bd37 commit 45d6bcb

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/Audio.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,14 @@ const char* const Sound_Names[SOUND_COUNT] = {
2525
"metal", "glass", "cloth", "sand", "snow",
2626
};
2727

28+
#ifdef CC_BIG_ENDIAN
29+
/* Hacky workaround to ensure that sounds are re-fetched on big endian systems, */
30+
/* as the .wav writing code at one point accidentally wrote big endian instead */
31+
/* of little endian samples to the .wav file */
32+
const cc_string Sounds_ZipPathMC = String_FromConst("audio/default2.zip");
33+
#else
2834
const cc_string Sounds_ZipPathMC = String_FromConst("audio/default.zip");
35+
#endif
2936
const cc_string Sounds_ZipPathCC = String_FromConst("audio/classicube.zip");
3037
static const cc_string audio_dir = String_FromConst("audio");
3138

@@ -90,7 +97,7 @@ static cc_result Sound_ReadWaveData(struct Stream* stream, struct Sound* snd) {
9097
if ((res = Audio_AllocChunks(size, &snd->chunk, 1))) return res;
9198
res = Stream_Read(stream, (cc_uint8*)snd->chunk.data, size);
9299

93-
#ifdef CC_BUILD_BIGENDIAN
100+
#ifdef CC_BIG_ENDIAN
94101
Utils_SwapEndian16((cc_int16*)snd->chunk.data, size / 2);
95102
#endif
96103
return res;

src/Resources.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ static cc_result SoundPatcher_WriteWav(struct Stream* s, struct VorbisState* ctx
473473
count = Vorbis_OutputFrame(ctx, samples);
474474
len += count * 2;
475475

476-
#ifdef CC_BUILD_BIGENDIAN
476+
#ifdef CC_BIG_ENDIAN
477477
Utils_SwapEndian16(samples, count);
478478
#endif
479479
res = Stream_Write(s, (cc_uint8*)samples, count * 2);

0 commit comments

Comments
 (0)