gosu 1.4.5.pre1 → 1.4.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (101) hide show
  1. checksums.yaml +4 -4
  2. data/dependencies/SDL/include/SDL.h +1 -0
  3. data/dependencies/SDL/include/SDL_assert.h +4 -2
  4. data/dependencies/SDL/include/SDL_atomic.h +20 -0
  5. data/dependencies/SDL/include/SDL_audio.h +40 -4
  6. data/dependencies/SDL/include/SDL_blendmode.h +4 -6
  7. data/dependencies/SDL/include/SDL_clipboard.h +47 -0
  8. data/dependencies/SDL/include/SDL_config.h +71 -45
  9. data/dependencies/SDL/include/SDL_cpuinfo.h +39 -4
  10. data/dependencies/SDL/include/SDL_egl.h +59 -9
  11. data/dependencies/SDL/include/SDL_endian.h +34 -3
  12. data/dependencies/SDL/include/SDL_events.h +32 -1
  13. data/dependencies/SDL/include/SDL_filesystem.h +5 -1
  14. data/dependencies/SDL/include/SDL_gamecontroller.h +78 -5
  15. data/dependencies/SDL/include/SDL_guid.h +100 -0
  16. data/dependencies/SDL/include/SDL_hints.h +645 -43
  17. data/dependencies/SDL/include/SDL_joystick.h +127 -7
  18. data/dependencies/SDL/include/SDL_keyboard.h +38 -1
  19. data/dependencies/SDL/include/SDL_keycode.h +6 -1
  20. data/dependencies/SDL/include/SDL_log.h +2 -2
  21. data/dependencies/SDL/include/SDL_main.h +42 -2
  22. data/dependencies/SDL/include/SDL_metal.h +2 -1
  23. data/dependencies/SDL/include/SDL_mouse.h +12 -1
  24. data/dependencies/SDL/include/SDL_opengl.h +0 -51
  25. data/dependencies/SDL/include/SDL_opengl_glext.h +2260 -231
  26. data/dependencies/SDL/include/SDL_opengles2_gl2.h +374 -339
  27. data/dependencies/SDL/include/SDL_opengles2_gl2ext.h +3479 -1496
  28. data/dependencies/SDL/include/SDL_opengles2_gl2platform.h +6 -9
  29. data/dependencies/SDL/include/SDL_opengles2_khrplatform.h +43 -14
  30. data/dependencies/SDL/include/SDL_platform.h +32 -6
  31. data/dependencies/SDL/include/SDL_rect.h +154 -2
  32. data/dependencies/SDL/include/SDL_render.h +46 -17
  33. data/dependencies/SDL/include/SDL_revision.h +6 -1
  34. data/dependencies/SDL/include/SDL_rwops.h +1 -15
  35. data/dependencies/SDL/include/SDL_scancode.h +46 -21
  36. data/dependencies/SDL/include/SDL_sensor.h +24 -3
  37. data/dependencies/SDL/include/SDL_stdinc.h +119 -8
  38. data/dependencies/SDL/include/SDL_surface.h +3 -1
  39. data/dependencies/SDL/include/SDL_system.h +66 -6
  40. data/dependencies/SDL/include/SDL_syswm.h +2 -0
  41. data/dependencies/SDL/include/SDL_test_common.h +1 -0
  42. data/dependencies/SDL/include/SDL_test_font.h +90 -3
  43. data/dependencies/SDL/include/SDL_thread.h +3 -3
  44. data/dependencies/SDL/include/SDL_touch.h +8 -0
  45. data/dependencies/SDL/include/SDL_version.h +19 -3
  46. data/dependencies/SDL/include/SDL_video.h +71 -9
  47. data/dependencies/SDL/include/begin_code.h +4 -4
  48. data/dependencies/SDL/lib/x64/libSDL2.dll.a +0 -0
  49. data/dependencies/SDL/lib/x86/libSDL2.dll.a +0 -0
  50. data/dependencies/SDL_sound/SDL_sound.c +210 -71
  51. data/dependencies/SDL_sound/SDL_sound.h +1 -1
  52. data/dependencies/SDL_sound/SDL_sound_coreaudio.c +111 -168
  53. data/dependencies/SDL_sound/SDL_sound_flac.c +0 -6
  54. data/dependencies/SDL_sound/SDL_sound_internal.h +27 -5
  55. data/dependencies/SDL_sound/SDL_sound_modplug.c +20 -8
  56. data/dependencies/SDL_sound/SDL_sound_mp3.c +11 -7
  57. data/dependencies/SDL_sound/SDL_sound_raw.c +1 -1
  58. data/dependencies/SDL_sound/SDL_sound_shn.c +1 -5
  59. data/dependencies/SDL_sound/SDL_sound_voc.c +1 -1
  60. data/dependencies/SDL_sound/SDL_sound_vorbis.c +2 -4
  61. data/dependencies/SDL_sound/SDL_sound_wav.c +44 -20
  62. data/dependencies/SDL_sound/dr_flac.h +237 -95
  63. data/dependencies/SDL_sound/dr_mp3.h +46 -33
  64. data/dependencies/SDL_sound/libmodplug/fastmix.c +53 -39
  65. data/dependencies/SDL_sound/libmodplug/libmodplug.h +0 -12
  66. data/dependencies/SDL_sound/libmodplug/load_669.c +37 -32
  67. data/dependencies/SDL_sound/libmodplug/load_amf.c +57 -44
  68. data/dependencies/SDL_sound/libmodplug/load_ams.c +127 -100
  69. data/dependencies/SDL_sound/libmodplug/load_dbm.c +40 -37
  70. data/dependencies/SDL_sound/libmodplug/load_dmf.c +61 -49
  71. data/dependencies/SDL_sound/libmodplug/load_dsm.c +18 -13
  72. data/dependencies/SDL_sound/libmodplug/load_far.c +31 -24
  73. data/dependencies/SDL_sound/libmodplug/load_gdm.c +27 -21
  74. data/dependencies/SDL_sound/libmodplug/load_it.c +106 -91
  75. data/dependencies/SDL_sound/libmodplug/load_mdl.c +43 -35
  76. data/dependencies/SDL_sound/libmodplug/load_med.c +66 -52
  77. data/dependencies/SDL_sound/libmodplug/load_mod.c +30 -26
  78. data/dependencies/SDL_sound/libmodplug/load_mt2.c +61 -50
  79. data/dependencies/SDL_sound/libmodplug/load_mtm.c +23 -17
  80. data/dependencies/SDL_sound/libmodplug/load_okt.c +18 -16
  81. data/dependencies/SDL_sound/libmodplug/load_psm.c +44 -32
  82. data/dependencies/SDL_sound/libmodplug/load_ptm.c +18 -14
  83. data/dependencies/SDL_sound/libmodplug/load_s3m.c +59 -53
  84. data/dependencies/SDL_sound/libmodplug/load_stm.c +23 -18
  85. data/dependencies/SDL_sound/libmodplug/load_ult.c +33 -29
  86. data/dependencies/SDL_sound/libmodplug/load_xm.c +64 -57
  87. data/dependencies/SDL_sound/libmodplug/mmcmp.c +2 -1
  88. data/dependencies/SDL_sound/libmodplug/snd_dsp.c +30 -20
  89. data/dependencies/SDL_sound/libmodplug/snd_flt.c +6 -4
  90. data/dependencies/SDL_sound/libmodplug/snd_fx.c +91 -65
  91. data/dependencies/SDL_sound/libmodplug/sndfile.c +91 -66
  92. data/dependencies/SDL_sound/libmodplug/sndmix.c +58 -35
  93. data/dependencies/SDL_sound/stb_vorbis.h +14 -9
  94. data/dependencies/mojoAL/mojoal.c +41 -24
  95. data/dependencies/utf8proc/utf8proc.c +1 -1
  96. data/dependencies/utf8proc/utf8proc.h +1 -1
  97. data/dependencies/utf8proc/utf8proc_data.h +3366 -3184
  98. data/lib/SDL2.dll +0 -0
  99. data/lib64/SDL2.dll +0 -0
  100. data/src/Window.cpp +3 -0
  101. metadata +5 -4
