gosu 1.4.5.pre1 → 1.4.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (152) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +0 -8
  3. data/dependencies/SDL/include/SDL.h +2 -1
  4. data/dependencies/SDL/include/SDL_assert.h +8 -12
  5. data/dependencies/SDL/include/SDL_atomic.h +21 -1
  6. data/dependencies/SDL/include/SDL_audio.h +41 -5
  7. data/dependencies/SDL/include/SDL_bits.h +1 -1
  8. data/dependencies/SDL/include/SDL_blendmode.h +5 -7
  9. data/dependencies/SDL/include/SDL_clipboard.h +48 -1
  10. data/dependencies/SDL/include/SDL_config.h +73 -47
  11. data/dependencies/SDL/include/SDL_cpuinfo.h +40 -5
  12. data/dependencies/SDL/include/SDL_egl.h +60 -10
  13. data/dependencies/SDL/include/SDL_endian.h +35 -4
  14. data/dependencies/SDL/include/SDL_error.h +1 -1
  15. data/dependencies/SDL/include/SDL_events.h +33 -2
  16. data/dependencies/SDL/include/SDL_filesystem.h +6 -2
  17. data/dependencies/SDL/include/SDL_gamecontroller.h +79 -6
  18. data/dependencies/SDL/include/SDL_gesture.h +1 -1
  19. data/dependencies/SDL/include/SDL_guid.h +100 -0
  20. data/dependencies/SDL/include/SDL_haptic.h +1 -1
  21. data/dependencies/SDL/include/SDL_hidapi.h +1 -1
  22. data/dependencies/SDL/include/SDL_hints.h +646 -44
  23. data/dependencies/SDL/include/SDL_joystick.h +128 -8
  24. data/dependencies/SDL/include/SDL_keyboard.h +39 -2
  25. data/dependencies/SDL/include/SDL_keycode.h +7 -2
  26. data/dependencies/SDL/include/SDL_loadso.h +1 -1
  27. data/dependencies/SDL/include/SDL_locale.h +1 -1
  28. data/dependencies/SDL/include/SDL_log.h +3 -3
  29. data/dependencies/SDL/include/SDL_main.h +43 -3
  30. data/dependencies/SDL/include/SDL_messagebox.h +1 -1
  31. data/dependencies/SDL/include/SDL_metal.h +3 -2
  32. data/dependencies/SDL/include/SDL_misc.h +1 -1
  33. data/dependencies/SDL/include/SDL_mouse.h +13 -2
  34. data/dependencies/SDL/include/SDL_mutex.h +1 -1
  35. data/dependencies/SDL/include/SDL_name.h +1 -1
  36. data/dependencies/SDL/include/SDL_opengl.h +1 -52
  37. data/dependencies/SDL/include/SDL_opengl_glext.h +2260 -231
  38. data/dependencies/SDL/include/SDL_opengles.h +1 -1
  39. data/dependencies/SDL/include/SDL_opengles2.h +1 -1
  40. data/dependencies/SDL/include/SDL_opengles2_gl2.h +374 -339
  41. data/dependencies/SDL/include/SDL_opengles2_gl2ext.h +3479 -1496
  42. data/dependencies/SDL/include/SDL_opengles2_gl2platform.h +6 -9
  43. data/dependencies/SDL/include/SDL_opengles2_khrplatform.h +43 -14
  44. data/dependencies/SDL/include/SDL_pixels.h +1 -1
  45. data/dependencies/SDL/include/SDL_platform.h +33 -7
  46. data/dependencies/SDL/include/SDL_power.h +1 -1
  47. data/dependencies/SDL/include/SDL_quit.h +1 -1
  48. data/dependencies/SDL/include/SDL_rect.h +155 -3
  49. data/dependencies/SDL/include/SDL_render.h +47 -18
  50. data/dependencies/SDL/include/SDL_revision.h +6 -1
  51. data/dependencies/SDL/include/SDL_rwops.h +2 -16
  52. data/dependencies/SDL/include/SDL_scancode.h +47 -22
  53. data/dependencies/SDL/include/SDL_sensor.h +25 -4
  54. data/dependencies/SDL/include/SDL_shape.h +1 -1
  55. data/dependencies/SDL/include/SDL_stdinc.h +120 -9
  56. data/dependencies/SDL/include/SDL_surface.h +4 -2
  57. data/dependencies/SDL/include/SDL_system.h +67 -7
  58. data/dependencies/SDL/include/SDL_syswm.h +3 -1
  59. data/dependencies/SDL/include/SDL_test.h +1 -1
  60. data/dependencies/SDL/include/SDL_test_assert.h +1 -1
  61. data/dependencies/SDL/include/SDL_test_common.h +2 -1
  62. data/dependencies/SDL/include/SDL_test_compare.h +1 -1
  63. data/dependencies/SDL/include/SDL_test_crc32.h +1 -1
  64. data/dependencies/SDL/include/SDL_test_font.h +91 -4
  65. data/dependencies/SDL/include/SDL_test_fuzzer.h +1 -1
  66. data/dependencies/SDL/include/SDL_test_harness.h +1 -1
  67. data/dependencies/SDL/include/SDL_test_images.h +1 -1
  68. data/dependencies/SDL/include/SDL_test_log.h +1 -1
  69. data/dependencies/SDL/include/SDL_test_md5.h +1 -1
  70. data/dependencies/SDL/include/SDL_test_memory.h +1 -1
  71. data/dependencies/SDL/include/SDL_test_random.h +1 -1
  72. data/dependencies/SDL/include/SDL_thread.h +6 -6
  73. data/dependencies/SDL/include/SDL_timer.h +1 -1
  74. data/dependencies/SDL/include/SDL_touch.h +9 -1
  75. data/dependencies/SDL/include/SDL_types.h +1 -1
  76. data/dependencies/SDL/include/SDL_version.h +20 -4
  77. data/dependencies/SDL/include/SDL_video.h +72 -10
  78. data/dependencies/SDL/include/begin_code.h +5 -5
  79. data/dependencies/SDL/include/close_code.h +1 -1
  80. data/dependencies/SDL/lib/x64/libSDL2.dll.a +0 -0
  81. data/dependencies/SDL/lib/x86/libSDL2.dll.a +0 -0
  82. data/dependencies/SDL_sound/SDL_sound.c +210 -71
  83. data/dependencies/SDL_sound/SDL_sound.h +1 -1
  84. data/dependencies/SDL_sound/SDL_sound_coreaudio.c +111 -168
  85. data/dependencies/SDL_sound/SDL_sound_flac.c +0 -6
  86. data/dependencies/SDL_sound/SDL_sound_internal.h +24 -2
  87. data/dependencies/SDL_sound/SDL_sound_modplug.c +20 -8
  88. data/dependencies/SDL_sound/SDL_sound_mp3.c +11 -7
  89. data/dependencies/SDL_sound/SDL_sound_raw.c +1 -1
  90. data/dependencies/SDL_sound/SDL_sound_shn.c +1 -5
  91. data/dependencies/SDL_sound/SDL_sound_voc.c +1 -1
  92. data/dependencies/SDL_sound/SDL_sound_vorbis.c +2 -4
  93. data/dependencies/SDL_sound/SDL_sound_wav.c +49 -20
  94. data/dependencies/SDL_sound/dr_flac.h +237 -95
  95. data/dependencies/SDL_sound/dr_mp3.h +46 -33
  96. data/dependencies/SDL_sound/libmodplug/fastmix.c +53 -39
  97. data/dependencies/SDL_sound/libmodplug/libmodplug.h +0 -12
  98. data/dependencies/SDL_sound/libmodplug/load_669.c +37 -32
  99. data/dependencies/SDL_sound/libmodplug/load_amf.c +57 -44
  100. data/dependencies/SDL_sound/libmodplug/load_ams.c +127 -100
  101. data/dependencies/SDL_sound/libmodplug/load_dbm.c +40 -37
  102. data/dependencies/SDL_sound/libmodplug/load_dmf.c +61 -49
  103. data/dependencies/SDL_sound/libmodplug/load_dsm.c +18 -13
  104. data/dependencies/SDL_sound/libmodplug/load_far.c +31 -24
  105. data/dependencies/SDL_sound/libmodplug/load_gdm.c +27 -21
  106. data/dependencies/SDL_sound/libmodplug/load_it.c +106 -91
  107. data/dependencies/SDL_sound/libmodplug/load_mdl.c +43 -35
  108. data/dependencies/SDL_sound/libmodplug/load_med.c +66 -52
  109. data/dependencies/SDL_sound/libmodplug/load_mod.c +30 -26
  110. data/dependencies/SDL_sound/libmodplug/load_mt2.c +61 -50
  111. data/dependencies/SDL_sound/libmodplug/load_mtm.c +23 -17
  112. data/dependencies/SDL_sound/libmodplug/load_okt.c +18 -16
  113. data/dependencies/SDL_sound/libmodplug/load_psm.c +44 -32
  114. data/dependencies/SDL_sound/libmodplug/load_ptm.c +18 -14
  115. data/dependencies/SDL_sound/libmodplug/load_s3m.c +59 -53
  116. data/dependencies/SDL_sound/libmodplug/load_stm.c +23 -18
  117. data/dependencies/SDL_sound/libmodplug/load_ult.c +33 -29
  118. data/dependencies/SDL_sound/libmodplug/load_xm.c +64 -57
  119. data/dependencies/SDL_sound/libmodplug/mmcmp.c +2 -1
  120. data/dependencies/SDL_sound/libmodplug/snd_dsp.c +30 -20
  121. data/dependencies/SDL_sound/libmodplug/snd_flt.c +6 -4
  122. data/dependencies/SDL_sound/libmodplug/snd_fx.c +91 -65
  123. data/dependencies/SDL_sound/libmodplug/sndfile.c +91 -66
  124. data/dependencies/SDL_sound/libmodplug/sndmix.c +58 -35
  125. data/dependencies/SDL_sound/stb_vorbis.h +14 -9
  126. data/dependencies/mojoAL/mojoal.c +68 -40
  127. data/dependencies/stb/stb_image.h +117 -27
  128. data/dependencies/utf8proc/utf8proc.c +1 -1
  129. data/dependencies/utf8proc/utf8proc.h +1 -1
  130. data/dependencies/utf8proc/utf8proc_data.h +3366 -3184
  131. data/ext/gosu/extconf.rb +1 -1
  132. data/include/Gosu/Version.hpp +1 -1
  133. data/lib/SDL2.dll +0 -0
  134. data/lib64/SDL2.dll +0 -0
  135. data/src/AudioFile.hpp +1 -1
  136. data/src/AudioFileSDLSound.cpp +2 -0
  137. data/src/AudioImpl.hpp +2 -2
  138. data/src/Input.cpp +30 -26
  139. data/src/RubyGosu.cxx +146 -93
  140. data/src/RubyGosu.h +5 -7
  141. data/src/Window.cpp +3 -0
  142. metadata +6 -15
  143. data/dependencies/SDL/include/SDL_config_android.h +0 -157
  144. data/dependencies/SDL/include/SDL_config_iphoneos.h +0 -166
  145. data/dependencies/SDL/include/SDL_config_macosx.h +0 -197
  146. data/dependencies/SDL/include/SDL_config_minimal.h +0 -82
  147. data/dependencies/SDL/include/SDL_config_pandora.h +0 -128
  148. data/dependencies/SDL/include/SDL_config_psp.h +0 -144
  149. data/dependencies/SDL/include/SDL_config_windows.h +0 -225
  150. data/dependencies/SDL/include/SDL_config_winrt.h +0 -215
  151. data/dependencies/SDL/include/SDL_config_wiz.h +0 -121
  152. data/dependencies/SDL/include/SDL_copying.h +0 -20
