gosu 1.4.1 → 1.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/dependencies/SDL_sound/SDL_sound.c +21 -63
- data/dependencies/SDL_sound/SDL_sound.h +2 -2
- data/dependencies/SDL_sound/SDL_sound_aiff.c +26 -23
- data/dependencies/SDL_sound/SDL_sound_au.c +8 -8
- data/dependencies/SDL_sound/SDL_sound_coreaudio.c +4 -5
- data/dependencies/SDL_sound/SDL_sound_flac.c +28 -30
- data/dependencies/SDL_sound/SDL_sound_internal.h +4 -4
- data/dependencies/SDL_sound/SDL_sound_modplug.c +1 -1
- data/dependencies/SDL_sound/SDL_sound_mp3.c +19 -23
- data/dependencies/SDL_sound/SDL_sound_raw.c +5 -6
- data/dependencies/SDL_sound/SDL_sound_shn.c +4 -4
- data/dependencies/SDL_sound/SDL_sound_voc.c +15 -15
- data/dependencies/SDL_sound/SDL_sound_vorbis.c +14 -7
- data/dependencies/SDL_sound/SDL_sound_wav.c +17 -17
- data/dependencies/SDL_sound/dr_flac.h +10840 -4779
- data/dependencies/SDL_sound/dr_mp3.h +2793 -1004
- data/dependencies/SDL_sound/libmodplug/fastmix.c +5 -0
- data/dependencies/SDL_sound/libmodplug/load_669.c +1 -1
- data/dependencies/SDL_sound/libmodplug/load_amf.c +1 -0
- data/dependencies/SDL_sound/libmodplug/load_ams.c +38 -22
- data/dependencies/SDL_sound/libmodplug/load_it.c +18 -14
- data/dependencies/SDL_sound/libmodplug/load_mdl.c +18 -9
- data/dependencies/SDL_sound/libmodplug/load_med.c +7 -6
- data/dependencies/SDL_sound/libmodplug/load_mt2.c +36 -17
- data/dependencies/SDL_sound/libmodplug/load_okt.c +51 -24
- data/dependencies/SDL_sound/libmodplug/load_psm.c +4 -2
- data/dependencies/SDL_sound/libmodplug/load_s3m.c +4 -4
- data/dependencies/SDL_sound/libmodplug/load_ult.c +4 -3
- data/dependencies/SDL_sound/libmodplug/load_xm.c +5 -5
- data/dependencies/SDL_sound/libmodplug/snd_fx.c +8 -1
- data/dependencies/SDL_sound/libmodplug/sndfile.c +21 -4
- data/dependencies/SDL_sound/stb_vorbis.h +10 -18
- data/dependencies/mojoAL/mojoal.c +260 -6
- data/dependencies/stb/stb_image.h +208 -73
- data/dependencies/stb/stb_image_write.h +57 -23
- data/dependencies/stb/stb_truetype.h +345 -279
- data/dependencies/utf8proc/utf8proc.c +37 -18
- data/dependencies/utf8proc/utf8proc.h +17 -5
- data/dependencies/utf8proc/utf8proc_data.h +12012 -10089
- data/include/Gosu/Buttons.hpp +103 -103
- data/include/Gosu/Directories.hpp +31 -24
- data/include/Gosu/Font.hpp +4 -2
- data/include/Gosu/Gosu.hpp +5 -8
- data/include/Gosu/IO.hpp +0 -3
- data/include/Gosu/Math.hpp +0 -3
- data/include/Gosu/Timing.hpp +2 -8
- data/include/Gosu/Version.hpp +1 -1
- data/src/AudioImpl.cpp +0 -7
- data/src/AudioImpl.hpp +1 -3
- data/src/BitmapIO.cpp +23 -2
- data/src/DirectoriesApple.cpp +25 -24
- data/src/DirectoriesUnix.cpp +14 -12
- data/src/DirectoriesWin.cpp +26 -30
- data/src/Font.cpp +12 -2
- data/src/Image.cpp +10 -15
- data/src/RubyGosu.cxx +6 -34
- data/src/TimingApple.cpp +1 -7
- data/src/TimingUnix.cpp +0 -6
- data/src/TimingWin.cpp +0 -6
- data/src/Window.cpp +4 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e577795a3efb0fe3e5a207c81305191da2682fe06de1c58de7bb78fe2351fa54
|
4
|
+
data.tar.gz: 9ba25d605fab3f9950c9d861fed9eed3f276ce3bb2316276426be2dd6d6a7626
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f24d89b6a88e3d1b5dd8e776bd93e2c5c338ca67b8f2d87b570caded06021ff7369a272e9771c5509dcbc9f0dae1fb303ac6541a6a65a9267393e3138be536d3
|
7
|
+
data.tar.gz: e2d21e6b09442dcf5041e02725da89566bb151b9a3b9b2edb2f4b95a1efa99c7318dfdd7da6c287bf64f0e824e68f7684153be3c3d5b2b0781369c0c0e14cbd1
|
@@ -30,12 +30,11 @@ extern const Sound_DecoderFunctions __Sound_DecoderFunctions_VOC;
|
|
30
30
|
extern const Sound_DecoderFunctions __Sound_DecoderFunctions_RAW;
|
31
31
|
extern const Sound_DecoderFunctions __Sound_DecoderFunctions_SHN;
|
32
32
|
extern const Sound_DecoderFunctions __Sound_DecoderFunctions_FLAC;
|
33
|
-
extern const Sound_DecoderFunctions __Sound_DecoderFunctions_QuickTime;
|
34
33
|
extern const Sound_DecoderFunctions __Sound_DecoderFunctions_CoreAudio;
|
35
34
|
|
36
35
|
typedef struct
|
37
36
|
{
|
38
|
-
|
37
|
+
SDL_bool available;
|
39
38
|
const Sound_DecoderFunctions *funcs;
|
40
39
|
} decoder_element;
|
41
40
|
|
@@ -85,17 +84,14 @@ static decoder_element decoders[] =
|
|
85
84
|
|
86
85
|
/* General SDL_sound state ... */
|
87
86
|
|
88
|
-
|
87
|
+
static SDL_TLSID tlsid_errmsg = 0;
|
88
|
+
|
89
|
+
typedef struct
|
89
90
|
{
|
90
|
-
|
91
|
-
int error_available;
|
91
|
+
SDL_bool error_available;
|
92
92
|
char error_string[128];
|
93
|
-
struct __SOUND_ERRMSGTYPE__ *next;
|
94
93
|
} ErrMsg;
|
95
94
|
|
96
|
-
static ErrMsg *error_msgs = NULL;
|
97
|
-
static SDL_mutex *errorlist_mutex = NULL;
|
98
|
-
|
99
95
|
static Sound_Sample *sample_list = NULL; /* this is a linked list. */
|
100
96
|
static SDL_mutex *samplelist_mutex = NULL;
|
101
97
|
|
@@ -124,7 +120,6 @@ int Sound_Init(void)
|
|
124
120
|
BAIL_IF_MACRO(initialized, ERR_IS_INITIALIZED, 0);
|
125
121
|
|
126
122
|
sample_list = NULL;
|
127
|
-
error_msgs = NULL;
|
128
123
|
|
129
124
|
available_decoders = (const Sound_DecoderInfo **)
|
130
125
|
SDL_calloc(total, sizeof (Sound_DecoderInfo *));
|
@@ -132,7 +127,8 @@ int Sound_Init(void)
|
|
132
127
|
|
133
128
|
SDL_InitSubSystem(SDL_INIT_AUDIO);
|
134
129
|
|
135
|
-
|
130
|
+
tlsid_errmsg = SDL_TLSCreate();
|
131
|
+
|
136
132
|
samplelist_mutex = SDL_CreateMutex();
|
137
133
|
|
138
134
|
for (i = 0; decoders[i].funcs != NULL; i++)
|
@@ -152,8 +148,6 @@ int Sound_Init(void)
|
|
152
148
|
|
153
149
|
int Sound_Quit(void)
|
154
150
|
{
|
155
|
-
ErrMsg *err;
|
156
|
-
ErrMsg *nexterr = NULL;
|
157
151
|
size_t i;
|
158
152
|
|
159
153
|
BAIL_IF_MACRO(!initialized, ERR_NOT_INITIALIZED, 0);
|
@@ -180,17 +174,7 @@ int Sound_Quit(void)
|
|
180
174
|
SDL_free((void *) available_decoders);
|
181
175
|
available_decoders = NULL;
|
182
176
|
|
183
|
-
|
184
|
-
SDL_LockMutex(errorlist_mutex);
|
185
|
-
for (err = error_msgs; err != NULL; err = nexterr)
|
186
|
-
{
|
187
|
-
nexterr = err->next;
|
188
|
-
SDL_free(err);
|
189
|
-
} /* for */
|
190
|
-
error_msgs = NULL;
|
191
|
-
SDL_UnlockMutex(errorlist_mutex);
|
192
|
-
SDL_DestroyMutex(errorlist_mutex);
|
193
|
-
errorlist_mutex = NULL;
|
177
|
+
tlsid_errmsg = 0;
|
194
178
|
|
195
179
|
return 1;
|
196
180
|
} /* Sound_Quit */
|
@@ -204,27 +188,8 @@ const Sound_DecoderInfo **Sound_AvailableDecoders(void)
|
|
204
188
|
|
205
189
|
static ErrMsg *findErrorForCurrentThread(void)
|
206
190
|
{
|
207
|
-
ErrMsg *
|
208
|
-
|
209
|
-
|
210
|
-
if (error_msgs != NULL)
|
211
|
-
{
|
212
|
-
tid = SDL_ThreadID();
|
213
|
-
|
214
|
-
SDL_LockMutex(errorlist_mutex);
|
215
|
-
for (i = error_msgs; i != NULL; i = i->next)
|
216
|
-
{
|
217
|
-
if (i->tid == tid)
|
218
|
-
{
|
219
|
-
SDL_UnlockMutex(errorlist_mutex);
|
220
|
-
return i;
|
221
|
-
} /* if */
|
222
|
-
} /* for */
|
223
|
-
SDL_UnlockMutex(errorlist_mutex);
|
224
|
-
} /* if */
|
225
|
-
|
226
|
-
return NULL; /* no error available. */
|
227
|
-
} /* findErrorForCurrentThread */
|
191
|
+
return (ErrMsg *) SDL_TLSGet(tlsid_errmsg);
|
192
|
+
}
|
228
193
|
|
229
194
|
|
230
195
|
const char *Sound_GetError(void)
|
@@ -239,7 +204,7 @@ const char *Sound_GetError(void)
|
|
239
204
|
if ((err != NULL) && (err->error_available))
|
240
205
|
{
|
241
206
|
retval = err->error_string;
|
242
|
-
err->error_available =
|
207
|
+
err->error_available = SDL_FALSE;
|
243
208
|
} /* if */
|
244
209
|
|
245
210
|
return retval;
|
@@ -248,15 +213,14 @@ const char *Sound_GetError(void)
|
|
248
213
|
|
249
214
|
void Sound_ClearError(void)
|
250
215
|
{
|
251
|
-
|
216
|
+
Sound_GetError(); /* this will set error_available to SDL_FALSE */
|
217
|
+
} /* Sound_ClearError */
|
252
218
|
|
253
|
-
if (!initialized)
|
254
|
-
return;
|
255
219
|
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
} /*
|
220
|
+
static void SDLCALL free_errmsg(void *errmsg)
|
221
|
+
{
|
222
|
+
SDL_free(errmsg);
|
223
|
+
} /* free_errmsg */
|
260
224
|
|
261
225
|
|
262
226
|
/*
|
@@ -269,8 +233,7 @@ void __Sound_SetError(const char *str)
|
|
269
233
|
if (str == NULL)
|
270
234
|
return;
|
271
235
|
|
272
|
-
SNDDBG(("__Sound_SetError(\"%s\");%s\n", str,
|
273
|
-
(initialized) ? "" : " [NOT INITIALIZED!]"));
|
236
|
+
SNDDBG(("__Sound_SetError(\"%s\");%s\n", str, (initialized) ? "" : " [NOT INITIALIZED!]"));
|
274
237
|
|
275
238
|
if (!initialized)
|
276
239
|
return;
|
@@ -282,15 +245,10 @@ void __Sound_SetError(const char *str)
|
|
282
245
|
if (err == NULL)
|
283
246
|
return; /* uhh...? */
|
284
247
|
|
285
|
-
err
|
286
|
-
|
287
|
-
SDL_LockMutex(errorlist_mutex);
|
288
|
-
err->next = error_msgs;
|
289
|
-
error_msgs = err;
|
290
|
-
SDL_UnlockMutex(errorlist_mutex);
|
248
|
+
SDL_TLSSet(tlsid_errmsg, err, free_errmsg);
|
291
249
|
} /* if */
|
292
250
|
|
293
|
-
err->error_available =
|
251
|
+
err->error_available = SDL_TRUE;
|
294
252
|
SDL_strlcpy(err->error_string, str, sizeof (err->error_string));
|
295
253
|
} /* __Sound_SetError */
|
296
254
|
|
@@ -391,7 +349,7 @@ static int init_sample(const Sound_DecoderFunctions *funcs,
|
|
391
349
|
{
|
392
350
|
Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque;
|
393
351
|
Sound_AudioInfo desired;
|
394
|
-
|
352
|
+
const Sint64 pos = SDL_RWtell(internal->rw);
|
395
353
|
|
396
354
|
/* fill in the funcs for this decoder... */
|
397
355
|
sample->decoder = &funcs->info;
|
@@ -696,8 +696,8 @@ SNDDECLSPEC int SDLCALL Sound_Rewind(Sound_Sample *sample);
|
|
696
696
|
*
|
697
697
|
* This function can be emulated in the application with Sound_Rewind()
|
698
698
|
* and predecoding a specific amount of the sample, but this can be
|
699
|
-
* extremely inefficient. Sound_Seek() accelerates the seek
|
700
|
-
*
|
699
|
+
* extremely inefficient. Sound_Seek() accelerates the seek with
|
700
|
+
* decoder-specific code.
|
701
701
|
*
|
702
702
|
* If this function fails, the sample should continue to function as if
|
703
703
|
* this call was never made. If there was an unrecoverable error,
|
@@ -38,8 +38,8 @@ typedef struct S_AIFF_FMT_T
|
|
38
38
|
{
|
39
39
|
Uint32 type;
|
40
40
|
|
41
|
-
|
42
|
-
|
41
|
+
Sint64 total_bytes;
|
42
|
+
Sint64 data_starting_offset;
|
43
43
|
|
44
44
|
void (*free)(struct S_AIFF_FMT_T *fmt);
|
45
45
|
Uint32 (*read_sample)(Sound_Sample *sample);
|
@@ -49,7 +49,7 @@ typedef struct S_AIFF_FMT_T
|
|
49
49
|
|
50
50
|
#if 0
|
51
51
|
/*
|
52
|
-
this is ripped from wav.c as
|
52
|
+
this is ripped from wav.c as an example of format-specific data.
|
53
53
|
please replace with something more appropriate when the need arises.
|
54
54
|
*/
|
55
55
|
union
|
@@ -177,8 +177,7 @@ static int read_comm_chunk(SDL_RWops *rw, comm_t *comm)
|
|
177
177
|
return 0;
|
178
178
|
comm->numChannels = SDL_SwapBE16(comm->numChannels);
|
179
179
|
|
180
|
-
if (SDL_RWread(rw, &comm->numSampleFrames,
|
181
|
-
sizeof (comm->numSampleFrames), 1) != 1)
|
180
|
+
if (SDL_RWread(rw, &comm->numSampleFrames, sizeof (comm->numSampleFrames), 1) != 1)
|
182
181
|
return 0;
|
183
182
|
comm->numSampleFrames = SDL_SwapBE32(comm->numSampleFrames);
|
184
183
|
|
@@ -245,7 +244,7 @@ static int read_ssnd_chunk(SDL_RWops *rw, ssnd_t *ssnd)
|
|
245
244
|
ssnd->blockSize = SDL_SwapBE32(ssnd->blockSize);
|
246
245
|
|
247
246
|
/* Leave the SDL_RWops position indicator at the start of the samples */
|
248
|
-
if (SDL_RWseek(rw,
|
247
|
+
if (SDL_RWseek(rw, ssnd->offset, RW_SEEK_CUR) == -1)
|
249
248
|
return 0;
|
250
249
|
|
251
250
|
return 1;
|
@@ -262,8 +261,7 @@ static Uint32 read_sample_fmt_normal(Sound_Sample *sample)
|
|
262
261
|
Uint32 retval;
|
263
262
|
Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque;
|
264
263
|
aiff_t *a = (aiff_t *) internal->decoder_private;
|
265
|
-
Uint32 max = (internal->buffer_size
|
266
|
-
internal->buffer_size : (Uint32) a->bytesLeft;
|
264
|
+
const Uint32 max = SDL_min(internal->buffer_size, (Uint32) a->bytesLeft);
|
267
265
|
|
268
266
|
SDL_assert(max > 0);
|
269
267
|
|
@@ -301,10 +299,10 @@ static int seek_sample_fmt_normal(Sound_Sample *sample, Uint32 ms)
|
|
301
299
|
{
|
302
300
|
Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque;
|
303
301
|
aiff_t *a = (aiff_t *) internal->decoder_private;
|
304
|
-
fmt_t *fmt = &a->fmt;
|
305
|
-
|
306
|
-
|
307
|
-
|
302
|
+
const fmt_t *fmt = &a->fmt;
|
303
|
+
const Uint32 offset = __Sound_convertMsToBytePos(&sample->actual, ms);
|
304
|
+
const Sint64 pos = (Sint64) (fmt->data_starting_offset + offset);
|
305
|
+
const Sint64 rc = SDL_RWseek(internal->rw, pos, RW_SEEK_SET);
|
308
306
|
BAIL_IF_MACRO(rc != pos, ERR_IO_ERROR, 0);
|
309
307
|
a->bytesLeft = fmt->total_bytes - offset;
|
310
308
|
return 1; /* success. */
|
@@ -334,9 +332,9 @@ static int read_fmt_normal(SDL_RWops *rw, fmt_t *fmt)
|
|
334
332
|
* Everything else... *
|
335
333
|
*****************************************************************************/
|
336
334
|
|
337
|
-
static
|
335
|
+
static SDL_bool AIFF_init(void)
|
338
336
|
{
|
339
|
-
return
|
337
|
+
return SDL_TRUE; /* always succeeds. */
|
340
338
|
} /* AIFF_init */
|
341
339
|
|
342
340
|
|
@@ -393,8 +391,8 @@ static int AIFF_open(Sound_Sample *sample, const char *ext)
|
|
393
391
|
Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque;
|
394
392
|
SDL_RWops *rw = internal->rw;
|
395
393
|
Uint32 chunk_id;
|
396
|
-
|
397
|
-
|
394
|
+
Uint32 bytes_per_sample;
|
395
|
+
Sint64 pos;
|
398
396
|
comm_t c;
|
399
397
|
ssnd_t s;
|
400
398
|
aiff_t *a;
|
@@ -413,14 +411,11 @@ static int AIFF_open(Sound_Sample *sample, const char *ext)
|
|
413
411
|
BAIL_IF_MACRO(!read_comm_chunk(rw, &c),
|
414
412
|
"AIFF: Can't read common chunk.", 0);
|
415
413
|
|
414
|
+
BAIL_IF_MACRO(c.numChannels == 0, "AIFF: no channels specified.", 0);
|
415
|
+
|
416
416
|
sample->actual.channels = (Uint8) c.numChannels;
|
417
417
|
sample->actual.rate = c.sampleRate;
|
418
418
|
|
419
|
-
/* Really, sample->total_time = (c.numSampleFrames*1000) c.sampleRate */
|
420
|
-
internal->total_time = (c.numSampleFrames / c.sampleRate) * 1000;
|
421
|
-
internal->total_time += (c.numSampleFrames % c.sampleRate)
|
422
|
-
* 1000 / c.sampleRate;
|
423
|
-
|
424
419
|
if (c.sampleSize <= 8)
|
425
420
|
{
|
426
421
|
sample->actual.format = AUDIO_S8;
|
@@ -461,6 +456,14 @@ static int AIFF_open(Sound_Sample *sample, const char *ext)
|
|
461
456
|
BAIL_MACRO("AIFF: Can't read sound data chunk.", 0);
|
462
457
|
} /* if */
|
463
458
|
|
459
|
+
if (c.numSampleFrames == 0)
|
460
|
+
c.numSampleFrames = (s.ckDataSize - 8) / bytes_per_sample;
|
461
|
+
|
462
|
+
/* Really, sample->total_time = (c.numSampleFrames*1000) c.sampleRate */
|
463
|
+
internal->total_time = (c.numSampleFrames / c.sampleRate) * 1000;
|
464
|
+
internal->total_time += (c.numSampleFrames % c.sampleRate) * 1000 / c.sampleRate;
|
465
|
+
|
466
|
+
|
464
467
|
a->fmt.total_bytes = a->bytesLeft = bytes_per_sample * c.numSampleFrames;
|
465
468
|
a->fmt.data_starting_offset = SDL_RWtell(rw);
|
466
469
|
internal->decoder_private = (void *) a;
|
@@ -493,8 +496,8 @@ static int AIFF_rewind(Sound_Sample *sample)
|
|
493
496
|
{
|
494
497
|
Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque;
|
495
498
|
aiff_t *a = (aiff_t *) internal->decoder_private;
|
496
|
-
fmt_t *fmt = &a->fmt;
|
497
|
-
|
499
|
+
const fmt_t *fmt = &a->fmt;
|
500
|
+
const Sint64 rc = SDL_RWseek(internal->rw, fmt->data_starting_offset, RW_SEEK_SET);
|
498
501
|
BAIL_IF_MACRO(rc != fmt->data_starting_offset, ERR_IO_ERROR, 0);
|
499
502
|
a->bytesLeft = fmt->total_bytes;
|
500
503
|
return fmt->rewind_sample(sample);
|
@@ -18,9 +18,9 @@
|
|
18
18
|
#if SOUND_SUPPORTS_AU
|
19
19
|
|
20
20
|
/* no init/deinit needed */
|
21
|
-
static
|
21
|
+
static SDL_bool AU_init(void)
|
22
22
|
{
|
23
|
-
return
|
23
|
+
return SDL_TRUE;
|
24
24
|
} /* AU_init */
|
25
25
|
|
26
26
|
static void AU_quit(void)
|
@@ -63,7 +63,7 @@ struct audec
|
|
63
63
|
{
|
64
64
|
Uint32 total;
|
65
65
|
Uint32 remaining;
|
66
|
-
|
66
|
+
Sint64 start_offset;
|
67
67
|
int encoding;
|
68
68
|
};
|
69
69
|
|
@@ -297,7 +297,7 @@ static int AU_rewind(Sound_Sample *sample)
|
|
297
297
|
{
|
298
298
|
Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque;
|
299
299
|
struct audec *dec = (struct audec *) internal->decoder_private;
|
300
|
-
|
300
|
+
const Sint64 rc = SDL_RWseek(internal->rw, dec->start_offset, RW_SEEK_SET);
|
301
301
|
BAIL_IF_MACRO(rc != dec->start_offset, ERR_IO_ERROR, 0);
|
302
302
|
dec->remaining = dec->total;
|
303
303
|
return 1;
|
@@ -308,14 +308,14 @@ static int AU_seek(Sound_Sample *sample, Uint32 ms)
|
|
308
308
|
{
|
309
309
|
Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque;
|
310
310
|
struct audec *dec = (struct audec *) internal->decoder_private;
|
311
|
-
|
312
|
-
|
313
|
-
|
311
|
+
Sint64 offset = __Sound_convertMsToBytePos(&sample->actual, ms);
|
312
|
+
Sint64 rc;
|
313
|
+
Sint64 pos;
|
314
314
|
|
315
315
|
if (dec->encoding == AU_ENC_ULAW_8)
|
316
316
|
offset >>= 1; /* halve the byte offset for compression. */
|
317
317
|
|
318
|
-
pos = (
|
318
|
+
pos = (dec->start_offset + offset);
|
319
319
|
rc = SDL_RWseek(internal->rw, pos, RW_SEEK_SET);
|
320
320
|
BAIL_IF_MACRO(rc != pos, ERR_IO_ERROR, 0);
|
321
321
|
dec->remaining = dec->total - offset;
|
@@ -23,9 +23,9 @@ typedef struct CoreAudioFileContainer
|
|
23
23
|
} CoreAudioFileContainer;
|
24
24
|
|
25
25
|
|
26
|
-
static
|
26
|
+
static SDL_bool CoreAudio_init(void)
|
27
27
|
{
|
28
|
-
return
|
28
|
+
return SDL_TRUE; /* always succeeds. */
|
29
29
|
} /* CoreAudio_init */
|
30
30
|
|
31
31
|
|
@@ -193,11 +193,10 @@ static const char* CoreAudio_FourCCToString(int32_t error_code)
|
|
193
193
|
SInt64 CoreAudio_SizeCallback(void* inClientData)
|
194
194
|
{
|
195
195
|
SDL_RWops* rw_ops = (SDL_RWops*)inClientData;
|
196
|
-
|
197
|
-
|
196
|
+
const Sint64 current_position = SDL_RWtell(rw_ops);
|
197
|
+
const Sint64 end_position = SDL_RWseek(rw_ops, 0, RW_SEEK_END);
|
198
198
|
SDL_RWseek(rw_ops, current_position, RW_SEEK_SET);
|
199
199
|
// fprintf(stderr, "CoreAudio_SizeCallback:%d\n", end_position);
|
200
|
-
|
201
200
|
return end_position;
|
202
201
|
}
|
203
202
|
|
@@ -29,17 +29,24 @@
|
|
29
29
|
#define DR_FLAC_IMPLEMENTATION
|
30
30
|
#define DR_FLAC_NO_STDIO 1
|
31
31
|
#define DR_FLAC_NO_WIN32_IO 1
|
32
|
-
#define DR_FLAC_NO_CRC 1
|
33
32
|
#define DRFLAC_ASSERT(x) SDL_assert((x))
|
34
33
|
#define DRFLAC_MALLOC(sz) SDL_malloc((sz))
|
35
34
|
#define DRFLAC_REALLOC(p, sz) SDL_realloc((p), (sz))
|
36
35
|
#define DRFLAC_FREE(p) SDL_free((p))
|
37
36
|
#define DRFLAC_COPY_MEMORY(dst, src, sz) SDL_memcpy((dst), (src), (sz))
|
38
37
|
#define DRFLAC_ZERO_MEMORY(p, sz) SDL_memset((p), 0, (sz))
|
38
|
+
#ifndef __WATCOMC__ /* #@!.!.. */
|
39
|
+
#if SDL_VERSION_ATLEAST(2, 0, 9)
|
40
|
+
#define exp SDL_exp
|
41
|
+
#endif
|
42
|
+
#define floor SDL_floor
|
43
|
+
#endif
|
44
|
+
|
39
45
|
#include "dr_flac.h"
|
40
46
|
|
41
47
|
static size_t flac_read(void* pUserData, void* pBufferOut, size_t bytesToRead)
|
42
48
|
{
|
49
|
+
/* !!! FIXME: dr_flac treats returning less than bytesToRead as EOF. So we can't EAGAIN. */
|
43
50
|
Uint8 *ptr = (Uint8 *) pBufferOut;
|
44
51
|
Sound_Sample *sample = (Sound_Sample *) pUserData;
|
45
52
|
Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque;
|
@@ -47,24 +54,13 @@ static size_t flac_read(void* pUserData, void* pBufferOut, size_t bytesToRead)
|
|
47
54
|
size_t retval = 0;
|
48
55
|
|
49
56
|
/* !!! FIXME: dr_flac treats returning less than bytesToRead as EOF. So we can't EAGAIN. */
|
50
|
-
while (
|
57
|
+
while (bytesToRead)
|
51
58
|
{
|
52
59
|
const size_t rc = SDL_RWread(rwops, ptr, 1, bytesToRead);
|
53
|
-
if (rc == 0)
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
} /* if */
|
58
|
-
else if (rc == -1) /** FIXME: this error check is broken **/
|
59
|
-
{
|
60
|
-
sample->flags |= SOUND_SAMPLEFLAG_ERROR;
|
61
|
-
break;
|
62
|
-
} /* else if */
|
63
|
-
else
|
64
|
-
{
|
65
|
-
retval += rc;
|
66
|
-
ptr += rc;
|
67
|
-
} /* else */
|
60
|
+
if (rc == 0) break;
|
61
|
+
bytesToRead -= rc;
|
62
|
+
retval += rc;
|
63
|
+
ptr += rc;
|
68
64
|
} /* while */
|
69
65
|
|
70
66
|
return retval;
|
@@ -79,9 +75,9 @@ static drflac_bool32 flac_seek(void* pUserData, int offset, drflac_seek_origin o
|
|
79
75
|
} /* flac_seek */
|
80
76
|
|
81
77
|
|
82
|
-
static
|
78
|
+
static SDL_bool FLAC_init(void)
|
83
79
|
{
|
84
|
-
return
|
80
|
+
return SDL_TRUE; /* always succeeds. */
|
85
81
|
} /* FLAC_init */
|
86
82
|
|
87
83
|
|
@@ -94,7 +90,7 @@ static void FLAC_quit(void)
|
|
94
90
|
static int FLAC_open(Sound_Sample *sample, const char *ext)
|
95
91
|
{
|
96
92
|
Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque;
|
97
|
-
drflac *dr = drflac_open(flac_read, flac_seek, sample);
|
93
|
+
drflac *dr = drflac_open(flac_read, flac_seek, sample, NULL);
|
98
94
|
|
99
95
|
if (!dr)
|
100
96
|
{
|
@@ -109,14 +105,14 @@ static int FLAC_open(Sound_Sample *sample, const char *ext)
|
|
109
105
|
sample->actual.rate = dr->sampleRate;
|
110
106
|
sample->actual.format = AUDIO_S32SYS; /* dr_flac only does Sint32. */
|
111
107
|
|
112
|
-
if (dr->
|
108
|
+
if (dr->totalPCMFrameCount == 0)
|
113
109
|
internal->total_time = -1;
|
114
110
|
else
|
115
111
|
{
|
116
112
|
const Uint32 rate = (Uint32) dr->sampleRate;
|
117
|
-
const Uint64 frames = (Uint64)
|
113
|
+
const Uint64 frames = (Uint64) dr->totalPCMFrameCount;
|
118
114
|
internal->total_time = (frames / rate) * 1000;
|
119
|
-
internal->total_time += ((dr->
|
115
|
+
internal->total_time += ((dr->totalPCMFrameCount % dr->sampleRate) * 1000) / dr->sampleRate;
|
120
116
|
} /* else */
|
121
117
|
|
122
118
|
internal->decoder_private = dr;
|
@@ -134,17 +130,21 @@ static void FLAC_close(Sound_Sample *sample)
|
|
134
130
|
static Uint32 FLAC_read(Sound_Sample *sample)
|
135
131
|
{
|
136
132
|
Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque;
|
133
|
+
const int channels = (int) sample->actual.channels;
|
137
134
|
drflac *dr = (drflac *) internal->decoder_private;
|
138
|
-
const drflac_uint64
|
139
|
-
|
140
|
-
|
135
|
+
const drflac_uint64 frames_to_read = (internal->buffer_size / channels) / sizeof (drflac_int32);
|
136
|
+
const drflac_uint64 rc = drflac_read_pcm_frames_s32(dr, frames_to_read, (drflac_int32 *) internal->buffer);
|
137
|
+
/* !!! FIXME: we only set the EOF flags, but this only tells you we're done, not about i/o errors, nor corruption. */
|
138
|
+
if (rc < frames_to_read)
|
139
|
+
sample->flags |= SOUND_SAMPLEFLAG_EOF;
|
140
|
+
return rc * channels * sizeof (drflac_int32);
|
141
141
|
} /* FLAC_read */
|
142
142
|
|
143
143
|
static int FLAC_rewind(Sound_Sample *sample)
|
144
144
|
{
|
145
145
|
Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque;
|
146
146
|
drflac *dr = (drflac *) internal->decoder_private;
|
147
|
-
return (
|
147
|
+
return (drflac_seek_to_pcm_frame(dr, 0) == DRFLAC_TRUE);
|
148
148
|
} /* FLAC_rewind */
|
149
149
|
|
150
150
|
static int FLAC_seek(Sound_Sample *sample, Uint32 ms)
|
@@ -153,8 +153,7 @@ static int FLAC_seek(Sound_Sample *sample, Uint32 ms)
|
|
153
153
|
drflac *dr = (drflac *) internal->decoder_private;
|
154
154
|
const float frames_per_ms = ((float) sample->actual.rate) / 1000.0f;
|
155
155
|
const drflac_uint64 frame_offset = (drflac_uint64) (frames_per_ms * ((float) ms));
|
156
|
-
|
157
|
-
return (drflac_seek_to_sample(dr, sampnum) == DRFLAC_TRUE);
|
156
|
+
return (drflac_seek_to_pcm_frame(dr, frame_offset) == DRFLAC_TRUE);
|
158
157
|
} /* FLAC_seek */
|
159
158
|
|
160
159
|
static const char *extensions_flac[] = { "FLAC", "FLA", NULL };
|
@@ -179,4 +178,3 @@ const Sound_DecoderFunctions __Sound_DecoderFunctions_FLAC =
|
|
179
178
|
#endif /* SOUND_SUPPORTS_FLAC */
|
180
179
|
|
181
180
|
/* end of SDL_sound_flac.c ... */
|
182
|
-
|
@@ -97,16 +97,16 @@ typedef struct __SOUND_DECODERFUNCTIONS__
|
|
97
97
|
* set up any global state that your decoder needs, such as
|
98
98
|
* initializing an external library, etc.
|
99
99
|
*
|
100
|
-
* Return
|
101
|
-
* a fatal error. If this method fails, then this decoder
|
102
|
-
* flagged as unavailable until SDL_sound() is shut down and
|
100
|
+
* Return SDL_TRUE if initialization is successful, SDL_FALSE if
|
101
|
+
* there's a fatal error. If this method fails, then this decoder
|
102
|
+
* is flagged as unavailable until SDL_sound() is shut down and
|
103
103
|
* reinitialized, in which case this method will be tried again.
|
104
104
|
*
|
105
105
|
* Note that the decoders quit() method won't be called if this
|
106
106
|
* method fails, so if you can't intialize, you'll have to clean
|
107
107
|
* up the half-initialized state in this method.
|
108
108
|
*/
|
109
|
-
|
109
|
+
SDL_bool (*init)(void);
|
110
110
|
|
111
111
|
/*
|
112
112
|
* This is called during the Sound_Quit() function. Use this to
|
@@ -20,7 +20,6 @@
|
|
20
20
|
#if SOUND_SUPPORTS_MP3
|
21
21
|
|
22
22
|
#define DR_MP3_IMPLEMENTATION
|
23
|
-
|
24
23
|
#define DR_MP3_NO_STDIO 1
|
25
24
|
#define DR_MP3_FLOAT_OUTPUT 1
|
26
25
|
#define DRMP3_ASSERT(x) SDL_assert((x))
|
@@ -30,6 +29,12 @@
|
|
30
29
|
#define DRMP3_COPY_MEMORY(dst, src, sz) SDL_memcpy((dst), (src), (sz))
|
31
30
|
#define DRMP3_MOVE_MEMORY(dst, src, sz) SDL_memmove((dst), (src), (sz))
|
32
31
|
#define DRMP3_ZERO_MEMORY(p, sz) SDL_memset((p), 0, (sz))
|
32
|
+
#ifndef __WATCOMC__ /* #@!.!.. */
|
33
|
+
#if SDL_VERSION_ATLEAST(2, 0, 9)
|
34
|
+
#define exp SDL_exp
|
35
|
+
#endif
|
36
|
+
#define floor SDL_floor
|
37
|
+
#endif
|
33
38
|
|
34
39
|
#include "dr_mp3.h"
|
35
40
|
|
@@ -42,24 +47,13 @@ static size_t mp3_read(void* pUserData, void* pBufferOut, size_t bytesToRead)
|
|
42
47
|
size_t retval = 0;
|
43
48
|
|
44
49
|
/* !!! FIXME: dr_mp3 treats returning less than bytesToRead as EOF. So we can't EAGAIN. */
|
45
|
-
while (
|
50
|
+
while (bytesToRead)
|
46
51
|
{
|
47
52
|
const size_t rc = SDL_RWread(rwops, ptr, 1, bytesToRead);
|
48
|
-
if (rc == 0)
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
} /* if */
|
53
|
-
else if (rc == -1) /** FIXME: this error check is broken **/
|
54
|
-
{
|
55
|
-
sample->flags |= SOUND_SAMPLEFLAG_ERROR;
|
56
|
-
break;
|
57
|
-
} /* else if */
|
58
|
-
else
|
59
|
-
{
|
60
|
-
retval += rc;
|
61
|
-
ptr += rc;
|
62
|
-
} /* else */
|
53
|
+
if (rc == 0) break;
|
54
|
+
bytesToRead -= rc;
|
55
|
+
retval += rc;
|
56
|
+
ptr += rc;
|
63
57
|
} /* while */
|
64
58
|
|
65
59
|
return retval;
|
@@ -74,9 +68,9 @@ static drmp3_bool32 mp3_seek(void* pUserData, int offset, drmp3_seek_origin orig
|
|
74
68
|
} /* mp3_seek */
|
75
69
|
|
76
70
|
|
77
|
-
static
|
71
|
+
static SDL_bool MP3_init(void)
|
78
72
|
{
|
79
|
-
return
|
73
|
+
return SDL_TRUE; /* always succeeds. */
|
80
74
|
} /* MP3_init */
|
81
75
|
|
82
76
|
|
@@ -125,8 +119,10 @@ static Uint32 MP3_read(Sound_Sample *sample)
|
|
125
119
|
const int channels = (int) sample->actual.channels;
|
126
120
|
drmp3 *dr = (drmp3 *) internal->decoder_private;
|
127
121
|
const drmp3_uint64 frames_to_read = (internal->buffer_size / channels) / sizeof (float);
|
128
|
-
const drmp3_uint64 rc =
|
129
|
-
/* !!! FIXME:
|
122
|
+
const drmp3_uint64 rc = drmp3_read_pcm_frames_f32(dr, frames_to_read, (float *) internal->buffer);
|
123
|
+
/* !!! FIXME: we only set the EOF flags, but this only tells you we're done, not about i/o errors, nor corruption. */
|
124
|
+
if (rc < frames_to_read)
|
125
|
+
sample->flags |= SOUND_SAMPLEFLAG_EOF;
|
130
126
|
return rc * channels * sizeof (float);
|
131
127
|
} /* MP3_read */
|
132
128
|
|
@@ -134,7 +130,7 @@ static int MP3_rewind(Sound_Sample *sample)
|
|
134
130
|
{
|
135
131
|
Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque;
|
136
132
|
drmp3 *dr = (drmp3 *) internal->decoder_private;
|
137
|
-
return (
|
133
|
+
return (drmp3_seek_to_pcm_frame(dr, 0) == DRMP3_TRUE);
|
138
134
|
} /* MP3_rewind */
|
139
135
|
|
140
136
|
static int MP3_seek(Sound_Sample *sample, Uint32 ms)
|
@@ -143,7 +139,7 @@ static int MP3_seek(Sound_Sample *sample, Uint32 ms)
|
|
143
139
|
drmp3 *dr = (drmp3 *) internal->decoder_private;
|
144
140
|
const float frames_per_ms = ((float) sample->actual.rate) / 1000.0f;
|
145
141
|
const drmp3_uint64 frame_offset = (drmp3_uint64) (frames_per_ms * ((float) ms));
|
146
|
-
return (
|
142
|
+
return (drmp3_seek_to_pcm_frame(dr, frame_offset) == DRMP3_TRUE);
|
147
143
|
} /* MP3_seek */
|
148
144
|
|
149
145
|
/* dr_mp3 will play layer 1 and 2 files, too */
|