@@ -12,7 +12,6 @@
12
12
  #if SOUND_SUPPORTS_COREAUDIO
13
13
 
14
14
  #include <stddef.h> /* NULL */
15
- #include <arpa/inet.h> /* htonl */
16
15
  #include <AudioToolbox/AudioToolbox.h>
17
16
 
18
17
  typedef struct CoreAudioFileContainer
@@ -153,13 +152,13 @@ static AudioFileTypeID CoreAudio_GetAudioTypeForExtension(const char* file_exten
153
152
  {
154
153
  return 0;
155
154
  }
156
-
157
155
  }
158
156
 
159
- static const char* CoreAudio_FourCCToString(int32_t error_code)
157
+ #ifdef DEBUG_CHATTER /* used with SNDDBG() */
158
+ static const char* CoreAudio_FourCCToString(Sint32 error_code)
160
159
  {
161
160
  static char return_string[16];
162
- uint32_t big_endian_code = htonl(error_code);
161
+ Uint32 big_endian_code = SDL_SwapBE32((Uint32)error_code);
163
162
  char* big_endian_str = (char*)&big_endian_code;
164
163
  // see if it appears to be a 4-char-code
165
164
  if(isprint(big_endian_str[0])
@@ -187,7 +186,7 @@ static const char* CoreAudio_FourCCToString(int32_t error_code)
187
186
  }
188
187
  return return_string;
189
188
  }
190
-
189
+ #endif
191
190
 
192
191
 
193
192
  SInt64 CoreAudio_SizeCallback(void* inClientData)
@@ -229,12 +228,10 @@ static int CoreAudio_open(Sound_Sample *sample, const char *ext)
229
228
  AudioStreamBasicDescription output_format;
230
229
  Float64 estimated_duration;
231
230
  UInt32 format_size;
232
-
233
231
 
234
232
  core_audio_file_container = (CoreAudioFileContainer*)SDL_malloc(sizeof(CoreAudioFileContainer));
235
233
  BAIL_IF_MACRO(core_audio_file_container == NULL, ERR_OUT_OF_MEMORY, 0);
236
234
 
237
-
238
235
  audio_file_id = (AudioFileID*)SDL_malloc(sizeof(AudioFileID));
239
236
  BAIL_IF_MACRO(audio_file_id == NULL, ERR_OUT_OF_MEMORY, 0);
240
237
 
@@ -255,15 +252,15 @@ static int CoreAudio_open(Sound_Sample *sample, const char *ext)
255
252
  SNDDBG(("Core Audio: can't grok data. reason: [%s].\n", CoreAudio_FourCCToString(error_result)));