@@ -11,7 +11,10 @@
11
11
  #include <math.h>
12
12
  #include <float.h>
13
13
 
14
- #ifdef _WIN32
14
+ /* Unless compiling statically into another app, we want the public API
15
+ to export on Windows. Define these before including al.h, so we override
16
+ its attempt to mark these as `dllimport`. */
17
+ #if defined(_WIN32) && !defined(AL_LIBTYPE_STATIC)
15
18
  #define AL_API __declspec(dllexport)
16
19
  #define ALC_API __declspec(dllexport)
17
20
  #endif
@@ -20,8 +23,8 @@
20
23
  #define M_PI (3.14159265358979323846264338327950288)
21
24
  #endif
22
25
 
23
- #include "AL/al.h"
24
- #include "AL/alc.h"
26
+ #include "al.h"
27
+ #include "alc.h"
25
28
  #include "SDL.h"
26
29
 
27
30
  #ifdef __SSE__ /* if you are on x86 or x86-64, we assume you have SSE1 by now. */
@@ -470,6 +473,7 @@ SIMDALIGNEDSTRUCT ALsource
470
473
  ALfloat cone_outer_gain;
471
474
  ALbuffer *buffer;
472
475
  SDL_AudioStream *stream; /* for resampling. */
476
+ SDL_atomic_t total_queued_buffers; /* everything queued, playing and processed. AL_BUFFERS_QUEUED value. */
473
477
  BufferQueue buffer_queue;
