gosu 1.3.0 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/dependencies/SDL/include/SDL.h +108 -14
- data/dependencies/SDL/include/SDL_assert.h +81 -50
- data/dependencies/SDL/include/SDL_atomic.h +135 -35
- data/dependencies/SDL/include/SDL_audio.h +960 -355
- data/dependencies/SDL/include/SDL_bits.h +11 -6
- data/dependencies/SDL/include/SDL_blendmode.h +91 -14
- data/dependencies/SDL/include/SDL_clipboard.h +30 -7
- data/dependencies/SDL/include/SDL_config.h +277 -27
- data/dependencies/SDL/include/SDL_config_android.h +13 -38
- data/dependencies/SDL/include/SDL_config_iphoneos.h +21 -62
- data/dependencies/SDL/include/SDL_config_macosx.h +23 -92
- data/dependencies/SDL/include/SDL_config_minimal.h +1 -4
- data/dependencies/SDL/include/SDL_config_pandora.h +15 -22
- data/dependencies/SDL/include/SDL_config_psp.h +16 -37
- data/dependencies/SDL/include/SDL_config_windows.h +28 -91
- data/dependencies/SDL/include/SDL_config_winrt.h +33 -61
- data/dependencies/SDL/include/SDL_config_wiz.h +28 -56
- data/dependencies/SDL/include/SDL_copying.h +1 -1
- data/dependencies/SDL/include/SDL_cpuinfo.h +331 -71
- data/dependencies/SDL/include/SDL_egl.h +906 -280
- data/dependencies/SDL/include/SDL_endian.h +101 -47
- data/dependencies/SDL/include/SDL_error.h +70 -19
- data/dependencies/SDL/include/SDL_events.h +387 -79
- data/dependencies/SDL/include/SDL_filesystem.h +73 -64
- data/dependencies/SDL/include/SDL_gamecontroller.h +585 -125
- data/dependencies/SDL/include/SDL_gesture.h +36 -6
- data/dependencies/SDL/include/SDL_haptic.h +304 -210
- data/dependencies/SDL/include/SDL_hidapi.h +451 -0
- data/dependencies/SDL/include/SDL_hints.h +1286 -897
- data/dependencies/SDL/include/SDL_joystick.h +577 -130
- data/dependencies/SDL/include/SDL_keyboard.h +162 -63
- data/dependencies/SDL/include/SDL_keycode.h +7 -5
- data/dependencies/SDL/include/SDL_loadso.h +42 -8
- data/dependencies/SDL/include/SDL_locale.h +34 -32
- data/dependencies/SDL/include/SDL_log.h +212 -19
- data/dependencies/SDL/include/SDL_main.h +72 -17
- data/dependencies/SDL/include/SDL_messagebox.h +70 -23
- data/dependencies/SDL/include/SDL_metal.h +27 -32
- data/dependencies/SDL/include/SDL_misc.h +19 -15
- data/dependencies/SDL/include/SDL_mouse.h +262 -110
- data/dependencies/SDL/include/SDL_mutex.h +286 -66
- data/dependencies/SDL/include/SDL_name.h +1 -1
- data/dependencies/SDL/include/SDL_opengl.h +1 -1
- data/dependencies/SDL/include/SDL_opengles.h +1 -1
- data/dependencies/SDL/include/SDL_opengles2.h +2 -2
- data/dependencies/SDL/include/SDL_pixels.h +199 -34
- data/dependencies/SDL/include/SDL_platform.h +39 -2
- data/dependencies/SDL/include/SDL_power.h +23 -10
- data/dependencies/SDL/include/SDL_quit.h +1 -1
- data/dependencies/SDL/include/SDL_rect.h +78 -28
- data/dependencies/SDL/include/SDL_render.h +1204 -472
- data/dependencies/SDL/include/SDL_revision.h +2 -2
- data/dependencies/SDL/include/SDL_rwops.h +605 -33
- data/dependencies/SDL/include/SDL_scancode.h +1 -1
- data/dependencies/SDL/include/SDL_sensor.h +76 -42
- data/dependencies/SDL/include/SDL_shape.h +38 -27
- data/dependencies/SDL/include/SDL_stdinc.h +96 -24
- data/dependencies/SDL/include/SDL_surface.h +571 -139
- data/dependencies/SDL/include/SDL_system.h +339 -101
- data/dependencies/SDL/include/SDL_syswm.h +50 -20
- data/dependencies/SDL/include/SDL_test.h +1 -1
- data/dependencies/SDL/include/SDL_test_assert.h +2 -2
- data/dependencies/SDL/include/SDL_test_common.h +23 -6
- data/dependencies/SDL/include/SDL_test_compare.h +1 -1
- data/dependencies/SDL/include/SDL_test_crc32.h +1 -1
- data/dependencies/SDL/include/SDL_test_font.h +3 -3
- data/dependencies/SDL/include/SDL_test_fuzzer.h +28 -26
- data/dependencies/SDL/include/SDL_test_harness.h +6 -6
- data/dependencies/SDL/include/SDL_test_images.h +1 -1
- data/dependencies/SDL/include/SDL_test_log.h +1 -1
- data/dependencies/SDL/include/SDL_test_md5.h +1 -1
- data/dependencies/SDL/include/SDL_test_memory.h +1 -1
- data/dependencies/SDL/include/SDL_test_random.h +2 -2
- data/dependencies/SDL/include/SDL_thread.h +226 -128
- data/dependencies/SDL/include/SDL_timer.h +129 -22
- data/dependencies/SDL/include/SDL_touch.h +48 -8
- data/dependencies/SDL/include/SDL_types.h +1 -1
- data/dependencies/SDL/include/SDL_version.h +72 -46
- data/dependencies/SDL/include/SDL_video.h +1266 -460
- data/dependencies/SDL/include/SDL_vulkan.h +100 -161
- data/dependencies/SDL/include/begin_code.h +22 -1
- data/dependencies/SDL/include/close_code.h +1 -1
- data/dependencies/SDL/lib/x64/libSDL2.dll.a +0 -0
- data/dependencies/SDL/lib/x86/libSDL2.dll.a +0 -0
- data/dependencies/SDL_sound/SDL_sound.c +83 -7
- data/dependencies/SDL_sound/SDL_sound.h +4 -4
- data/dependencies/SDL_sound/SDL_sound_aiff.c +9 -12
- data/dependencies/SDL_sound/SDL_sound_au.c +7 -7
- data/dependencies/SDL_sound/SDL_sound_coreaudio.c +3 -3
- data/dependencies/SDL_sound/SDL_sound_flac.c +1 -1
- data/dependencies/SDL_sound/SDL_sound_internal.h +17 -10
- data/dependencies/SDL_sound/SDL_sound_modplug.c +25 -27
- data/dependencies/SDL_sound/SDL_sound_mp3.c +5 -17
- data/dependencies/SDL_sound/SDL_sound_raw.c +11 -11
- data/dependencies/SDL_sound/SDL_sound_shn.c +8 -7
- data/dependencies/SDL_sound/SDL_sound_voc.c +6 -4
- data/dependencies/SDL_sound/SDL_sound_vorbis.c +6 -11
- data/dependencies/SDL_sound/SDL_sound_wav.c +35 -29
- data/dependencies/SDL_sound/dr_flac.h +618 -220
- data/dependencies/SDL_sound/dr_mp3.h +263 -94
- data/dependencies/SDL_sound/libmodplug/fastmix.c +58 -64
- data/dependencies/SDL_sound/libmodplug/libmodplug.h +25 -103
- data/dependencies/SDL_sound/libmodplug/load_669.c +14 -17
- data/dependencies/SDL_sound/libmodplug/load_amf.c +11 -7
- data/dependencies/SDL_sound/libmodplug/load_ams.c +65 -22
- data/dependencies/SDL_sound/libmodplug/load_dbm.c +8 -4
- data/dependencies/SDL_sound/libmodplug/load_dmf.c +55 -25
- data/dependencies/SDL_sound/libmodplug/load_far.c +9 -13
- data/dependencies/SDL_sound/libmodplug/load_gdm.c +448 -0
- data/dependencies/SDL_sound/libmodplug/load_it.c +45 -49
- data/dependencies/SDL_sound/libmodplug/load_mdl.c +80 -53
- data/dependencies/SDL_sound/libmodplug/load_med.c +20 -12
- data/dependencies/SDL_sound/libmodplug/load_mod.c +40 -15
- data/dependencies/SDL_sound/libmodplug/load_mt2.c +29 -17
- data/dependencies/SDL_sound/libmodplug/load_okt.c +12 -8
- data/dependencies/SDL_sound/libmodplug/load_psm.c +101 -78
- data/dependencies/SDL_sound/libmodplug/load_ptm.c +18 -17
- data/dependencies/SDL_sound/libmodplug/load_s3m.c +9 -7
- data/dependencies/SDL_sound/libmodplug/load_stm.c +3 -2
- data/dependencies/SDL_sound/libmodplug/load_ult.c +2 -2
- data/dependencies/SDL_sound/libmodplug/load_umx.c +315 -35
- data/dependencies/SDL_sound/libmodplug/load_xm.c +25 -21
- data/dependencies/SDL_sound/libmodplug/mmcmp.c +295 -149
- data/dependencies/SDL_sound/libmodplug/modplug.c +7 -123
- data/dependencies/SDL_sound/libmodplug/modplug.h +32 -29
- data/dependencies/SDL_sound/libmodplug/snd_dsp.c +0 -1
- data/dependencies/SDL_sound/libmodplug/snd_flt.c +2 -2
- data/dependencies/SDL_sound/libmodplug/snd_fx.c +24 -18
- data/dependencies/SDL_sound/libmodplug/sndfile.c +55 -156
- data/dependencies/SDL_sound/libmodplug/sndmix.c +7 -12
- data/dependencies/SDL_sound/libmodplug/tables.h +10 -15
- data/dependencies/SDL_sound/stb_vorbis.h +508 -325
- data/dependencies/{al_soft → mojoAL}/AL/al.h +38 -30
- data/dependencies/{al_soft → mojoAL}/AL/alc.h +27 -56
- data/dependencies/mojoAL/mojoal.c +4594 -0
- data/ext/gosu/extconf.rb +29 -30
- data/include/Gosu/Audio.hpp +70 -85
- data/include/Gosu/Color.hpp +19 -11
- data/include/Gosu/Font.hpp +40 -44
- data/include/Gosu/Graphics.hpp +58 -71
- data/include/Gosu/GraphicsBase.hpp +26 -33
- data/include/Gosu/Image.hpp +56 -62
- data/include/Gosu/ImageData.hpp +23 -27
- data/include/Gosu/Inspection.hpp +1 -4
- data/include/Gosu/TextInput.hpp +34 -40
- data/include/Gosu/Version.hpp +1 -1
- data/include/Gosu/Window.hpp +71 -70
- data/lib/SDL2.dll +0 -0
- data/lib/gosu/compat.rb +24 -37
- data/lib/gosu.rb +2 -2
- data/lib64/SDL2.dll +0 -0
- data/src/Audio.cpp +86 -86
- data/src/AudioFile.hpp +6 -6
- data/src/AudioFileAudioToolbox.cpp +1 -1
- data/src/AudioFileSDLSound.cpp +1 -1
- data/src/AudioImpl.hpp +5 -5
- data/src/BitmapIO.cpp +0 -20
- data/src/BlockAllocator.cpp +2 -1
- data/src/Channel.cpp +22 -20
- data/src/Color.cpp +12 -9
- data/src/EmptyImageData.hpp +15 -17
- data/src/FileUnix.cpp +1 -1
- data/src/FileWin.cpp +1 -1
- data/src/Font.cpp +48 -53
- data/src/Graphics.cpp +135 -143
- data/src/Image.cpp +41 -42
- data/src/Input.cpp +1 -1
- data/src/InputUIKit.cpp +1 -1
- data/src/LargeImageData.cpp +108 -101
- data/src/LargeImageData.hpp +17 -15
- data/src/Log.hpp +6 -6
- data/src/Macro.cpp +35 -37
- data/src/Macro.hpp +11 -11
- data/src/Math.cpp +8 -1
- data/src/Resolution.cpp +12 -7
- data/src/RubyGosu.cxx +5 -5
- data/src/TexChunk.cpp +50 -41
- data/src/TexChunk.hpp +22 -22
- data/src/Text.cpp +37 -37
- data/src/TextBuilder.cpp +60 -57
- data/src/TextBuilder.hpp +20 -20
- data/src/TextInput.cpp +127 -135
- data/src/TrueTypeFont.cpp +107 -107
- data/src/TrueTypeFont.hpp +39 -38
- data/src/TrueTypeFontApple.cpp +19 -22
- data/src/TrueTypeFontUnix.cpp +21 -26
- data/src/TrueTypeFontWin.cpp +30 -30
- data/src/Window.cpp +95 -86
- data/src/WindowUIKit.cpp +46 -49
- metadata +7 -17
- data/dependencies/SDL/include/SDL_config_os2.h +0 -188
- data/dependencies/SDL_sound/libmodplug/load_abc.c +0 -4725
- data/dependencies/SDL_sound/libmodplug/load_mid.c +0 -1405
- data/dependencies/SDL_sound/libmodplug/load_pat.c +0 -1143
- data/dependencies/SDL_sound/libmodplug/load_pat.h +0 -25
- data/dependencies/al_soft/AL/alext.h +0 -585
- data/dependencies/al_soft/AL/efx-creative.h +0 -3
- data/dependencies/al_soft/AL/efx-presets.h +0 -402
- data/dependencies/al_soft/AL/efx.h +0 -762
- data/dependencies/al_soft/x64/libOpenAL32.dll.a +0 -0
- data/dependencies/al_soft/x86/libOpenAL32.dll.a +0 -0
- data/lib/OpenAL32.dll +0 -0
- data/lib64/OpenAL32.dll +0 -0
@@ -194,8 +194,8 @@ SInt64 CoreAudio_SizeCallback(void* inClientData)
|
|
194
194
|
{
|
195
195
|
SDL_RWops* rw_ops = (SDL_RWops*)inClientData;
|
196
196
|
SInt64 current_position = SDL_RWtell(rw_ops);
|
197
|
-
SInt64 end_position = SDL_RWseek(rw_ops, 0,
|
198
|
-
SDL_RWseek(rw_ops, current_position,
|
197
|
+
SInt64 end_position = SDL_RWseek(rw_ops, 0, RW_SEEK_END);
|
198
|
+
SDL_RWseek(rw_ops, current_position, RW_SEEK_SET);
|
199
199
|
// fprintf(stderr, "CoreAudio_SizeCallback:%d\n", end_position);
|
200
200
|
|
201
201
|
return end_position;
|
@@ -210,7 +210,7 @@ OSStatus CoreAudio_ReadCallback(
|
|
210
210
|
)
|
211
211
|
{
|
212
212
|
SDL_RWops* rw_ops = (SDL_RWops*)inClientData;
|
213
|
-
SDL_RWseek(rw_ops, inPosition,
|
213
|
+
SDL_RWseek(rw_ops, inPosition, RW_SEEK_SET);
|
214
214
|
size_t bytes_actually_read = SDL_RWread(rw_ops, data_buffer, 1, requestCount);
|
215
215
|
// Not sure how to test for a read error with SDL_RWops
|
216
216
|
// fprintf(stderr, "CoreAudio_ReadCallback:%d, %d\n", requestCount, bytes_actually_read);
|
@@ -55,7 +55,7 @@ static size_t flac_read(void* pUserData, void* pBufferOut, size_t bytesToRead)
|
|
55
55
|
sample->flags |= SOUND_SAMPLEFLAG_EOF;
|
56
56
|
break;
|
57
57
|
} /* if */
|
58
|
-
else if (
|
58
|
+
else if (rc == -1) /** FIXME: this error check is broken **/
|
59
59
|
{
|
60
60
|
sample->flags |= SOUND_SAMPLEFLAG_ERROR;
|
61
61
|
break;
|
@@ -18,14 +18,9 @@
|
|
18
18
|
#error Do not include this header from your applications.
|
19
19
|
#endif
|
20
20
|
|
21
|
-
#include <stdio.h>
|
22
|
-
#include <stdlib.h>
|
23
|
-
#include <string.h>
|
24
|
-
#include <math.h>
|
25
|
-
|
26
21
|
#include "SDL_sound.h"
|
27
22
|
|
28
|
-
#if (defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__)
|
23
|
+
#if ((defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__)) && !(defined(_WIN32) || defined(__OS2__))
|
29
24
|
#define SOUND_HAVE_PRAGMA_VISIBILITY 1
|
30
25
|
#endif
|
31
26
|
|
@@ -34,11 +29,14 @@
|
|
34
29
|
#endif
|
35
30
|
|
36
31
|
#if (defined DEBUG_CHATTER)
|
37
|
-
#define SNDDBG(x)
|
32
|
+
#define SNDDBG(x) SDL_Log x
|
38
33
|
#else
|
39
34
|
#define SNDDBG(x)
|
40
35
|
#endif
|
41
36
|
|
37
|
+
#ifndef SOUND_SUPPORTS_MIDI
|
38
|
+
#define SOUND_SUPPORTS_MIDI 0
|
39
|
+
#endif
|
42
40
|
#ifndef SOUND_SUPPORTS_MP3
|
43
41
|
#define SOUND_SUPPORTS_MP3 1
|
44
42
|
#endif
|
@@ -86,7 +84,7 @@
|
|
86
84
|
* SDL_sound that rely on it, though.
|
87
85
|
* !!! FIXME: SDL2 supports more channels.
|
88
86
|
*/
|
89
|
-
#define
|
87
|
+
#define SOUND_MAX_CHANNELS 2
|
90
88
|
|
91
89
|
|
92
90
|
typedef struct __SOUND_DECODERFUNCTIONS__
|
@@ -294,10 +292,19 @@ Uint32 __Sound_convertMsToBytePos(Sound_AudioInfo *info, Uint32 ms);
|
|
294
292
|
#define BAIL_MACRO(e, r) { __Sound_SetError(e); return r; }
|
295
293
|
#define BAIL_IF_MACRO(c, e, r) if (c) { __Sound_SetError(e); return r; }
|
296
294
|
|
297
|
-
#
|
298
|
-
|
295
|
+
#if SDL_VERSION_ATLEAST(2,0,12)
|
296
|
+
#define HAVE_SDL_STRTOKR
|
297
|
+
#else
|
298
|
+
#define SDL_strtokr __Sound_strtokr
|
299
|
+
extern char *SDL_strtokr(char *s1, const char *s2, char **saveptr);
|
299
300
|
#endif
|
300
301
|
|
302
|
+
/* SDL doesn't provide a rand() replacement */
|
303
|
+
#define SDL_rand __Sound_rand
|
304
|
+
#define SDL_srand __Sound_srand
|
305
|
+
extern int SDL_rand(void);
|
306
|
+
extern void SDL_srand(unsigned int seed);
|
307
|
+
|
301
308
|
#endif /* defined _INCLUDE_SDL_SOUND_INTERNAL_H_ */
|
302
309
|
|
303
310
|
/* end of SDL_sound_internal.h ... */
|
@@ -36,6 +36,7 @@ static const char *extensions_modplug[] =
|
|
36
36
|
"DMF", /* DMF DELUSION DIGITAL MUSIC FILEFORMAT (X-Tracker) */
|
37
37
|
"DSM", /* DSIK Internal Format module */
|
38
38
|
"FAR", /* Farandole module */
|
39
|
+
"GDM", /* General Digital Music */
|
39
40
|
"IT", /* Impulse Tracker IT file */
|
40
41
|
"MDL", /* DigiTracker module */
|
41
42
|
"MED", /* OctaMed MED file */
|
@@ -50,9 +51,6 @@ static const char *extensions_modplug[] =
|
|
50
51
|
"ULT",
|
51
52
|
"UMX",
|
52
53
|
"XM", /* FastTracker II */
|
53
|
-
"ABC",
|
54
|
-
"MID",
|
55
|
-
"MIDI",
|
56
54
|
NULL
|
57
55
|
};
|
58
56
|
|
@@ -81,53 +79,53 @@ static int MODPLUG_open(Sound_Sample *sample, const char *ext)
|
|
81
79
|
ModPlug_Settings settings;
|
82
80
|
Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque;
|
83
81
|
ModPlugFile *module;
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
int has_extension = 0;
|
82
|
+
void *data;
|
83
|
+
Sint64 size;
|
84
|
+
size_t retval;
|
88
85
|
int i;
|
89
86
|
|
90
87
|
/*
|
91
88
|
* Apparently ModPlug's loaders are too forgiving. They gladly accept
|
92
89
|
* streams that they shouldn't. For now, rely on file extension instead.
|
93
90
|
*/
|
94
|
-
for (i = 0; extensions_modplug[i] != NULL; i++)
|
91
|
+
for (i = 0; ext != NULL && extensions_modplug[i] != NULL; i++)
|
95
92
|
{
|
96
93
|
if (SDL_strcasecmp(ext, extensions_modplug[i]) == 0)
|
97
|
-
{
|
98
|
-
has_extension = 1;
|
99
94
|
break;
|
100
|
-
} /* if */
|
101
95
|
} /* for */
|
102
96
|
|
103
|
-
if (
|
97
|
+
if (ext == NULL || extensions_modplug[i] == NULL)
|
104
98
|
{
|
105
99
|
SNDDBG(("MODPLUG: Unrecognized file type: %s\n", ext));
|
106
100
|
BAIL_MACRO("MODPLUG: Not a module file.", 0);
|
107
101
|
} /* if */
|
108
|
-
|
102
|
+
|
109
103
|
/* ModPlug needs the entire stream in one big chunk. I don't like it,
|
110
104
|
but I don't think there's any way around it. !!! FIXME: rework modplug? */
|
111
|
-
|
112
|
-
BAIL_IF_MACRO(
|
113
|
-
size = 0;
|
105
|
+
size = SDL_RWsize(internal->rw);
|
106
|
+
BAIL_IF_MACRO(size <= 0 || size > (Sint64)0x7fffffff, "MODPLUG: Not a module file.", 0);
|
114
107
|
|
115
|
-
|
108
|
+
if (internal->rw->type == SDL_RWOPS_MEMORY || internal->rw->type == SDL_RWOPS_MEMORY_RO)
|
109
|
+
{
|
110
|
+
data = internal->rw->hidden.mem.base;
|
111
|
+
retval = 0;
|
112
|
+
}
|
113
|
+
else
|
116
114
|
{
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
} /* if */
|
124
|
-
} while (retval > 0);
|
115
|
+
data = SDL_malloc((size_t) size);
|
116
|
+
BAIL_IF_MACRO(data == NULL, ERR_OUT_OF_MEMORY, 0);
|
117
|
+
retval = SDL_RWread(internal->rw, data, 1, size);
|
118
|
+
if (retval != (size_t)size) SDL_free(data);
|
119
|
+
BAIL_IF_MACRO(retval != (size_t)size, ERR_IO_ERROR, 0);
|
120
|
+
}
|
125
121
|
|
126
122
|
SDL_memcpy(&sample->actual, &sample->desired, sizeof (Sound_AudioInfo));
|
127
123
|
if (sample->actual.rate == 0) sample->actual.rate = 44100;
|
128
124
|
if (sample->actual.channels == 0) sample->actual.channels = 2;
|
129
125
|
if (sample->actual.format == 0) sample->actual.format = AUDIO_S16SYS;
|
130
126
|
|
127
|
+
SDL_zero(settings);
|
128
|
+
|
131
129
|
settings.mChannels=sample->actual.channels;
|
132
130
|
settings.mFrequency=sample->actual.rate;
|
133
131
|
settings.mBits = sample->actual.format & 0xFF;
|
@@ -153,8 +151,8 @@ static int MODPLUG_open(Sound_Sample *sample, const char *ext)
|
|
153
151
|
|
154
152
|
/* The buffer may be a bit too large, but that doesn't matter. I think
|
155
153
|
it's safe to free it as soon as ModPlug_Load() is finished anyway. */
|
156
|
-
module = ModPlug_Load((
|
157
|
-
SDL_free(data);
|
154
|
+
module = ModPlug_Load(data, (int) size, &settings);
|
155
|
+
if (retval) SDL_free(data);
|
158
156
|
BAIL_IF_MACRO(module == NULL, "MODPLUG: Not a module file.", 0);
|
159
157
|
|
160
158
|
internal->total_time = ModPlug_GetLength(module);
|
@@ -9,7 +9,7 @@
|
|
9
9
|
/*
|
10
10
|
* MP3 decoder for SDL_sound.
|
11
11
|
*
|
12
|
-
*
|
12
|
+
* Uses dr_mp3, a public domain, single-header library.
|
13
13
|
*
|
14
14
|
* dr_mp3 is here: https://github.com/mackron/dr_libs/
|
15
15
|
*/
|
@@ -20,29 +20,17 @@
|
|
20
20
|
#if SOUND_SUPPORTS_MP3
|
21
21
|
|
22
22
|
#define DR_MP3_IMPLEMENTATION
|
23
|
+
|
23
24
|
#define DR_MP3_NO_STDIO 1
|
25
|
+
#define DR_MP3_FLOAT_OUTPUT 1
|
24
26
|
#define DRMP3_ASSERT(x) SDL_assert((x))
|
25
27
|
#define DRMP3_MALLOC(sz) SDL_malloc((sz))
|
26
28
|
#define DRMP3_REALLOC(p, sz) SDL_realloc((p), (sz))
|
27
29
|
#define DRMP3_FREE(p) SDL_free((p))
|
28
30
|
#define DRMP3_COPY_MEMORY(dst, src, sz) SDL_memcpy((dst), (src), (sz))
|
31
|
+
#define DRMP3_MOVE_MEMORY(dst, src, sz) SDL_memmove((dst), (src), (sz))
|
29
32
|
#define DRMP3_ZERO_MEMORY(p, sz) SDL_memset((p), 0, (sz))
|
30
33
|
|
31
|
-
#if !defined(__clang_analyzer__)
|
32
|
-
#ifdef memset
|
33
|
-
#undef memset
|
34
|
-
#endif
|
35
|
-
#ifdef memcpy
|
36
|
-
#undef memcpy
|
37
|
-
#endif
|
38
|
-
#ifdef memmove
|
39
|
-
#undef memmove
|
40
|
-
#endif
|
41
|
-
#define memset SDL_memset
|
42
|
-
#define memcpy SDL_memcpy
|
43
|
-
#define memmove SDL_memmove
|
44
|
-
#endif
|
45
|
-
|
46
34
|
#include "dr_mp3.h"
|
47
35
|
|
48
36
|
static size_t mp3_read(void* pUserData, void* pBufferOut, size_t bytesToRead)
|
@@ -62,7 +50,7 @@ static size_t mp3_read(void* pUserData, void* pBufferOut, size_t bytesToRead)
|
|
62
50
|
sample->flags |= SOUND_SAMPLEFLAG_EOF;
|
63
51
|
break;
|
64
52
|
} /* if */
|
65
|
-
else if (
|
53
|
+
else if (rc == -1) /** FIXME: this error check is broken **/
|
66
54
|
{
|
67
55
|
sample->flags |= SOUND_SAMPLEFLAG_ERROR;
|
68
56
|
break;
|
@@ -43,14 +43,14 @@ static void RAW_quit(void)
|
|
43
43
|
static int RAW_open(Sound_Sample *sample, const char *ext)
|
44
44
|
{
|
45
45
|
Sound_SampleInternal *internal = sample->opaque;
|
46
|
-
|
47
|
-
Uint32
|
48
|
-
|
46
|
+
Sint64 pos;
|
47
|
+
Uint32 sample_rate;
|
48
|
+
|
49
49
|
/*
|
50
50
|
* We check this explicitly, since we have no other way to
|
51
51
|
* determine whether we should handle this data or not.
|
52
52
|
*/
|
53
|
-
if (SDL_strcasecmp(ext, "RAW") != 0)
|
53
|
+
if (!ext || SDL_strcasecmp(ext, "RAW") != 0)
|
54
54
|
BAIL_MACRO("RAW: extension isn't explicitly \"RAW\".", 0);
|
55
55
|
|
56
56
|
/*
|
@@ -73,11 +73,11 @@ static int RAW_open(Sound_Sample *sample, const char *ext)
|
|
73
73
|
SDL_memcpy(&sample->actual, &sample->desired, sizeof (Sound_AudioInfo));
|
74
74
|
sample->flags = SOUND_SAMPLEFLAG_CANSEEK;
|
75
75
|
|
76
|
-
if (
|
77
|
-
BAIL_MACRO("RAW:
|
76
|
+
if ((pos = SDL_RWseek(internal->rw, 0, RW_SEEK_END)) <= 0) {
|
77
|
+
BAIL_MACRO("RAW: can't seek to the end of the file.", 0);
|
78
78
|
}
|
79
|
-
if ( SDL_RWseek(internal->rw, 0,
|
80
|
-
BAIL_MACRO("RAW:
|
79
|
+
if ( SDL_RWseek(internal->rw, 0, RW_SEEK_SET) != 0) {
|
80
|
+
BAIL_MACRO("RAW: can't reset file.", 0);
|
81
81
|
}
|
82
82
|
|
83
83
|
sample_rate = (sample->actual.rate * sample->actual.channels
|
@@ -111,7 +111,7 @@ static Uint32 RAW_read(Sound_Sample *sample)
|
|
111
111
|
if (retval == 0)
|
112
112
|
sample->flags |= SOUND_SAMPLEFLAG_EOF;
|
113
113
|
|
114
|
-
else if (retval == -1)
|
114
|
+
else if (retval == -1) /** FIXME: this error check is broken **/
|
115
115
|
sample->flags |= SOUND_SAMPLEFLAG_ERROR;
|
116
116
|
|
117
117
|
/* (next call this EAGAIN may turn into an EOF or error.) */
|
@@ -125,7 +125,7 @@ static Uint32 RAW_read(Sound_Sample *sample)
|
|
125
125
|
static int RAW_rewind(Sound_Sample *sample)
|
126
126
|
{
|
127
127
|
Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque;
|
128
|
-
BAIL_IF_MACRO(SDL_RWseek(internal->rw, 0,
|
128
|
+
BAIL_IF_MACRO(SDL_RWseek(internal->rw, 0, RW_SEEK_SET) != 0, ERR_IO_ERROR, 0);
|
129
129
|
return 1;
|
130
130
|
} /* RAW_rewind */
|
131
131
|
|
@@ -134,7 +134,7 @@ static int RAW_seek(Sound_Sample *sample, Uint32 ms)
|
|
134
134
|
{
|
135
135
|
Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque;
|
136
136
|
int pos = (int) __Sound_convertMsToBytePos(&sample->actual, ms);
|
137
|
-
int err = (SDL_RWseek(internal->rw, pos,
|
137
|
+
int err = (SDL_RWseek(internal->rw, pos, RW_SEEK_SET) != pos);
|
138
138
|
BAIL_IF_MACRO(err, ERR_IO_ERROR, 0);
|
139
139
|
return 1;
|
140
140
|
} /* RAW_seek */
|
@@ -174,6 +174,10 @@ static const Uint8 ulaw_outward[13][256] = {
|
|
174
174
|
#define M_PI 3.14159265358979323846
|
175
175
|
#endif
|
176
176
|
|
177
|
+
#if defined(HAVE_LIBC) && defined(__WATCOMC__) /* Watcom has issues... */
|
178
|
+
#define SDL_log log
|
179
|
+
#endif
|
180
|
+
|
177
181
|
|
178
182
|
static int word_get(shn_t *shn, SDL_RWops *rw, Uint32 *word)
|
179
183
|
{
|
@@ -331,7 +335,7 @@ static SDL_INLINE int determine_shn_version(Sound_Sample *sample,
|
|
331
335
|
* check the whole stream, though.
|
332
336
|
*/
|
333
337
|
|
334
|
-
if (SDL_strcasecmp(ext, "shn") == 0)
|
338
|
+
if (ext != NULL && SDL_strcasecmp(ext, "shn") == 0)
|
335
339
|
return extended_shn_magic_search(sample);
|
336
340
|
|
337
341
|
BAIL_IF_MACRO(SDL_RWread(rw, &magic, sizeof (magic), 1) != 1, NULL, -1);
|
@@ -1016,14 +1020,11 @@ static Uint32 SHN_read(Sound_Sample *sample)
|
|
1016
1020
|
{
|
1017
1021
|
Uint32 retval = 0;
|
1018
1022
|
Sint32 chan = 0;
|
1019
|
-
Uint32 cpyBytes = 0;
|
1020
1023
|
Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque;
|
1021
1024
|
SDL_RWops *rw = internal->rw;
|
1022
1025
|
shn_t *shn = (shn_t *) internal->decoder_private;
|
1023
1026
|
Sint32 cmd;
|
1024
1027
|
|
1025
|
-
SDL_assert(shn->backBufLeft >= 0);
|
1026
|
-
|
1027
1028
|
/* see if there are leftovers to copy... */
|
1028
1029
|
if (shn->backBufLeft > 0)
|
1029
1030
|
{
|
@@ -1253,10 +1254,10 @@ static Uint32 SHN_read(Sound_Sample *sample)
|
|
1253
1254
|
static int SHN_rewind(Sound_Sample *sample)
|
1254
1255
|
{
|
1255
1256
|
Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque;
|
1256
|
-
shn_t *shn = (shn_t *) internal->decoder_private;
|
1257
1257
|
|
1258
1258
|
#if 0
|
1259
|
-
|
1259
|
+
shn_t *shn = (shn_t *) internal->decoder_private;
|
1260
|
+
int rc = SDL_RWseek(internal->rw, shn->start_pos, RW_SEEK_SET);
|
1260
1261
|
BAIL_IF_MACRO(rc != shn->start_pos, ERR_IO_ERROR, 0);
|
1261
1262
|
/* !!! FIXME: set state. */
|
1262
1263
|
return 1;
|
@@ -1267,7 +1268,7 @@ static int SHN_rewind(Sound_Sample *sample)
|
|
1267
1268
|
* !!! FIXME: to decode. The below kludge adds unneeded overhead and
|
1268
1269
|
* !!! FIXME: risk of failure.
|
1269
1270
|
*/
|
1270
|
-
BAIL_IF_MACRO(SDL_RWseek(internal->rw, 0,
|
1271
|
+
BAIL_IF_MACRO(SDL_RWseek(internal->rw, 0, RW_SEEK_SET) != 0, ERR_IO_ERROR, 0);
|
1271
1272
|
SHN_close(sample);
|
1272
1273
|
return SHN_open(sample, "SHN");
|
1273
1274
|
#endif
|
@@ -122,7 +122,7 @@ static SDL_INLINE int voc_check_header(SDL_RWops *src)
|
|
122
122
|
|
123
123
|
datablockofs = SDL_SwapLE16(datablockofs);
|
124
124
|
|
125
|
-
if (SDL_RWseek(src, datablockofs,
|
125
|
+
if (SDL_RWseek(src, datablockofs, RW_SEEK_SET) != datablockofs)
|
126
126
|
{
|
127
127
|
BAIL_MACRO("VOC: Failed to seek to data block.", 0);
|
128
128
|
} /* if */
|
@@ -303,6 +303,8 @@ static int voc_get_block(Sound_Sample *sample, vs_t *v)
|
|
303
303
|
|
304
304
|
if (uc)
|
305
305
|
sample->actual.channels = 2; /* Stereo */
|
306
|
+
/* VOC_EXTENDED may be read before spec->channels inited: */
|
307
|
+
else sample->actual.channels = 1;
|
306
308
|
|
307
309
|
/* Needed number of channels before finishing
|
308
310
|
compute for rate */
|
@@ -386,7 +388,7 @@ static int voc_read_waveform(Sound_Sample *sample, int fill_buf, Uint32 max)
|
|
386
388
|
cur = SDL_RWtell(src);
|
387
389
|
if (cur >= 0)
|
388
390
|
{
|
389
|
-
rc = SDL_RWseek(src, max,
|
391
|
+
rc = SDL_RWseek(src, max, RW_SEEK_CUR);
|
390
392
|
if (rc >= 0)
|
391
393
|
done = rc - cur;
|
392
394
|
else
|
@@ -480,7 +482,7 @@ static int VOC_rewind(Sound_Sample *sample)
|
|
480
482
|
{
|
481
483
|
Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque;
|
482
484
|
vs_t *v = (vs_t *) internal->decoder_private;
|
483
|
-
int rc = SDL_RWseek(internal->rw, v->start_pos,
|
485
|
+
int rc = SDL_RWseek(internal->rw, v->start_pos, RW_SEEK_SET);
|
484
486
|
BAIL_IF_MACRO(rc != v->start_pos, ERR_IO_ERROR, 0);
|
485
487
|
v->rest = 0;
|
486
488
|
return 1;
|
@@ -514,7 +516,7 @@ static int VOC_seek(Sound_Sample *sample, Uint32 ms)
|
|
514
516
|
Uint32 rc = voc_read_waveform(sample, 0, offset);
|
515
517
|
if ( (rc == 0) || (!voc_get_block(sample, v)) )
|
516
518
|
{
|
517
|
-
SDL_RWseek(internal->rw, origpos,
|
519
|
+
SDL_RWseek(internal->rw, origpos, RW_SEEK_SET);
|
518
520
|
v->rest = origrest;
|
519
521
|
return 0;
|
520
522
|
} /* if */
|
@@ -28,6 +28,7 @@
|
|
28
28
|
#define STB_VORBIS_NO_PUSHDATA_API 1
|
29
29
|
#define STB_VORBIS_MAX_CHANNELS 6
|
30
30
|
#define STBV_CDECL
|
31
|
+
#define STB_VORBIS_NO_COMMENTS 1
|
31
32
|
#define STB_FORCEINLINE SDL_FORCE_INLINE
|
32
33
|
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
|
33
34
|
#define STB_VORBIS_BIG_ENDIAN 1
|
@@ -43,26 +44,20 @@
|
|
43
44
|
#ifdef memcpy
|
44
45
|
#undef memcpy
|
45
46
|
#endif
|
46
|
-
#ifdef alloca
|
47
|
-
#undef alloca
|
48
|
-
#endif
|
49
47
|
#define assert SDL_assert
|
50
48
|
#define memset SDL_memset
|
51
49
|
#define memcmp SDL_memcmp
|
52
50
|
#define memcpy SDL_memcpy
|
53
51
|
#define qsort SDL_qsort
|
54
|
-
#define pow SDL_pow
|
55
|
-
#define floor SDL_floor
|
56
52
|
#define malloc SDL_malloc
|
57
53
|
#define realloc SDL_realloc
|
58
54
|
#define free SDL_free
|
55
|
+
/* there is no 'dealloca' in stb_vorbis: we need alloca()
|
56
|
+
#ifdef alloca
|
57
|
+
#undef alloca
|
58
|
+
#endif
|
59
59
|
#define alloca(x) ((void *) SDL_stack_alloc(Uint8, (x)))
|
60
|
-
|
61
|
-
#define ldexp(v, e) SDL_scalbn((v), (e))
|
62
|
-
#define abs(x) SDL_abs(x)
|
63
|
-
#define cos(x) SDL_cos(x)
|
64
|
-
#define sin(x) SDL_sin(x)
|
65
|
-
#define log(x) SDL_log(x)
|
60
|
+
*/
|
66
61
|
#endif
|
67
62
|
#include "stb_vorbis.h"
|
68
63
|
|
@@ -72,6 +72,7 @@ static SDL_INLINE int read_uint8(SDL_RWops *rw, Uint8 *ui8)
|
|
72
72
|
|
73
73
|
#define FMT_NORMAL 0x0001 /* Uncompressed waveform data. */
|
74
74
|
#define FMT_ADPCM 0x0002 /* ADPCM compressed waveform data. */
|
75
|
+
#define FMT_IEEE_FLOAT 0x0003 /* Uncompressed IEEE floating point waveform data. */
|
75
76
|
|
76
77
|
typedef struct
|
77
78
|
{
|
@@ -226,7 +227,7 @@ static Uint32 read_sample_fmt_normal(Sound_Sample *sample)
|
|
226
227
|
if ((retval == 0) || (w->bytesLeft == 0))
|
227
228
|
sample->flags |= SOUND_SAMPLEFLAG_EOF;
|
228
229
|
|
229
|
-
else if (retval == -1)
|
230
|
+
else if (retval == -1) /** FIXME: this error check is broken **/
|
230
231
|
sample->flags |= SOUND_SAMPLEFLAG_ERROR;
|
231
232
|
|
232
233
|
/* (next call this EAGAIN may turn into an EOF or error.) */
|
@@ -244,7 +245,7 @@ static int seek_sample_fmt_normal(Sound_Sample *sample, Uint32 ms)
|
|
244
245
|
fmt_t *fmt = w->fmt;
|
245
246
|
int offset = __Sound_convertMsToBytePos(&sample->actual, ms);
|
246
247
|
int pos = (int) (fmt->data_starting_offset + offset);
|
247
|
-
int rc = SDL_RWseek(internal->rw, pos,
|
248
|
+
int rc = SDL_RWseek(internal->rw, pos, RW_SEEK_SET);
|
248
249
|
BAIL_IF_MACRO(rc != pos, ERR_IO_ERROR, 0);
|
249
250
|
w->bytesLeft = fmt->total_bytes - offset;
|
250
251
|
return 1; /* success. */
|
@@ -362,12 +363,10 @@ static SDL_INLINE int decode_adpcm_sample_frame(Sound_Sample *sample)
|
|
362
363
|
SDL_RWops *rw = internal->rw;
|
363
364
|
int i;
|
364
365
|
int max = fmt->wChannels;
|
365
|
-
Sint32 delta;
|
366
366
|
Uint8 nib = fmt->fmt.adpcm.nibble;
|
367
367
|
|
368
368
|
for (i = 0; i < max; i++)
|
369
369
|
{
|
370
|
-
Uint8 byte;
|
371
370
|
Sint16 iCoef1 = fmt->fmt.adpcm.aCoef[headers[i].bPredictor].iCoef1;
|
372
371
|
Sint16 iCoef2 = fmt->fmt.adpcm.aCoef[headers[i].bPredictor].iCoef2;
|
373
372
|
Sint32 lPredSamp = ((headers[i].iSamp1 * iCoef1) +
|
@@ -497,7 +496,7 @@ static int seek_sample_fmt_adpcm(Sound_Sample *sample, Uint32 ms)
|
|
497
496
|
int bpb = (fmt->fmt.adpcm.wSamplesPerBlock * fmt->sample_frame_size);
|
498
497
|
int skipsize = (offset / bpb) * fmt->wBlockAlign;
|
499
498
|
int pos = skipsize + fmt->data_starting_offset;
|
500
|
-
int rc = SDL_RWseek(internal->rw, pos,
|
499
|
+
int rc = SDL_RWseek(internal->rw, pos, RW_SEEK_SET);
|
501
500
|
BAIL_IF_MACRO(rc != pos, ERR_IO_ERROR, 0);
|
502
501
|
|
503
502
|
/* The offset we need is in this block, so we need to decode to there. */
|
@@ -505,7 +504,7 @@ static int seek_sample_fmt_adpcm(Sound_Sample *sample, Uint32 ms)
|
|
505
504
|
rc = (offset % bpb); /* bytes into this block we need to decode */
|
506
505
|
if (!read_adpcm_block_headers(sample))
|
507
506
|
{
|
508
|
-
SDL_RWseek(internal->rw, origpos,
|
507
|
+
SDL_RWseek(internal->rw, origpos, RW_SEEK_SET); /* try to make sane. */
|
509
508
|
return 0;
|
510
509
|
} /* if */
|
511
510
|
|
@@ -516,7 +515,7 @@ static int seek_sample_fmt_adpcm(Sound_Sample *sample, Uint32 ms)
|
|
516
515
|
{
|
517
516
|
if (!decode_adpcm_sample_frame(sample))
|
518
517
|
{
|
519
|
-
SDL_RWseek(internal->rw, origpos,
|
518
|
+
SDL_RWseek(internal->rw, origpos, RW_SEEK_SET);
|
520
519
|
fmt->fmt.adpcm.samples_left_in_block = origsampsleft;
|
521
520
|
return 0;
|
522
521
|
} /* if */
|
@@ -599,16 +598,17 @@ static int read_fmt(SDL_RWops *rw, fmt_t *fmt)
|
|
599
598
|
SNDDBG(("WAV: Appears to be ADPCM compressed audio.\n"));
|
600
599
|
return read_fmt_adpcm(rw, fmt);
|
601
600
|
|
601
|
+
case FMT_IEEE_FLOAT:
|
602
|
+
SNDDBG(("WAV: Appears to be IEEE float uncompressed audio.\n"));
|
603
|
+
return read_fmt_normal(rw, fmt); /* just normal PCM, otherwise. */
|
604
|
+
|
602
605
|
/* add other types here. */
|
603
606
|
|
604
|
-
default:
|
605
|
-
SNDDBG(("WAV: Format 0x%X is unknown.\n",
|
606
|
-
(unsigned int) fmt->wFormatTag));
|
607
|
-
BAIL_MACRO("WAV: Unsupported format", 0);
|
608
607
|
} /* switch */
|
609
608
|
|
610
|
-
|
611
|
-
|
609
|
+
SNDDBG(("WAV: Format 0x%X is unknown.\n",
|
610
|
+
(unsigned int) fmt->wFormatTag));
|
611
|
+
BAIL_MACRO("WAV: Unsupported format", 0);
|
612
612
|
} /* read_fmt */
|
613
613
|
|
614
614
|
|
@@ -632,7 +632,7 @@ static int find_chunk(SDL_RWops *rw, Uint32 id)
|
|
632
632
|
SDL_assert(siz >= 0);
|
633
633
|
pos += (sizeof (Uint32) * 2) + siz;
|
634
634
|
if (siz > 0)
|
635
|
-
BAIL_IF_MACRO(SDL_RWseek(rw, pos,
|
635
|
+
BAIL_IF_MACRO(SDL_RWseek(rw, pos, RW_SEEK_SET) != pos, NULL, 0);
|
636
636
|
} /* while */
|
637
637
|
|
638
638
|
return 0; /* shouldn't hit this, but just in case... */
|
@@ -645,7 +645,6 @@ static int WAV_open_internal(Sound_Sample *sample, const char *ext, fmt_t *fmt)
|
|
645
645
|
SDL_RWops *rw = internal->rw;
|
646
646
|
data_t d;
|
647
647
|
wav_t *w;
|
648
|
-
Uint32 pos;
|
649
648
|
|
650
649
|
BAIL_IF_MACRO(SDL_ReadLE32(rw) != riffID, "WAV: Not a RIFF file.", 0);
|
651
650
|
SDL_ReadLE32(rw); /* throw the length away; we get this info later. */
|
@@ -653,26 +652,33 @@ static int WAV_open_internal(Sound_Sample *sample, const char *ext, fmt_t *fmt)
|
|
653
652
|
BAIL_IF_MACRO(!find_chunk(rw, fmtID), "WAV: No format chunk.", 0);
|
654
653
|
BAIL_IF_MACRO(!read_fmt_chunk(rw, fmt), "WAV: Can't read format chunk.", 0);
|
655
654
|
|
656
|
-
/* !!! FIXME: need float32 format stuff, since it's not just wBitsPerSample. */
|
657
|
-
|
658
655
|
sample->actual.channels = (Uint8) fmt->wChannels;
|
659
656
|
sample->actual.rate = fmt->dwSamplesPerSec;
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
sample
|
664
|
-
|
665
|
-
|
666
|
-
else if (fmt->wBitsPerSample == 32)
|
667
|
-
sample->actual.format = AUDIO_S32LSB;
|
657
|
+
|
658
|
+
if (fmt->wFormatTag == FMT_IEEE_FLOAT)
|
659
|
+
{
|
660
|
+
BAIL_IF_MACRO(fmt->wBitsPerSample != 32, "WAV: Unsupported sample size.", 0);
|
661
|
+
sample->actual.format = AUDIO_F32LSB;
|
662
|
+
} /* if */
|
668
663
|
else
|
669
664
|
{
|
670
|
-
|
671
|
-
|
665
|
+
if (fmt->wBitsPerSample == 4)
|
666
|
+
sample->actual.format = AUDIO_S16SYS;
|
667
|
+
else if (fmt->wBitsPerSample == 8)
|
668
|
+
sample->actual.format = AUDIO_U8;
|
669
|
+
else if (fmt->wBitsPerSample == 16)
|
670
|
+
sample->actual.format = AUDIO_S16LSB;
|
671
|
+
else if (fmt->wBitsPerSample == 32)
|
672
|
+
sample->actual.format = AUDIO_S32LSB;
|
673
|
+
else
|
674
|
+
{
|
675
|
+
SNDDBG(("WAV: %d bits per sample!?\n", (int) fmt->wBitsPerSample));
|
676
|
+
BAIL_MACRO("WAV: Unsupported sample size.", 0);
|
677
|
+
} /* else */
|
672
678
|
} /* else */
|
673
679
|
|
674
680
|
BAIL_IF_MACRO(!read_fmt(rw, fmt), NULL, 0);
|
675
|
-
SDL_RWseek(rw, fmt->next_chunk_offset,
|
681
|
+
SDL_RWseek(rw, fmt->next_chunk_offset, RW_SEEK_SET);
|
676
682
|
BAIL_IF_MACRO(!find_chunk(rw, dataID), "WAV: No data chunk.", 0);
|
677
683
|
BAIL_IF_MACRO(!read_data_chunk(rw, &d), "WAV: Can't read data chunk.", 0);
|
678
684
|
|
@@ -743,7 +749,7 @@ static int WAV_rewind(Sound_Sample *sample)
|
|
743
749
|
Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque;
|
744
750
|
wav_t *w = (wav_t *) internal->decoder_private;
|
745
751
|
fmt_t *fmt = w->fmt;
|
746
|
-
int rc = SDL_RWseek(internal->rw, fmt->data_starting_offset,
|
752
|
+
int rc = SDL_RWseek(internal->rw, fmt->data_starting_offset, RW_SEEK_SET);
|
747
753
|
BAIL_IF_MACRO(rc != fmt->data_starting_offset, ERR_IO_ERROR, 0);
|
748
754
|
w->bytesLeft = fmt->total_bytes;
|
749
755
|
return fmt->rewind_sample(sample);
|