256
253
  BAIL_MACRO("Core Audio: Not valid audio data.", 0);
257
254
  } /* if */
258
-
259
- format_size = sizeof(actual_format);
260
- error_result = AudioFileGetProperty(
255
+
256
+ format_size = sizeof(actual_format);
257
+ error_result = AudioFileGetProperty(
261
258
  *audio_file_id,
262
259
  kAudioFilePropertyDataFormat,
263
260
  &format_size,
264
261
  &actual_format
265
262
  );
266
- if (error_result != noErr)
263
+ if (error_result != noErr)
267
264
  {
268
265
  AudioFileClose(*audio_file_id);
269
266
  SDL_free(audio_file_id);
@@ -272,14 +269,14 @@ static int CoreAudio_open(Sound_Sample *sample, const char *ext)
272
269
  BAIL_MACRO("Core Audio: Not valid audio data.", 0);
273
270
  } /* if */
274
271
 
275
- format_size = sizeof(estimated_duration);
276
- error_result = AudioFileGetProperty(
272
+ format_size = sizeof(estimated_duration);
273
+ error_result = AudioFileGetProperty(
277
274
  *audio_file_id,
278
275
  kAudioFilePropertyEstimatedDuration,
279
276
  &format_size,
280
277
  &estimated_duration
281
278
  );
282
- if (error_result != noErr)
279
+ if (error_result != noErr)
283
280
  {
284
281
  AudioFileClose(*audio_file_id);
285
282
  SDL_free(audio_file_id);
@@ -288,61 +285,65 @@ static int CoreAudio_open(Sound_Sample *sample, const char *ext)
288
285
  BAIL_MACRO("Core Audio: Not valid audio data.", 0);
289
286
  } /* if */
290
287
 
291
-
292
288
  core_audio_file_container->audioFileID = audio_file_id;
293
-
289
+
294
290
  internal->decoder_private = core_audio_file_container;
295
-
291
+
296
292
  sample->flags = SOUND_SAMPLEFLAG_CANSEEK;
297
293
  sample->actual.rate = (UInt32) actual_format.mSampleRate;
298
294
  sample->actual.channels = (UInt8)actual_format.mChannelsPerFrame;
299
295
  internal->total_time = (SInt32)(estimated_duration * 1000.0 + 0.5);
300
296
 
301
- #if 0
302
- /* FIXME: Both Core Audio and SDL 1.3 support float and 32-bit formats */
303
- if(actual_format.mFormatFlags & kAudioFormatFlagIsBigEndian)
297
+ if(0 == sample->desired.format)
304
298
  {
305
- if(16 == actual_format.mBitsPerChannel)
299
+ if(32 == actual_format.mBitsPerChannel)
306
300
  {
307
- if(kAudioFormatFlagIsSignedInteger & actual_format.mFormatFlags)
301
+ if(kAudioFormatFlagIsFloat & actual_format.mFormatFlags)
308
302
  {
309
- sample->actual.format = AUDIO_S16MSB;
303
+ if(actual_format.mFormatFlags & kAudioFormatFlagIsBigEndian)
304
+ {
305
+ sample->actual.format = AUDIO_F32MSB;
306
+ }
307
+ else
308
+ {
309
+ sample->actual.format = AUDIO_F32LSB;
310
+ }
310
311
  }
311
312
  else
312
313
  {
313
- sample->actual.format = AUDIO_U16MSB;
314
+ if(actual_format.mFormatFlags & kAudioFormatFlagIsBigEndian)
315
+ {
316
+ sample->actual.format = AUDIO_S32MSB;
317
+ }
318
+ else
319
+ {
320
+ sample->actual.format = AUDIO_S32LSB;
321
+ }
314
322
  }
315
323
  }
316
- else if(8 == actual_format.mBitsPerChannel)
324
+ else if(16 == actual_format.mBitsPerChannel)
317
325
  {
318
326
  if(kAudioFormatFlagIsSignedInteger & actual_format.mFormatFlags)
319
327
  {
320
- sample->actual.format = AUDIO_S8;
328
+ if(actual_format.mFormatFlags & kAudioFormatFlagIsBigEndian)
329
+ {
330
+ sample->actual.format = AUDIO_S16MSB;
331
+ }
332
+ else
333
+ {
334
+ sample->actual.format = AUDIO_S16LSB;
335
+ }
321
336
  }
322
337
  else
323
338
  {
324
- sample->actual.format = AUDIO_U8;
325
- }
326
- }
327
- else // might be 0 for undefined?
328
- {
329
- // This case seems to come up a lot for me. Maybe for file types like .m4a?
330
- sample->actual.format = AUDIO_S16SYS;
331
- SNDDBG(("Core Audio: Unsupported actual_format.mBitsPerChannel: [%d].\n", actual_format.mBitsPerChannel));
332
-
333
- }
334
- }
335
- else // little endian
336
- {
337
- if(16 == actual_format.mBitsPerChannel)
338
- {
339
- if(kAudioFormatFlagIsSignedInteger & actual_format.mFormatFlags)
340
- {
341
- sample->actual.format = AUDIO_S16LSB;
342
- }
343
- else
344
- {
345
- sample->actual.format = AUDIO_U16LSB;
339
+ if(actual_format.mFormatFlags & kAudioFormatFlagIsBigEndian)
340
+ {
341
+ sample->actual.format = AUDIO_U16MSB;
342
+ }
343
+ else
344
+ {
345
+ sample->actual.format = AUDIO_U16LSB;
346
+ }
346
347
  }
347
348
  }
348
349
  else if(8 == actual_format.mBitsPerChannel)
@@ -353,39 +354,38 @@ static int CoreAudio_open(Sound_Sample *sample, const char *ext)
353
354
  }
354
355
  else
355
356
  {
356
- sample->actual.format = AUDIO_U8;
357
+ sample->actual.format = AUDIO_U8;
357
358
  }
358
359
  }
359
- else // might be 0 for undefined?
360
+ else // might be 0 for undefined?
360
361
  {
362
+ // This case seems to come up a lot for me. Maybe for file types like .m4a?
361
363
  sample->actual.format = AUDIO_S16SYS;
362
-
363
364
  SNDDBG(("Core Audio: Unsupported actual_format.mBitsPerChannel: [%d].\n", actual_format.mBitsPerChannel));
364
365
  }
365
-
366
366
  }