474
478
  BufferQueue buffer_queue_processed;
475
479
  ALsizei offset; /* offset in bytes for converted stream! */
@@ -567,7 +571,7 @@ static void queue_new_buffer_items_recursive(BufferQueue *queue, BufferQueueItem
567
571
  return;
568
572
  }
569
573
 
570
- queue_new_buffer_items_recursive(queue, items->next);
574
+ queue_new_buffer_items_recursive(queue, (BufferQueueItem*)items->next);
571
575
  items->next = NULL;
572
576
  if (queue->tail) {
573
577
  queue->tail->next = items;
@@ -599,7 +603,7 @@ static void source_mark_all_buffers_processed(ALsource *src)
599
603
  while (src->buffer_queue.head) {
600
604
  void *ptr;
601
605
  BufferQueueItem *item = src->buffer_queue.head;
602
- src->buffer_queue.head = item->next;
606
+ src->buffer_queue.head = (BufferQueueItem*)item->next;
603
607
  SDL_AtomicAdd(&src->buffer_queue.num_items, -1);
604
608
 
605
609
  /* Move it to the processed queue for alSourceUnqueueBuffers() to pick up. */
@@ -619,7 +623,7 @@ static void source_release_buffer_queue(ALCcontext *ctx, ALsource *src)
619
623
  obtain_newly_queued_buffers(&src->buffer_queue);
620
624
  if (src->buffer_queue.tail != NULL) {
621
625
  BufferQueueItem *i;
622
- for (i = src->buffer_queue.head; i; i = i->next) {
626
+ for (i = src->buffer_queue.head; i; i = (BufferQueueItem*)i->next) {
623
627
  (void) SDL_AtomicDecRef(&i->buffer->refcount);
624
628
  }
625
629
  src->buffer_queue.tail->next = ctx->device->playback.buffer_queue_pool;
@@ -631,7 +635,7 @@ static void source_release_buffer_queue(ALCcontext *ctx, ALsource *src)
631
635
  obtain_newly_queued_buffers(&src->buffer_queue_processed);
632
636
  if (src->buffer_queue_processed.tail != NULL) {
633
637
  BufferQueueItem *i;
634
- for (i = src->buffer_queue_processed.head; i; i = i->next) {
638
+ for (i = src->buffer_queue_processed.head; i; i = (BufferQueueItem*)i->next) {
635
639
  (void) SDL_AtomicDecRef(&i->buffer->refcount);
636
640
  }
637
641
  src->buffer_queue_processed.tail->next = ctx->device->playback.buffer_queue_pool;
@@ -764,7 +768,7 @@ ALCboolean alcCloseDevice(ALCdevice *device)
764
768
 
765
769
  item = device->playback.buffer_queue_pool;
766
770
  while (item) {
767
- BufferQueueItem *next = item->next;
771
+ BufferQueueItem *next = (BufferQueueItem*)item->next;
768
772
  SDL_free(item);
769
773
  item = next;
770
774
  }
@@ -1194,11 +1198,11 @@ static void pitch_fft(float *fftBuffer, int fftFrameSize, int sign)
1194
1198
  for (k = 0, le = 2; k < endval; k++) {
1195
1199
  le <<= 1;
1196
1200
  le2 = le>>1;
1197
- ur = 1.0;
1198
- ui = 0.0;
1199
- arg = M_PI / (le2>>1);
1200
- wr = SDL_cos(arg);
1201
- wi = sign*SDL_sin(arg);
1201
+ ur = 1.0f;
1202
+ ui = 0.0f;
1203
+ arg = (float) (M_PI / (le2>>1));
1204
+ wr = SDL_cosf(arg);
1205
+ wi = sign*SDL_sinf(arg);
1202
1206
  for (j = 0; j < le2; j += 2) {
1203
1207
  p1r = fftBuffer+j; p1i = p1r+1;
1204
1208
  p2r = p1r+le2; p2i = p2r+1;
@@ -1250,8 +1254,8 @@ static void pitch_shift(ALsource *src, const ALbuffer *buffer, int numSampsToPro
1250
1254
  /* do windowing and re,im interleave */
1251
1255
  for (k = 0; k < pitch_framesize;k++) {
1252
1256
  window = -.5*SDL_cos(2.*M_PI*(double)k/(double)pitch_framesize)+.5;
1253
- state->workspace[2*k] = state->infifo[k] * window;
1254
- state->workspace[2*k+1] = 0.;
1257
+ state->workspace[2*k] = (ALfloat) state->infifo[k] * window;
1258
+ state->workspace[2*k+1] = 0.0f;
1255
1259
  }
1256
1260
 
1257
1261
 
@@ -1272,13 +1276,13 @@ static void pitch_shift(ALsource *src, const ALbuffer *buffer, int numSampsToPro
1272
1276
 
1273
1277
  /* compute phase difference */
1274
1278
  tmp = phase - state->lastphase[k];
1275
- state->lastphase[k] = phase;
1279
+ state->lastphase[k] = (ALfloat) phase;
1276
1280
 
1277
1281
  /* subtract expected phase difference */
1278
1282
  tmp -= (double)k*expct;
1279
1283
 
1280
1284
  /* map delta phase into +/- Pi interval */
1281
- qpd = tmp/M_PI;
1285
+ qpd = (int) (tmp/M_PI);
1282
1286
  if (qpd >= 0) qpd += qpd&1;
1283
1287
  else qpd -= qpd&1;
1284
1288
  tmp -= M_PI*(double)qpd;
@@ -1290,8 +1294,8 @@ static void pitch_shift(ALsource *src, const ALbuffer *buffer, int numSampsToPro
1290
1294
  tmp = (double)k*freqPerBin + tmp*freqPerBin;
1291
1295
 
1292
1296
  /* store magnitude and true frequency in analysis arrays */
1293
- state->workspace[2*k] = magn;
1294
- state->workspace[2*k+1] = tmp;
1297
+ state->workspace[2*k] = (ALfloat) magn;
1298
+ state->workspace[2*k+1] = (ALfloat) tmp;
1295
1299
 
1296
1300
  }
1297
1301
 
@@ -1299,7 +1303,7 @@ static void pitch_shift(ALsource *src, const ALbuffer *buffer, int numSampsToPro
1299
1303
  /* this does the actual pitch shifting */
1300
1304
  SDL_memset(state->synmagn, '\0', sizeof (state->synmagn));
1301
1305
  for (k = 0; k <= pitch_framesize2; k++) {
1302
- index = k*pitchShift;
1306
+ index = (int) (k*pitchShift);
1303
1307
  if (index <= pitch_framesize2) {
1304
1308
  state->synmagn[index] += state->workspace[2*k];
1305
1309
  state->synfreq[index] = state->workspace[2*k+1] * pitchShift;
@@ -1327,12 +1331,12 @@ static void pitch_shift(ALsource *src, const ALbuffer *buffer, int numSampsToPro
1327
1331
  tmp += (double)k*expct;
1328
1332
 
1329
1333
  /* accumulate delta phase to get bin phase */
1330
- state->sumphase[k] += tmp;
1334
+ state->sumphase[k] += (ALfloat) tmp;
1331
1335
  phase = state->sumphase[k];
1332
1336
 
1333
1337
  /* get real and imag part and re-interleave */
1334
- state->workspace[2*k] = magn*SDL_cos(phase);
1335
- state->workspace[2*k+1] = magn*SDL_sin(phase);
1338
+ state->workspace[2*k] = (ALfloat) (magn*SDL_cos(phase));
1339
+ state->workspace[2*k+1] = (ALfloat) (magn*SDL_sin(phase));
1336
1340
  }
1337
1341
 
1338
1342
  /* zero negative frequencies */
@@ -1344,7 +1348,7 @@ static void pitch_shift(ALsource *src, const ALbuffer *buffer, int numSampsToPro
1344
1348
  /* do windowing and add to output accumulator */
1345
1349
  for(k=0; k < pitch_framesize; k++) {
1346
1350
  window = -.5*SDL_cos(2.*M_PI*(double)k/(double)pitch_framesize)+.5;
1347
- state->outputaccum[k] += 2.*window*state->workspace[2*k]/(pitch_framesize2*osamp);
1351
+ state->outputaccum[k] += (ALfloat) (2.*window*state->workspace[2*k]/(pitch_framesize2*osamp));
1348
1352
  }
1349
1353
  for (k = 0; k < stepSize; k++) state->outfifo[k] = state->outputaccum[k];
1350
1354
 
@@ -1466,7 +1470,7 @@ static ALCboolean mix_source_buffer_queue(ALCcontext *ctx, ALsource *src, Buffer
1466
1470
  while ((len > 0) && (mix_source_buffer(ctx, src, queue, &stream, &len))) {
1467
1471
  /* Finished this buffer! */
1468
1472
  BufferQueueItem *item = queue;
1469
- BufferQueueItem *next = queue ? queue->next : NULL;
1473
+ BufferQueueItem *next = queue ? (BufferQueueItem*)queue->next : NULL;
1470
1474
  void *ptr;
1471
1475
 
1472
1476
  if (queue) {
@@ -2569,6 +2573,16 @@ static void _alcGetIntegerv(ALCdevice *device, const ALCenum param, const ALCsiz
2569
2573
  *values = OPENAL_VERSION_MINOR;
2570
2574
  return;
2571
2575
 
2576
+ case ALC_FREQUENCY:
2577
+ if (!device) {
2578
+ *values = 0;
2579
+ set_alc_error(device, ALC_INVALID_DEVICE);
2580
+ return;
2581
+ }
2582
+
2583
+ *values = device->frequency;
2584
+ return;
2585
+
2572
2586
  default: break;
2573
2587
  }
2574
2588
 
@@ -2921,7 +2935,7 @@ static const ALchar *_alGetString(const ALenum param)
2921
2935
 
2922
2936
  return NULL;
2923
2937
  }
2924
- ENTRYPOINT(const ALchar *,alGetString,(const ALenum param),(param))
2938
+ ENTRYPOINT(const ALchar *,alGetString,(ALenum param),(param))
2925
2939
 
2926
2940
  static void _alGetBooleanv(const ALenum param, ALboolean *values)
2927
2941
  {
@@ -3589,6 +3603,7 @@ static void _alGenSources(const ALsizei n, ALuint *names)
3589
3603
 
3590
3604
  SDL_zerop(src);
3591
3605
  SDL_AtomicSet(&src->state, AL_INITIAL);
3606
+ SDL_AtomicSet(&src->total_queued_buffers, 0);
3592
3607
  src->name = names[i];
3593
3608
  src->type = AL_UNDETERMINED;
3594
3609
  src->recalc = AL_TRUE;
@@ -3906,7 +3921,7 @@ static void _alGetSourcefv(const ALuint name, const ALenum param, ALfloat *value
3906
3921
  case AL_REFERENCE_DISTANCE: *values = src->reference_distance; break;
3907
3922
  case AL_ROLLOFF_FACTOR: *values = src->rolloff_factor; break;
3908
3923
  case AL_MAX_DISTANCE: *values = src->max_distance; break;
3909
- case AL_PITCH: source_set_pitch(ctx, src, *values); break;
3924
+ case AL_PITCH: *values = src->pitch; break;
3910
3925
  case AL_CONE_INNER_ANGLE: *values = src->cone_inner_angle; break;
3911
3926
  case AL_CONE_OUTER_ANGLE: *values = src->cone_outer_angle; break;
3912
3927
  case AL_CONE_OUTER_GAIN: *values = src->cone_outer_gain; break;
@@ -3973,8 +3988,7 @@ static void _alGetSourceiv(const ALuint name, const ALenum param, ALint *values)
3973
3988
  case AL_SOURCE_STATE: *values = (ALint) SDL_AtomicGet(&src->state); break;
3974
3989
  case AL_SOURCE_TYPE: *values = (ALint) src->type; break;
3975
3990
  case AL_BUFFER: *values = (ALint) (src->buffer ? src->buffer->name : 0); break;
3976
- /* !!! FIXME: AL_BUFFERS_QUEUED is the total number of buffers pending, playing, and processed, so this is wrong. It might also have to be 1 if there's a static buffer, but I'm not sure. */
3977
- case AL_BUFFERS_QUEUED: *values = (ALint) SDL_AtomicGet(&src->buffer_queue.num_items); break;
3991
+ case AL_BUFFERS_QUEUED: *values = (ALint) SDL_AtomicGet(&src->total_queued_buffers); break;
3978
3992
  case AL_BUFFERS_PROCESSED: *values = (ALint) SDL_AtomicGet(&src->buffer_queue_processed.num_items); break;
3979
3993
  case AL_SOURCE_RELATIVE: *values = (ALint) src->source_relative; break;
3980
3994
  case AL_LOOPING: *values = (ALint) src->looping; break;
@@ -4134,7 +4148,7 @@ static void source_play(ALCcontext *ctx, const ALsizei n, const ALuint *names)
4134
4148
  with it, as nothing else owns the pointers in that list. */
4135
4149
  do {
4136
4150
  ptr = SDL_AtomicGetPtr(&ctx->playlist_todo);
4137
- todoend->next = ptr;
4151
+ todoend->next = (SourcePlayTodo*)ptr;
4138
4152
  } while (!SDL_AtomicCASPtr(&ctx->playlist_todo, ptr, todo.next));
4139
4153
  }
4140
4154
 
@@ -4162,6 +4176,9 @@ static void source_stop(ALCcontext *ctx, const ALuint name)
4162
4176
  }
4163
4177
  SDL_AtomicSet(&src->state, AL_STOPPED);
4164
4178
  source_mark_all_buffers_processed(src);
4179
+ if (src->stream) {
4180
+ SDL_AudioStreamClear(src->stream);
4181
+ }
4165
4182
  if (must_lock) {
4166
4183
  SDL_UnlockMutex(ctx->source_lock);
4167
4184
  }
@@ -4228,9 +4245,10 @@ static void source_set_offset(ALsource *src, ALenum param, ALfloat value)
4228
4245
  if (!ctx) {
4229
4246
  set_al_error(ctx, AL_INVALID_OPERATION);
4230
4247
  return;
4231
- }
4232
-
4233
- if (src->type == AL_STREAMING) {
4248
+ } else if (src->type == AL_UNDETERMINED) { /* no buffer to seek in */
4249
+ set_al_error(ctx, AL_INVALID_OPERATION);
4250
+ return;
4251
+ } else if (src->type == AL_STREAMING) {
4234
4252
  FIXME("set_offset for streaming sources not implemented");
4235
4253
  return;
4236
4254
  }
@@ -4242,14 +4260,18 @@ static void source_set_offset(ALsource *src, ALenum param, ALfloat value)
4242
4260
 
4243
4261
  switch (param) {
4244
4262
  case AL_SAMPLE_OFFSET:
4245
- offset = value * framesize;
4263
+ offset = ((int) value) * framesize;
4246
4264
  break;
4247
4265
  case AL_SEC_OFFSET:
4248
- offset = value * freq * framesize;
4266
+ offset = ((int) value) * freq * framesize;
4249
4267
  break;
4250
4268
  case AL_BYTE_OFFSET:
4251
- offset = ((int)value / framesize) * framesize;
4269
+ offset = (((int) value) / framesize) * framesize;
4252
4270
  break;
4271
+ default:
4272
+ SDL_assert(!"Unexpected source offset type!");
4273
+ set_al_error(ctx, AL_INVALID_ENUM); /* this is a MojoAL bug, not an app bug, but we'll try to recover. */
4274
+ return;
4253
4275
  }
4254
4276
 
4255
4277
  if ((offset < 0) || (offset > bufflen)) {
@@ -4267,6 +4289,10 @@ static void source_set_offset(ALsource *src, ALenum param, ALfloat value)
4267
4289
  src->offset = offset;
4268
4290
  SDL_UnlockMutex(ctx->source_lock);
4269
4291
  }
4292
+
4293
+ if (SDL_AtomicGet(&src->state) != AL_PLAYING) {
4294
+ src->offset_latched = SDL_TRUE;
4295
+ }
4270
4296
  }
4271
4297
 
4272
4298
  /* deal with alSourcePlay and alSourcePlayv (etc) boiler plate... */
@@ -4347,7 +4373,7 @@ static void _alSourceQueueBuffers(const ALuint name, const ALsizei nb, const ALu
4347
4373
 
4348
4374
  item = ctx->device->playback.buffer_queue_pool;
4349
4375
  if (item) {
4350
- ctx->device->playback.buffer_queue_pool = item->next;
4376
+ ctx->device->playback.buffer_queue_pool = (BufferQueueItem*)item->next;
4351
4377
  } else { /* allocate a new item */
4352
4378
  item = (BufferQueueItem *) SDL_calloc(1, sizeof (BufferQueueItem));
4353
4379
  if (!item) {
@@ -4400,7 +4426,7 @@ static void _alSourceQueueBuffers(const ALuint name, const ALsizei nb, const ALu
4400
4426
  if (queue) {
4401
4427
  /* Drop our claim on any buffers we planned to queue. */
4402
4428
  BufferQueueItem *item;
4403
- for (item = queue; item != NULL; item = item->next) {
4429
+ for (item = queue; item != NULL; item = (BufferQueueItem*)item->next) {
4404
4430
  if (item->buffer) {
4405
4431
  (void) SDL_AtomicDecRef(&item->buffer->refcount);
4406
4432
  }
@@ -4446,6 +4472,7 @@ static void _alSourceQueueBuffers(const ALuint name, const ALsizei nb, const ALu
4446
4472
  SDL_AtomicSetPtr(&queueend->next, ptr);
4447
4473
  } while (!SDL_AtomicCASPtr(&src->buffer_queue.just_queued, ptr, queue));
4448
4474
 
4475
+ SDL_AtomicAdd(&src->total_queued_buffers, (int) nb);
4449
4476
  SDL_AtomicAdd(&src->buffer_queue.num_items, (int) nb);
4450
4477
  }
4451
4478
  ENTRYPOINTVOID(alSourceQueueBuffers,(ALuint name, ALsizei nb, const ALuint *bufnames),(name,nb,bufnames))
@@ -4477,6 +4504,7 @@ static void _alSourceUnqueueBuffers(const ALuint name, const ALsizei nb, ALuint
4477
4504
  }
4478
4505
 
4479
4506
  SDL_AtomicAdd(&src->buffer_queue_processed.num_items, -((int) nb));
4507
+ SDL_AtomicAdd(&src->total_queued_buffers, -((int) nb));
4480
4508
 
4481
4509
  obtain_newly_queued_buffers(&src->buffer_queue_processed);
4482
4510
 
@@ -4484,7 +4512,7 @@ static void _alSourceUnqueueBuffers(const ALuint name, const ALsizei nb, ALuint
4484
4512
  for (i = 0; i < nb; i++) {
4485
4513
  /* buffer_queue_processed.num_items said list was long enough. */
4486
4514
  SDL_assert(item != NULL);
4487
- item = item->next;
4515
+ item = (BufferQueueItem*)item->next;
4488
4516
  }
4489
4517
  src->buffer_queue_processed.head = item;
4490
4518
  if (!item) {
@@ -4498,7 +4526,7 @@ static void _alSourceUnqueueBuffers(const ALuint name, const ALsizei nb, ALuint
4498
4526
  }
4499
4527
  bufnames[i] = item->buffer ? item->buffer->name : 0;
4500
4528
  queueend = item;
4501
- item = item->next;
4529
+ item = (BufferQueueItem*)item->next;
4502
4530
  }
4503
4531
 
4504
4532
  /* put the whole new queue back in the pool for reuse later. */