367
- #else
368
-
369
-
370
-
371
- /*
372
- * I want to use Core Audio to do conversion and decoding for performance reasons.
373
- * This is particularly important on mobile devices like iOS.
374
- * Taking from the Ogg Vorbis decode, I pretend the "actual" format is the same
375
- * as the desired format.
376
- */
377
- sample->actual.format = (sample->desired.format == 0) ?
378
- AUDIO_S16SYS : sample->desired.format;
379
- #endif
367
+ else
368
+ {
369
+ /*
370
+ * I want to use Core Audio to do conversion and decoding for performance reasons.
371
+ * This is particularly important on mobile devices like iOS.
372
+ * Taking from the Ogg Vorbis decode, I pretend the "actual" format is the same
373
+ * as the desired format.
374
+ */
375
+ sample->actual.format = sample->desired.format;
376
+ }
380
377
 
378
+ /* AUDIO_U16LSB and AUDIO_U16MSB don't seem to be supported by CoreAudio. */
379
+ if (sample->actual.format == AUDIO_U16LSB)
380
+ sample->actual.format = AUDIO_S16LSB;
381
+ if (sample->actual.format == AUDIO_U16MSB)
382
+ sample->actual.format = AUDIO_S16MSB;
381
383
 
382
384
  SNDDBG(("CoreAudio: channels == (%d).\n", sample->actual.channels));
383
385
  SNDDBG(("CoreAudio: sampling rate == (%d).\n",sample->actual.rate));
384
386
  SNDDBG(("CoreAudio: total seconds of sample == (%d).\n", internal->total_time));
385
387
  SNDDBG(("CoreAudio: sample->actual.format == (%d).\n", sample->actual.format));
386
388
 
387
-
388
-
389
389
  error_result = ExtAudioFileWrapAudioFileID(*audio_file_id,
390
390
  false, // set to false for read-only
391
391
  &core_audio_file_container->extAudioFileRef
@@ -399,7 +399,6 @@ static int CoreAudio_open(Sound_Sample *sample, const char *ext)
399
399
  BAIL_MACRO("Core Audio: Failed to wrap data.", 0);
400
400
  } /* if */
401
401
 
402
-
403
402
  /* The output format must be linear PCM because that's the only type OpenAL knows how to deal with.
404
403
  * Set the client format to 16 bit signed integer (native-endian) data because that is the most
405
404
  * optimal format on iPhone/iPod Touch hardware.
@@ -408,74 +407,37 @@ static int CoreAudio_open(Sound_Sample *sample, const char *ext)
408
407
  output_format.mSampleRate = actual_format.mSampleRate; // preserve the original sample rate
409
408
  output_format.mChannelsPerFrame = actual_format.mChannelsPerFrame; // preserve the number of channels
410
409
  output_format.mFormatID = kAudioFormatLinearPCM; // We want linear PCM data
410
+ output_format.mFormatFlags = kAudioFormatFlagIsPacked; // I seem to read failures problems without kAudioFormatFlagIsPacked. From a mailing list post, this seems to be a Core Audio bug.
411
411
  output_format.mFramesPerPacket = 1; // We know for linear PCM, the definition is 1 frame per packet
412
+ output_format.mBitsPerChannel = SDL_AUDIO_BITSIZE(sample->actual.format);
412
413
 
413
- if(sample->desired.format == 0)
414
+ if(SDL_AUDIO_ISFLOAT(sample->actual.format))
414
415
  {
415
- // do AUDIO_S16SYS
416
- output_format.mFormatFlags = kAudioFormatFlagsNativeEndian | kAudioFormatFlagIsSignedInteger | kAudioFormatFlagIsPacked; // I seem to read failures problems without kAudioFormatFlagIsPacked. From a mailing list post, this seems to be a Core Audio bug.
417
- output_format.mBitsPerChannel = 16; // We know we want 16-bit
416
+ output_format.mFormatFlags |= kAudioFormatFlagIsFloat;
418
417
  }
419
- else
420
- {
421
- output_format.mFormatFlags = 0; // clear flags
422
- output_format.mFormatFlags |= kAudioFormatFlagIsPacked; // I seem to read failures problems without kAudioFormatFlagIsPacked. From a mailing list post, this seems to be a Core Audio bug.
423
- // Mask against bitsize
424
- if(0xFF & sample->desired.format)
425
- {
426
- output_format.mBitsPerChannel = 16; /* 16-bit */
427
- }
428
- else
429
- {
430
- output_format.mBitsPerChannel = 8; /* 8-bit */
431
- }
432
418
 
433
- // Mask for signed/unsigned
434
- if((1<<15) & sample->desired.format)
435
- {
436
- output_format.mFormatFlags = output_format.mFormatFlags | kAudioFormatFlagIsSignedInteger;
419
+ if(SDL_AUDIO_ISSIGNED(sample->actual.format))
420
+ {
421
+ output_format.mFormatFlags |= kAudioFormatFlagIsSignedInteger;
422
+ }
437
423
 
438
- }
439
- else
440
- {
441
- // no flag set for unsigned
442
- }
443
- // Mask for big/little endian
444
- if((1<<12) & sample->desired.format)
445
- {
446
- output_format.mFormatFlags = output_format.mFormatFlags | kAudioFormatFlagIsBigEndian;
447
- }
448
- else
449
- {
450
- // no flag set for little endian
451
- }
424
+ if(SDL_AUDIO_ISBIGENDIAN(sample->actual.format))
425
+ {
426
+ output_format.mFormatFlags |= kAudioFormatFlagIsBigEndian;
452
427
  }
453
428
 
454
429
  output_format.mBytesPerPacket = output_format.mBitsPerChannel/8 * output_format.mChannelsPerFrame; // e.g. 16-bits/8 * channels => so 2-bytes per channel per frame
455
430
  output_format.mBytesPerFrame = output_format.mBitsPerChannel/8 * output_format.mChannelsPerFrame; // For PCM, since 1 frame is 1 packet, it is the same as mBytesPerPacket
456
431
 
457
-
458
- /*
459
- output_format.mSampleRate = actual_format.mSampleRate; // preserve the original sample rate
460
- output_format.mChannelsPerFrame = actual_format.mChannelsPerFrame; // preserve the number of channels
461
- output_format.mFormatID = kAudioFormatLinearPCM; // We want linear PCM data
462
- // output_format.mFormatFlags = kAudioFormatFlagsNativeEndian | kAudioFormatFlagIsPacked | kAudioFormatFlagIsSignedInteger;
463
- output_format.mFormatFlags = kAudioFormatFlagsNativeEndian | kAudioFormatFlagIsSignedInteger;
464
- output_format.mFramesPerPacket = 1; // We know for linear PCM, the definition is 1 frame per packet
465
- output_format.mBitsPerChannel = 16; // We know we want 16-bit
466
- output_format.mBytesPerPacket = 2 * output_format.mChannelsPerFrame; // We know we are using 16-bit, so 2-bytes per channel per frame
467
- output_format.mBytesPerFrame = 2 * output_format.mChannelsPerFrame; // For PCM, since 1 frame is 1 packet, it is the same as mBytesPerPacket
468
- */
469
- SNDDBG(("output_format: mSampleRate: %lf\n", output_format.mSampleRate));
470
- SNDDBG(("output_format: mChannelsPerFrame: %d\n", output_format.mChannelsPerFrame));
471
- SNDDBG(("output_format: mFormatID: %d\n", output_format.mFormatID));
472
- SNDDBG(("output_format: mFormatFlags: %d\n", output_format.mFormatFlags));
473
- SNDDBG(("output_format: mFramesPerPacket: %d\n", output_format.mFramesPerPacket));
474
- SNDDBG(("output_format: mBitsPerChannel: %d\n", output_format.mBitsPerChannel));
475
- SNDDBG(("output_format: mBytesPerPacket: %d\n", output_format.mBytesPerPacket));
476
- SNDDBG(("output_format: mBytesPerFrame: %d\n", output_format.mBytesPerFrame));
477
-
478
-
432
+ SNDDBG(("output_format: mSampleRate: %lf\n", output_format.mSampleRate));
433
+ SNDDBG(("output_format: mChannelsPerFrame: %d\n", output_format.mChannelsPerFrame));
434
+ SNDDBG(("output_format: mFormatID: %d\n", output_format.mFormatID));
435
+ SNDDBG(("output_format: mFormatFlags: %d\n", output_format.mFormatFlags));
436
+ SNDDBG(("output_format: mFramesPerPacket: %d\n", output_format.mFramesPerPacket));
437
+ SNDDBG(("output_format: mBitsPerChannel: %d\n", output_format.mBitsPerChannel));
438
+ SNDDBG(("output_format: mBytesPerPacket: %d\n", output_format.mBytesPerPacket));
439
+ SNDDBG(("output_format: mBytesPerFrame: %d\n", output_format.mBytesPerFrame));
440
+
479
441
  /* Set the desired client (output) data format */
480
442
  error_result = ExtAudioFileSetProperty(core_audio_file_container->extAudioFileRef, kExtAudioFileProperty_ClientDataFormat, sizeof(output_format), &output_format);
481
443
  if(noErr != error_result)
@@ -486,21 +448,16 @@ static int CoreAudio_open(Sound_Sample *sample, const char *ext)
486
448
  SDL_free(core_audio_file_container);
487
449
  SNDDBG(("Core Audio: ExtAudioFileSetProperty(kExtAudioFileProperty_ClientDataFormat) failed, reason: [%s].\n", CoreAudio_FourCCToString(error_result)));
488
450
  BAIL_MACRO("Core Audio: Not valid audio data.", 0);
489
- }
490
-
451
+ }
491
452
 
492
453
  core_audio_file_container->outputFormat = (AudioStreamBasicDescription*)SDL_malloc(sizeof(AudioStreamBasicDescription));
493
454
  BAIL_IF_MACRO(core_audio_file_container->outputFormat == NULL, ERR_OUT_OF_MEMORY, 0);
494
455
 
495
-
496
-
497
456
  /* Copy the output format to the audio_description that was passed in so the
498
457
  * info will be returned to the user.
499
458
  */
500
459
  SDL_memcpy(core_audio_file_container->outputFormat, &output_format, sizeof(AudioStreamBasicDescription));
501
460
 
502
-
503
-
504
461
  return 1;
505
462
  } /* CoreAudio_open */
506
463
 
@@ -545,55 +502,48 @@ static Uint32 CoreAudio_read(Sound_Sample *sample)
545
502
 
546
503
 
547
504
  // void* temp_buffer = SDL_malloc(max_buffer_size);
548
-
505
+
549
506
  AudioBufferList audio_buffer_list;
550
507
  audio_buffer_list.mNumberBuffers = 1;
551
508
  audio_buffer_list.mBuffers[0].mDataByteSize = max_buffer_size;
552
509
  audio_buffer_list.mBuffers[0].mNumberChannels = core_audio_file_container->outputFormat->mChannelsPerFrame;
553
510
  audio_buffer_list.mBuffers[0].mData = internal->buffer;
554
511
 
555
-
556
512
  bytes_remaining = max_buffer_size;
557
513
  buffer_size_in_frames_remaining = buffer_size_in_frames;
558
-
559
- // oops. Due to the kAudioFormatFlagIsPacked bug,
514
+
515
+ // oops. Due to the kAudioFormatFlagIsPacked bug,
560
516
  // I was misled to believe that Core Audio
561
- // was not always filling my entire requested buffer.
517
+ // was not always filling my entire requested buffer.
562
518
  // So this while-loop might be unnecessary.
563
- // However, I have not exhaustively tested all formats,
519
+ // However, I have not exhaustively tested all formats,
564
520
  // so maybe it is possible this loop is useful.
565
521
  // It might also handle the not-evenly disvisible case above.
566
522
  while(buffer_size_in_frames_remaining > 0 && !(sample->flags & SOUND_SAMPLEFLAG_EOF))
567
523
  {
568
-
569
524
  data_buffer_size = (UInt32)(buffer_size_in_frames * core_audio_file_container->outputFormat->mBytesPerFrame);
570
- // printf("data_buffer_size=%d\n", data_buffer_size);
525
+ // printf("data_buffer_size=%d\n", data_buffer_size);
571
526
 
572
527
  buffer_size_in_frames = buffer_size_in_frames_remaining;
573
-
574
- // printf("reading buffer_size_in_frames=%"PRId64"\n", buffer_size_in_frames);
575
528
 
529
+ // printf("reading buffer_size_in_frames=%"PRId64"\n", buffer_size_in_frames);
576
530
 
577
531
  audio_buffer_list.mBuffers[0].mDataByteSize = bytes_remaining;
578
532
  audio_buffer_list.mBuffers[0].mData = &(((UInt8*)internal->buffer)[total_bytes_read]);
579
533
 
580
-
581
534
  /* Read the data into an AudioBufferList */
582
535
  error_result = ExtAudioFileRead(core_audio_file_container->extAudioFileRef, &buffer_size_in_frames, &audio_buffer_list);
583
536
  if(error_result == noErr)
584
537
  {
585
-
586
-
587
538
  /* Success */
588
-
589
539
  total_frames_read += buffer_size_in_frames;
590
540
  buffer_size_in_frames_remaining = buffer_size_in_frames_remaining - buffer_size_in_frames;
591
-
541
+
592
542
  // printf("read buffer_size_in_frames=%"PRId64", buffer_size_in_frames_remaining=%"PRId64"\n", buffer_size_in_frames, buffer_size_in_frames_remaining);
593
543
 
594
544
  /* ExtAudioFileRead returns the number of frames actually read. Need to convert back to bytes. */
595
545
  data_buffer_size = (UInt32)(buffer_size_in_frames * core_audio_file_container->outputFormat->mBytesPerFrame);
596
- // printf("data_buffer_size=%d\n", data_buffer_size);
546
+ // printf("data_buffer_size=%d\n", data_buffer_size);
597
547
 
598
548
  total_bytes_read += data_buffer_size;
599
549
  bytes_remaining = bytes_remaining - data_buffer_size;
@@ -601,20 +551,18 @@ static Uint32 CoreAudio_read(Sound_Sample *sample)
601
551
  /* Note: 0 == buffer_size_in_frames is a legitimate value meaning we are EOF. */
602
552
  if(0 == buffer_size_in_frames)
603
553
  {
604
- sample->flags |= SOUND_SAMPLEFLAG_EOF;
554
+ sample->flags |= SOUND_SAMPLEFLAG_EOF;
605
555
  }
606
-
607
556
  }
608
- else
557
+ else
609
558
  {
610
559
  SNDDBG(("Core Audio: ExtAudioFileReadfailed, reason: [%s].\n", CoreAudio_FourCCToString(error_result)));
611
560
 
612
561
  sample->flags |= SOUND_SAMPLEFLAG_ERROR;
613
562
  break;
614
-
615
563
  }
616
564
  }
617
-
565
+
618
566
  if( (!(sample->flags & SOUND_SAMPLEFLAG_EOF)) && (total_bytes_read < max_buffer_size))
619
567
  {
620
568
  SNDDBG(("Core Audio: ExtAudioFileReadfailed SOUND_SAMPLEFLAG_EAGAIN, reason: [total_bytes_read < max_buffer_size], %d, %d.\n", total_bytes_read , max_buffer_size));
@@ -628,13 +576,12 @@ static Uint32 CoreAudio_read(Sound_Sample *sample)
628
576
 
629
577
  static int CoreAudio_rewind(Sound_Sample *sample)
630
578
  {
631
- OSStatus error_result = noErr;
579
+ OSStatus error_result = noErr;
632
580
  Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque;
633
581
  CoreAudioFileContainer* core_audio_file_container = (CoreAudioFileContainer *) internal->decoder_private;
634
-
582
+
635
583
  error_result = ExtAudioFileSeek(core_audio_file_container->extAudioFileRef, 0);
636
- if(error_result != noErr)
637
- {
584
+ if(error_result != noErr) {
638
585
  sample->flags |= SOUND_SAMPLEFLAG_ERROR;
639
586
  }
640
587
  return 1;
@@ -651,10 +598,8 @@ static int CoreAudio_seek(Sound_Sample *sample, Uint32 ms)
651
598
  Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque;
652
599
  CoreAudioFileContainer* core_audio_file_container = (CoreAudioFileContainer *) internal->decoder_private;
653
600
  SInt64 frame_offset = 0;
654
- AudioStreamBasicDescription actual_format;
655
- UInt32 format_size;
656
601
 
657
-
602
+ #if 0 /* not working */
658
603
  /* I'm confused. The Apple documentation says this:
659
604
  "Seek position is specified in the sample rate and frame count of the file’s audio data format
660
605
  — not your application’s audio data format."
@@ -663,16 +608,15 @@ static int CoreAudio_seek(Sound_Sample *sample, Uint32 ms)
663
608
  When I use outputFormat, things seem to work correctly.
664
609
  I must be misinterpreting the documentation or doing something wrong.
665
610
  */
666
- #if 0 /* not working */
667
- format_size = sizeof(AudioStreamBasicDescription);
668
- error_result = AudioFileGetProperty(
611
+ AudioStreamBasicDescription actual_format;
612
+ UInt32 format_size = sizeof(AudioStreamBasicDescription);
613
+ error_result = AudioFileGetProperty(
669
614
  *core_audio_file_container->audioFileID,
670
615
  kAudioFilePropertyDataFormat,
671
616
  &format_size,
672
617
  &actual_format
673
618
  );
674
- if(error_result != noErr)
675
- {
619
+ if(error_result != noErr) {
676
620
  sample->flags |= SOUND_SAMPLEFLAG_ERROR;
677
621
  BAIL_MACRO("Core Audio: Could not GetProperty for kAudioFilePropertyDataFormat.", 0);
678
622
  } /* if */
@@ -686,11 +630,10 @@ static int CoreAudio_seek(Sound_Sample *sample, Uint32 ms)
686
630
 
687
631
  // computed against actual format and not the client format
688
632
  error_result = ExtAudioFileSeek(core_audio_file_container->extAudioFileRef, frame_offset);
689
- if(error_result != noErr)
690
- {
633
+ if(error_result != noErr) {
691
634
  sample->flags |= SOUND_SAMPLEFLAG_ERROR;
692
635
  }
693
-
636
+
694
637
  return 1;
695
638
  } /* CoreAudio_seek */
696
639
 
@@ -730,7 +673,7 @@ const Sound_DecoderFunctions __Sound_DecoderFunctions_CoreAudio =
730
673
  "Eric Wing <ewing . public @ playcontrol.net>",
731
674
  "https://playcontrol.net"
732
675
  },
733
-
676
+
734
677
  CoreAudio_init, /* init() method */
735
678
  CoreAudio_quit, /* quit() method */
736
679
  CoreAudio_open, /* open() method */
@@ -35,12 +35,6 @@
35
35
  #define DRFLAC_FREE(p) SDL_free((p))
36
36
  #define DRFLAC_COPY_MEMORY(dst, src, sz) SDL_memcpy((dst), (src), (sz))
37
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
38
 
45
39
  #include "dr_flac.h"
46
40
 
@@ -20,6 +20,11 @@
20
20
 
21
21
  #include "SDL_sound.h"
22
22
 
23
+ /* SDL_AudioStream, which we use internally, didn't arrive until SDL 2.0.7. */
24
+ #if !SDL_VERSION_ATLEAST(2, 0, 7)
25
+ #error SDL_sound requires SDL 2.0.7 or later. Please upgrade.
26
+ #endif
27
+
23
28
  #if ((defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__)) && !(defined(_WIN32) || defined(__OS2__))
24
29
  #define SOUND_HAVE_PRAGMA_VISIBILITY 1
25
30
  #endif
@@ -140,7 +145,9 @@ typedef struct __SOUND_DECODERFUNCTIONS__
140
145
  * Sound_Sample *prev; (offlimits)
141
146
  * SDL_RWops *rw; (can use, but do NOT close it)
142
147
  * const Sound_DecoderFunctions *funcs; (that's this structure)
143
- * SDL_AudioCVT sdlcvt; (offlimits)
148
+ * SDL_AudioStream stream; (offlimits)
149
+ * SDL_bool pending_eof; (offlimits)
150
+ * SDL_bool pending_error; (offlimits)
144
151
  * void *buffer; (offlimits until read() method)
145
152
  * Uint32 buffer_size; (offlimits until read() method)
146
153
  * void *decoder_private; (read and write access)
@@ -205,7 +212,7 @@ typedef struct __SOUND_DECODERFUNCTIONS__
205
212
  /*
206
213
  * Reset the decoding to the beginning of the stream. Nonzero on
207
214
  * success, zero on failure.
208
- *
215
+ *
209
216
  * The purpose of this method is to allow for higher efficiency than
210
217
  * an application could get by just recreating the sample externally;
211
218
  * not only do they not have to reopen the RWops, reallocate buffers,
@@ -223,9 +230,9 @@ typedef struct __SOUND_DECODERFUNCTIONS__
223
230
  /*
224
231
  * Reposition the decoding to an arbitrary point. Nonzero on
225
232
  * success, zero on failure.
226
- *
233
+ *
227
234
  * The purpose of this method is to allow for higher efficiency than
228
- * an application could get by just rewinding the sample and
235
+ * an application could get by just rewinding the sample and
229
236
  * decoding to a given point.
230
237
  *
231
238
  * The decoder is responsible for calling seek() on the associated
@@ -246,7 +253,9 @@ typedef struct __SOUND_SAMPLEINTERNAL__
246
253
  Sound_Sample *prev;
247
254
  SDL_RWops *rw;
248
255
  const Sound_DecoderFunctions *funcs;
249
- SDL_AudioCVT sdlcvt;
256
+ SDL_AudioStream *stream;
257
+ SDL_bool pending_eof;
258
+ SDL_bool pending_error;
250
259
  void *buffer;
251
260
  Uint32 buffer_size;
252
261
  void *decoder_private;
@@ -272,6 +281,10 @@ typedef struct __SOUND_SAMPLEINTERNAL__
272
281
  #define ERR_PREV_EOF "Previous decoding already triggered EOF"
273
282
  #define ERR_CANNOT_SEEK "Sample is not seekable"
274
283
 
284
+ #ifdef __cplusplus
285
+ extern "C" {
286
+ #endif
287
+
275
288
  /*
276
289
  * Call this to set the message returned by Sound_GetError().
277
290
  * Please only use the ERR_* constants above, or add new constants to the
@@ -305,6 +318,15 @@ extern char *SDL_strtokr(char *s1, const char *s2, char **saveptr);
305
318
  extern int SDL_rand(void);
306
319
  extern void SDL_srand(unsigned int seed);
307
320
 
321
+ /* Wrappers around the SDL versions of these in case you're on an older SDL */
322
+ extern void *__Sound_SIMDAlloc(const size_t len);
323
+ extern void *__Sound_SIMDRealloc(void *mem, const size_t len);
324
+ extern void __Sound_SIMDFree(void *ptr);
325
+
326
+ #ifdef __cplusplus
327
+ }
328
+ #endif
329
+
308
330
  #endif /* defined _INCLUDE_SDL_SOUND_INTERNAL_H_ */
309
331
 
310
332
  /* end of SDL_sound_internal.h ... */
@@ -121,14 +121,26 @@ static int MODPLUG_open(Sound_Sample *sample, const char *ext)
121
121
 
122
122
  SDL_memcpy(&sample->actual, &sample->desired, sizeof (Sound_AudioInfo));
123
123
  if (sample->actual.rate == 0) sample->actual.rate = 44100;
124
- if (sample->actual.channels == 0) sample->actual.channels = 2;
124
+ if (sample->actual.channels != 1) sample->actual.channels = 2;
125
125
  if (sample->actual.format == 0) sample->actual.format = AUDIO_S16SYS;
126
126
 
127
- SDL_zero(settings);
127
+ switch (sample->actual.format) {
128
+ case AUDIO_U8:
129
+ case AUDIO_S8:
130
+ sample->actual.format = AUDIO_U8;
131
+ break;
132
+ case AUDIO_S32MSB:
133
+ case AUDIO_S32LSB:
134
+ case AUDIO_F32MSB:
135
+ case AUDIO_F32LSB:
136
+ sample->actual.format = AUDIO_S32SYS;
137
+ break;
138
+ default:
139
+ sample->actual.format = AUDIO_S16SYS;
140
+ break;
141
+ }
128
142
 
129
- settings.mChannels=sample->actual.channels;
130
- settings.mFrequency=sample->actual.rate;
131
- settings.mBits = sample->actual.format & 0xFF;
143
+ SDL_zero(settings);
132
144
 
133
145
  /* The settings will require some experimenting. I've borrowed some
134
146
  of them from the XMMS ModPlug plugin. */
@@ -143,9 +155,9 @@ static int MODPLUG_open(Sound_Sample *sample, const char *ext)
143
155
  settings.mBassRange = 30;
144
156
  settings.mSurroundDepth = 20;
145
157
  settings.mSurroundDelay = 20;
146
- settings.mChannels = 2;
147
- settings.mBits = 16;
148
- settings.mFrequency = 44100;
158
+ settings.mChannels = sample->actual.channels;
159
+ settings.mBits = SDL_AUDIO_BITSIZE(sample->actual.format);
160
+ settings.mFrequency = sample->actual.rate;
149
161
  settings.mResamplingMode = MODPLUG_RESAMPLE_FIR;
150
162
  settings.mLoopCount = 0;
151
163