Bladeren bron

Update to latest SDL source.

woollybah 10 jaren geleden
bovenliggende
commit
2aed4f41db
100 gewijzigde bestanden met toevoegingen van 738 en 577 verwijderingen
  1. 1 1
      sdl.mod/SDL/include/SDL.h
  2. 22 14
      sdl.mod/SDL/include/SDL_assert.h
  3. 1 1
      sdl.mod/SDL/include/SDL_atomic.h
  4. 1 1
      sdl.mod/SDL/include/SDL_audio.h
  5. 1 1
      sdl.mod/SDL/include/SDL_bits.h
  6. 1 1
      sdl.mod/SDL/include/SDL_blendmode.h
  7. 1 1
      sdl.mod/SDL/include/SDL_clipboard.h
  8. 16 10
      sdl.mod/SDL/include/SDL_config.h.cmake
  9. 3 2
      sdl.mod/SDL/include/SDL_config.h.in
  10. 2 4
      sdl.mod/SDL/include/SDL_config_android.h
  11. 4 1
      sdl.mod/SDL/include/SDL_config_iphoneos.h
  12. 2 1
      sdl.mod/SDL/include/SDL_config_macosx.h
  13. 1 1
      sdl.mod/SDL/include/SDL_config_minimal.h
  14. 1 1
      sdl.mod/SDL/include/SDL_config_pandora.h
  15. 1 1
      sdl.mod/SDL/include/SDL_config_psp.h
  16. 1 1
      sdl.mod/SDL/include/SDL_config_windows.h
  17. 1 1
      sdl.mod/SDL/include/SDL_config_winrt.h
  18. 1 1
      sdl.mod/SDL/include/SDL_config_wiz.h
  19. 1 1
      sdl.mod/SDL/include/SDL_copying.h
  20. 1 1
      sdl.mod/SDL/include/SDL_cpuinfo.h
  21. 1 1
      sdl.mod/SDL/include/SDL_egl.h
  22. 3 3
      sdl.mod/SDL/include/SDL_endian.h
  23. 1 1
      sdl.mod/SDL/include/SDL_error.h
  24. 25 6
      sdl.mod/SDL/include/SDL_events.h
  25. 1 1
      sdl.mod/SDL/include/SDL_filesystem.h
  26. 6 4
      sdl.mod/SDL/include/SDL_gamecontroller.h
  27. 1 1
      sdl.mod/SDL/include/SDL_gesture.h
  28. 3 8
      sdl.mod/SDL/include/SDL_haptic.h
  29. 60 4
      sdl.mod/SDL/include/SDL_hints.h
  30. 5 4
      sdl.mod/SDL/include/SDL_joystick.h
  31. 1 1
      sdl.mod/SDL/include/SDL_keyboard.h
  32. 1 1
      sdl.mod/SDL/include/SDL_keycode.h
  33. 1 1
      sdl.mod/SDL/include/SDL_loadso.h
  34. 1 1
      sdl.mod/SDL/include/SDL_log.h
  35. 2 2
      sdl.mod/SDL/include/SDL_main.h
  36. 1 1
      sdl.mod/SDL/include/SDL_messagebox.h
  37. 3 2
      sdl.mod/SDL/include/SDL_mouse.h
  38. 1 1
      sdl.mod/SDL/include/SDL_mutex.h
  39. 1 1
      sdl.mod/SDL/include/SDL_name.h
  40. 1 1
      sdl.mod/SDL/include/SDL_opengl.h
  41. 5 0
      sdl.mod/SDL/include/SDL_opengl_glext.h
  42. 1 1
      sdl.mod/SDL/include/SDL_opengles.h
  43. 1 1
      sdl.mod/SDL/include/SDL_opengles2.h
  44. 24 3
      sdl.mod/SDL/include/SDL_pixels.h
  45. 1 1
      sdl.mod/SDL/include/SDL_platform.h
  46. 1 1
      sdl.mod/SDL/include/SDL_power.h
  47. 1 1
      sdl.mod/SDL/include/SDL_quit.h
  48. 1 1
      sdl.mod/SDL/include/SDL_rect.h
  49. 4 4
      sdl.mod/SDL/include/SDL_render.h
  50. 1 1
      sdl.mod/SDL/include/SDL_rwops.h
  51. 1 1
      sdl.mod/SDL/include/SDL_scancode.h
  52. 1 1
      sdl.mod/SDL/include/SDL_shape.h
  53. 10 2
      sdl.mod/SDL/include/SDL_stdinc.h
  54. 1 1
      sdl.mod/SDL/include/SDL_surface.h
  55. 10 1
      sdl.mod/SDL/include/SDL_system.h
  56. 7 1
      sdl.mod/SDL/include/SDL_syswm.h
  57. 2 2
      sdl.mod/SDL/include/SDL_test.h
  58. 1 1
      sdl.mod/SDL/include/SDL_test_assert.h
  59. 1 1
      sdl.mod/SDL/include/SDL_test_common.h
  60. 1 1
      sdl.mod/SDL/include/SDL_test_compare.h
  61. 1 1
      sdl.mod/SDL/include/SDL_test_crc32.h
  62. 1 1
      sdl.mod/SDL/include/SDL_test_font.h
  63. 1 1
      sdl.mod/SDL/include/SDL_test_fuzzer.h
  64. 1 1
      sdl.mod/SDL/include/SDL_test_harness.h
  65. 1 1
      sdl.mod/SDL/include/SDL_test_images.h
  66. 1 1
      sdl.mod/SDL/include/SDL_test_log.h
  67. 1 1
      sdl.mod/SDL/include/SDL_test_md5.h
  68. 1 1
      sdl.mod/SDL/include/SDL_test_random.h
  69. 1 1
      sdl.mod/SDL/include/SDL_thread.h
  70. 1 1
      sdl.mod/SDL/include/SDL_timer.h
  71. 1 1
      sdl.mod/SDL/include/SDL_touch.h
  72. 1 1
      sdl.mod/SDL/include/SDL_types.h
  73. 1 1
      sdl.mod/SDL/include/SDL_version.h
  74. 33 2
      sdl.mod/SDL/include/SDL_video.h
  75. 1 3
      sdl.mod/SDL/include/begin_code.h
  76. 1 1
      sdl.mod/SDL/include/close_code.h
  77. 3 1
      sdl.mod/SDL/src/SDL.c
  78. 1 1
      sdl.mod/SDL/src/SDL_assert.c
  79. 1 1
      sdl.mod/SDL/src/SDL_assert_c.h
  80. 29 11
      sdl.mod/SDL/src/SDL_error.c
  81. 1 1
      sdl.mod/SDL/src/SDL_error_c.h
  82. 1 1
      sdl.mod/SDL/src/SDL_hints.c
  83. 1 1
      sdl.mod/SDL/src/SDL_internal.h
  84. 4 4
      sdl.mod/SDL/src/SDL_log.c
  85. 1 1
      sdl.mod/SDL/src/atomic/SDL_atomic.c
  86. 1 1
      sdl.mod/SDL/src/atomic/SDL_spinlock.c
  87. 308 379
      sdl.mod/SDL/src/audio/SDL_audio.c
  88. 1 1
      sdl.mod/SDL/src/audio/SDL_audio_c.h
  89. 1 1
      sdl.mod/SDL/src/audio/SDL_audiocvt.c
  90. 23 13
      sdl.mod/SDL/src/audio/SDL_audiodev.c
  91. 2 3
      sdl.mod/SDL/src/audio/SDL_audiodev_c.h
  92. 1 1
      sdl.mod/SDL/src/audio/SDL_audiomem.h
  93. 1 1
      sdl.mod/SDL/src/audio/SDL_audiotypecvt.c
  94. 1 1
      sdl.mod/SDL/src/audio/SDL_mixer.c
  95. 44 10
      sdl.mod/SDL/src/audio/SDL_sysaudio.h
  96. 1 1
      sdl.mod/SDL/src/audio/SDL_wave.c
  97. 1 1
      sdl.mod/SDL/src/audio/SDL_wave.h
  98. 3 3
      sdl.mod/SDL/src/audio/alsa/SDL_alsa_audio.c
  99. 1 1
      sdl.mod/SDL/src/audio/alsa/SDL_alsa_audio.h
  100. 2 2
      sdl.mod/SDL/src/audio/android/SDL_androidaudio.c

+ 1 - 1
sdl.mod/SDL/include/SDL.h

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages

+ 22 - 14
sdl.mod/SDL/include/SDL_assert.h

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages
@@ -86,8 +86,10 @@ This also solves the problem of...
 disable assertions.
 */
 
+/* "while (0,0)" fools Microsoft's compiler's /W4 warning level into thinking
+    this condition isn't constant. And looks like an owl's face! */
 #ifdef _MSC_VER  /* stupid /W4 warnings. */
-#define SDL_NULL_WHILE_LOOP_CONDITION (-1 == __LINE__)
+#define SDL_NULL_WHILE_LOOP_CONDITION (0,0)
 #else
 #define SDL_NULL_WHILE_LOOP_CONDITION (0)
 #endif
@@ -102,9 +104,9 @@ typedef enum
     SDL_ASSERTION_ABORT,  /**< Terminate the program. */
     SDL_ASSERTION_IGNORE,  /**< Ignore the assert. */
     SDL_ASSERTION_ALWAYS_IGNORE  /**< Ignore the assert from now on. */
-} SDL_assert_state;
+} SDL_AssertState;
 
-typedef struct SDL_assert_data
+typedef struct SDL_AssertData
 {
     int always_ignore;
     unsigned int trigger_count;
@@ -112,13 +114,13 @@ typedef struct SDL_assert_data
     const char *filename;
     int linenum;
     const char *function;
-    const struct SDL_assert_data *next;
-} SDL_assert_data;
+    const struct SDL_AssertData *next;
+} SDL_AssertData;
 
 #if (SDL_ASSERT_LEVEL > 0)
 
 /* Never call this directly. Use the SDL_assert* macros. */
-extern DECLSPEC SDL_assert_state SDLCALL SDL_ReportAssertion(SDL_assert_data *,
+extern DECLSPEC SDL_AssertState SDLCALL SDL_ReportAssertion(SDL_AssertData *,
                                                              const char *,
                                                              const char *, int)
 #if defined(__clang__)
@@ -141,10 +143,10 @@ extern DECLSPEC SDL_assert_state SDLCALL SDL_ReportAssertion(SDL_assert_data *,
 #define SDL_enabled_assert(condition) \
     do { \
         while ( !(condition) ) { \
-            static struct SDL_assert_data sdl_assert_data = { \
+            static struct SDL_AssertData sdl_assert_data = { \
                 0, 0, #condition, 0, 0, 0, 0 \
             }; \
-            const SDL_assert_state sdl_assert_state = SDL_ReportAssertion(&sdl_assert_data, SDL_FUNCTION, SDL_FILE, SDL_LINE); \
+            const SDL_AssertState sdl_assert_state = SDL_ReportAssertion(&sdl_assert_data, SDL_FUNCTION, SDL_FILE, SDL_LINE); \
             if (sdl_assert_state == SDL_ASSERTION_RETRY) { \
                 continue; /* go again. */ \
             } else if (sdl_assert_state == SDL_ASSERTION_BREAK) { \
@@ -181,8 +183,8 @@ extern DECLSPEC SDL_assert_state SDLCALL SDL_ReportAssertion(SDL_assert_data *,
 #define SDL_assert_always(condition) SDL_enabled_assert(condition)
 
 
-typedef SDL_assert_state (SDLCALL *SDL_AssertionHandler)(
-                                 const SDL_assert_data* data, void* userdata);
+typedef SDL_AssertState (SDLCALL *SDL_AssertionHandler)(
+                                 const SDL_AssertData* data, void* userdata);
 
 /**
  *  \brief Set an application-defined assertion handler.
@@ -199,7 +201,7 @@ typedef SDL_assert_state (SDLCALL *SDL_AssertionHandler)(
  *
  *  This callback is NOT reset to SDL's internal handler upon SDL_Quit()!
  *
- *  \return SDL_assert_state value of how to handle the assertion failure.
+ *  \return SDL_AssertState value of how to handle the assertion failure.
  *
  *  \param handler Callback function, called when an assertion fails.
  *  \param userdata A pointer passed to the callback as-is.
@@ -246,7 +248,7 @@ extern DECLSPEC SDL_AssertionHandler SDLCALL SDL_GetAssertionHandler(void **puse
  *  The proper way to examine this data looks something like this:
  *
  *  <code>
- *  const SDL_assert_data *item = SDL_GetAssertionReport();
+ *  const SDL_AssertData *item = SDL_GetAssertionReport();
  *  while (item) {
  *      printf("'%s', %s (%s:%d), triggered %u times, always ignore: %s.\n",
  *             item->condition, item->function, item->filename,
@@ -259,7 +261,7 @@ extern DECLSPEC SDL_AssertionHandler SDLCALL SDL_GetAssertionHandler(void **puse
  *  \return List of all assertions.
  *  \sa SDL_ResetAssertionReport
  */
-extern DECLSPEC const SDL_assert_data * SDLCALL SDL_GetAssertionReport(void);
+extern DECLSPEC const SDL_AssertData * SDLCALL SDL_GetAssertionReport(void);
 
 /**
  *  \brief Reset the list of all assertion failures.
@@ -270,6 +272,12 @@ extern DECLSPEC const SDL_assert_data * SDLCALL SDL_GetAssertionReport(void);
  */
 extern DECLSPEC void SDLCALL SDL_ResetAssertionReport(void);
 
+
+/* these had wrong naming conventions until 2.0.4. Please update your app! */
+#define SDL_assert_state SDL_AssertState
+#define SDL_assert_data SDL_AssertData
+
+
 /* Ends C function definitions when using C++ */
 #ifdef __cplusplus
 }

+ 1 - 1
sdl.mod/SDL/include/SDL_atomic.h

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages

+ 1 - 1
sdl.mod/SDL/include/SDL_audio.h

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages

+ 1 - 1
sdl.mod/SDL/include/SDL_bits.h

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages

+ 1 - 1
sdl.mod/SDL/include/SDL_blendmode.h

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages

+ 1 - 1
sdl.mod/SDL/include/SDL_clipboard.h

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages

+ 16 - 10
sdl.mod/SDL/include/SDL_config.h.cmake

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages
@@ -47,6 +47,13 @@
 #cmakedefine HAVE_GCC_ATOMICS @HAVE_GCC_ATOMICS@
 #cmakedefine HAVE_GCC_SYNC_LOCK_TEST_AND_SET @HAVE_GCC_SYNC_LOCK_TEST_AND_SET@
 
+#cmakedefine HAVE_D3D_H @HAVE_D3D_H@
+#cmakedefine HAVE_D3D11_H @HAVE_D3D11_H@
+#cmakedefine HAVE_DDRAW_H @HAVE_DDRAW_H@
+#cmakedefine HAVE_DSOUND_H @HAVE_DSOUND_H@
+#cmakedefine HAVE_DINPUT_H @HAVE_DINPUT_H@
+#cmakedefine HAVE_XAUDIO2_H @HAVE_XAUDIO2_H@
+#cmakedefine HAVE_XINPUT_H @HAVE_XINPUT_H@
 #cmakedefine HAVE_DXGI_H @HAVE_DXGI_H@
 
 /* Comment this if you want to build without any C library requirements */
@@ -225,6 +232,7 @@
 #cmakedefine SDL_INPUT_TSLIB @SDL_INPUT_TSLIB@
 #cmakedefine SDL_JOYSTICK_HAIKU @SDL_JOYSTICK_HAIKU@
 #cmakedefine SDL_JOYSTICK_DINPUT @SDL_JOYSTICK_DINPUT@
+#cmakedefine SDL_JOYSTICK_XINPUT @SDL_JOYSTICK_XINPUT@
 #cmakedefine SDL_JOYSTICK_DUMMY @SDL_JOYSTICK_DUMMY@
 #cmakedefine SDL_JOYSTICK_IOKIT @SDL_JOYSTICK_IOKIT@
 #cmakedefine SDL_JOYSTICK_LINUX @SDL_JOYSTICK_LINUX@
@@ -236,6 +244,7 @@
 #cmakedefine SDL_HAPTIC_LINUX @SDL_HAPTIC_LINUX@
 #cmakedefine SDL_HAPTIC_IOKIT @SDL_HAPTIC_IOKIT@
 #cmakedefine SDL_HAPTIC_DINPUT @SDL_HAPTIC_DINPUT@
+#cmakedefine SDL_HAPTIC_XINPUT @SDL_HAPTIC_XINPUT@
 
 /* Enable various shared object loading systems */
 #cmakedefine SDL_LOADSO_HAIKU @SDL_LOADSO_HAIKU@
@@ -269,14 +278,11 @@
 #cmakedefine SDL_VIDEO_DRIVER_VIVANTE @SDL_VIDEO_DRIVER_VIVANTE@
 #cmakedefine SDL_VIDEO_DRIVER_VIVANTE_VDK @SDL_VIDEO_DRIVER_VIVANTE_VDK@
 
-#if 0
-/* !!! FIXME: in configure script version, missing here: */
-#undef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH
-#undef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC
-#undef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_EGL
-#undef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_CURSOR
-#undef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_XKBCOMMON
-#endif
+#cmakedefine SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH @SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH@
+#cmakedefine SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC @SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC@
+#cmakedefine SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_EGL @SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_EGL@
+#cmakedefine SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_CURSOR @SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_CURSOR@
+#cmakedefine SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_XKBCOMMON @SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_XKBCOMMON@
 
 #cmakedefine SDL_VIDEO_DRIVER_MIR @SDL_VIDEO_DRIVER_MIR@
 #cmakedefine SDL_VIDEO_DRIVER_MIR_DYNAMIC @SDL_VIDEO_DRIVER_MIR_DYNAMIC@
@@ -292,6 +298,7 @@
 #cmakedefine SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS @SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS@
 #cmakedefine SDL_VIDEO_DRIVER_X11_DYNAMIC_XVIDMODE @SDL_VIDEO_DRIVER_X11_DYNAMIC_XVIDMODE@
 #cmakedefine SDL_VIDEO_DRIVER_X11_XCURSOR @SDL_VIDEO_DRIVER_X11_XCURSOR@
+#cmakedefine SDL_VIDEO_DRIVER_X11_XDBE @SDL_VIDEO_DRIVER_X11_XDBE@
 #cmakedefine SDL_VIDEO_DRIVER_X11_XINERAMA @SDL_VIDEO_DRIVER_X11_XINERAMA@
 #cmakedefine SDL_VIDEO_DRIVER_X11_XINPUT2 @SDL_VIDEO_DRIVER_X11_XINPUT2@
 #cmakedefine SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH @SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH@
@@ -300,7 +307,6 @@
 #cmakedefine SDL_VIDEO_DRIVER_X11_XSHAPE @SDL_VIDEO_DRIVER_X11_XSHAPE@
 #cmakedefine SDL_VIDEO_DRIVER_X11_XVIDMODE @SDL_VIDEO_DRIVER_X11_XVIDMODE@
 #cmakedefine SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS @SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS@
-#cmakedefine SDL_VIDEO_DRIVER_X11_CONST_PARAM_XDATA32 @SDL_VIDEO_DRIVER_X11_CONST_PARAM_XDATA32@
 #cmakedefine SDL_VIDEO_DRIVER_X11_CONST_PARAM_XEXTADDDISPLAY @SDL_VIDEO_DRIVER_X11_CONST_PARAM_XEXTADDDISPLAY@
 #cmakedefine SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM @SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM@
 

+ 3 - 2
sdl.mod/SDL/include/SDL_config.h.in

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages
@@ -299,6 +299,7 @@
 #undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS
 #undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XVIDMODE
 #undef SDL_VIDEO_DRIVER_X11_XCURSOR
+#undef SDL_VIDEO_DRIVER_X11_XDBE
 #undef SDL_VIDEO_DRIVER_X11_XINERAMA
 #undef SDL_VIDEO_DRIVER_X11_XINPUT2
 #undef SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH
@@ -307,7 +308,6 @@
 #undef SDL_VIDEO_DRIVER_X11_XSHAPE
 #undef SDL_VIDEO_DRIVER_X11_XVIDMODE
 #undef SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS
-#undef SDL_VIDEO_DRIVER_X11_CONST_PARAM_XDATA32
 #undef SDL_VIDEO_DRIVER_X11_CONST_PARAM_XEXTADDDISPLAY
 #undef SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM
 #undef SDL_VIDEO_DRIVER_NACL
@@ -349,6 +349,7 @@
 #undef SDL_FILESYSTEM_UNIX
 #undef SDL_FILESYSTEM_WINDOWS
 #undef SDL_FILESYSTEM_NACL
+#undef SDL_FILESYSTEM_ANDROID
 #undef SDL_FILESYSTEM_EMSCRIPTEN
 
 /* Enable assembly routines */

+ 2 - 4
sdl.mod/SDL/include/SDL_config_android.h

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages
@@ -43,7 +43,6 @@
 #define HAVE_STDINT_H   1
 #define HAVE_CTYPE_H    1
 #define HAVE_MATH_H 1
-#define HAVE_SIGNAL_H   1
 
 /* C library functions */
 #define HAVE_MALLOC 1
@@ -76,7 +75,6 @@
 #define HAVE_STRTOULL   1
 #define HAVE_STRTOD 1
 #define HAVE_ATOI   1
-#define HAVE_ATOF   1
 #define HAVE_STRCMP 1
 #define HAVE_STRNCMP    1
 #define HAVE_STRCASECMP 1
@@ -103,10 +101,10 @@
 #define HAVE_SQRTF  1
 #define HAVE_TAN    1
 #define HAVE_TANF   1
-#define HAVE_SIGACTION  1
 #define HAVE_SETJMP 1
 #define HAVE_NANOSLEEP  1
 #define HAVE_SYSCONF    1
+#define HAVE_CLOCK_GETTIME	1
 
 #define SIZEOF_VOIDP 4
 

+ 4 - 1
sdl.mod/SDL/include/SDL_config_iphoneos.h

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages
@@ -145,6 +145,9 @@
 /* enable iPhone keyboard support */
 #define SDL_IPHONE_KEYBOARD 1
 
+/* enable iOS extended launch screen */
+#define SDL_IPHONE_LAUNCHSCREEN 1
+
 /* enable joystick subsystem */
 #define SDL_JOYSTICK_DISABLED 0
 

+ 2 - 1
sdl.mod/SDL/include/SDL_config_macosx.h

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages
@@ -139,6 +139,7 @@
 #define SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR "/usr/X11R6/lib/libXrandr.2.dylib"
 #define SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS "/usr/X11R6/lib/libXss.1.dylib"
 #define SDL_VIDEO_DRIVER_X11_DYNAMIC_XVIDMODE "/usr/X11R6/lib/libXxf86vm.1.dylib"
+#define SDL_VIDEO_DRIVER_X11_XDBE 1
 #define SDL_VIDEO_DRIVER_X11_XINERAMA 1
 #define SDL_VIDEO_DRIVER_X11_XRANDR 1
 #define SDL_VIDEO_DRIVER_X11_XSCRNSAVER 1

+ 1 - 1
sdl.mod/SDL/include/SDL_config_minimal.h

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages

+ 1 - 1
sdl.mod/SDL/include/SDL_config_pandora.h

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages

+ 1 - 1
sdl.mod/SDL/include/SDL_config_psp.h

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages

+ 1 - 1
sdl.mod/SDL/include/SDL_config_windows.h

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages

+ 1 - 1
sdl.mod/SDL/include/SDL_config_winrt.h

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages

+ 1 - 1
sdl.mod/SDL/include/SDL_config_wiz.h

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages

+ 1 - 1
sdl.mod/SDL/include/SDL_copying.h

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages

+ 1 - 1
sdl.mod/SDL/include/SDL_cpuinfo.h

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages

+ 1 - 1
sdl.mod/SDL/include/SDL_egl.h

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages

+ 3 - 3
sdl.mod/SDL/include/SDL_endian.h

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages
@@ -42,7 +42,7 @@
 #ifdef __linux__
 #include <endian.h>
 #define SDL_BYTEORDER  __BYTE_ORDER
-#else /* __linux __ */
+#else /* __linux__ */
 #if defined(__hppa__) || \
     defined(__m68k__) || defined(mc68000) || defined(_M_M68K) || \
     (defined(__MIPS__) && defined(__MISPEB__)) || \
@@ -52,7 +52,7 @@
 #else
 #define SDL_BYTEORDER   SDL_LIL_ENDIAN
 #endif
-#endif /* __linux __ */
+#endif /* __linux__ */
 #endif /* !SDL_BYTEORDER */
 
 

+ 1 - 1
sdl.mod/SDL/include/SDL_error.h

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages

+ 25 - 6
sdl.mod/SDL/include/SDL_events.h

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages
@@ -134,6 +134,10 @@ typedef enum
     /* Drag and drop events */
     SDL_DROPFILE        = 0x1000, /**< The system requests a file open */
 
+    /* Audio hotplug events */
+    SDL_AUDIODEVICEADDED = 0x1100, /**< A new audio device is available */
+    SDL_AUDIODEVICEREMOVED,        /**< An audio device has been removed. */
+
     /* Render events */
     SDL_RENDER_TARGETS_RESET = 0x2000, /**< The render targets have been reset and their contents need to be updated */
     SDL_RENDER_DEVICE_RESET, /**< The device has been reset and all textures need to be recreated */
@@ -382,6 +386,20 @@ typedef struct SDL_ControllerDeviceEvent
     Sint32 which;       /**< The joystick device index for the ADDED event, instance id for the REMOVED or REMAPPED event */
 } SDL_ControllerDeviceEvent;
 
+/**
+ *  \brief Audio device event structure (event.adevice.*)
+ */
+typedef struct SDL_AudioDeviceEvent
+{
+    Uint32 type;        /**< ::SDL_AUDIODEVICEADDED, or ::SDL_AUDIODEVICEREMOVED */
+    Uint32 timestamp;
+    Uint32 which;       /**< The audio device index for the ADDED event (valid until next SDL_GetNumAudioDevices() call), SDL_AudioDeviceID for the REMOVED event */
+    Uint8 iscapture;    /**< zero if an output device, non-zero if a capture device. */
+    Uint8 padding1;
+    Uint8 padding2;
+    Uint8 padding3;
+} SDL_AudioDeviceEvent;
+
 
 /**
  *  \brief Touch finger event structure (event.tfinger.*)
@@ -394,8 +412,8 @@ typedef struct SDL_TouchFingerEvent
     SDL_FingerID fingerId;
     float x;            /**< Normalized in the range 0...1 */
     float y;            /**< Normalized in the range 0...1 */
-    float dx;           /**< Normalized in the range 0...1 */
-    float dy;           /**< Normalized in the range 0...1 */
+    float dx;           /**< Normalized in the range -1...1 */
+    float dy;           /**< Normalized in the range -1...1 */
     float pressure;     /**< Normalized in the range 0...1 */
 } SDL_TouchFingerEvent;
 
@@ -422,7 +440,7 @@ typedef struct SDL_MultiGestureEvent
  */
 typedef struct SDL_DollarGestureEvent
 {
-    Uint32 type;        /**< ::SDL_DOLLARGESTURE */
+    Uint32 type;        /**< ::SDL_DOLLARGESTURE or ::SDL_DOLLARRECORD */
     Uint32 timestamp;
     SDL_TouchID touchId; /**< The touch device id */
     SDL_GestureID gestureId;
@@ -435,8 +453,8 @@ typedef struct SDL_DollarGestureEvent
 
 /**
  *  \brief An event used to request a file open by the system (event.drop.*)
- *         This event is disabled by default, you can enable it with SDL_EventState()
- *  \note If you enable this event, you must free the filename in the event.
+ *         This event is enabled by default, you can disable it with SDL_EventState().
+ *  \note If this event is enabled, you must free the filename in the event.
  */
 typedef struct SDL_DropEvent
 {
@@ -516,6 +534,7 @@ typedef union SDL_Event
     SDL_ControllerAxisEvent caxis;      /**< Game Controller axis event data */
     SDL_ControllerButtonEvent cbutton;  /**< Game Controller button event data */
     SDL_ControllerDeviceEvent cdevice;  /**< Game Controller device event data */
+    SDL_AudioDeviceEvent adevice;   /**< Audio device event data */
     SDL_QuitEvent quit;             /**< Quit request event data */
     SDL_UserEvent user;             /**< Custom event data */
     SDL_SysWMEvent syswm;           /**< System dependent window event data */

+ 1 - 1
sdl.mod/SDL/include/SDL_filesystem.h

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages

+ 6 - 4
sdl.mod/SDL/include/SDL_gamecontroller.h

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages
@@ -163,8 +163,9 @@ extern DECLSPEC const char *SDLCALL SDL_GameControllerNameForIndex(int joystick_
 /**
  *  Open a game controller for use.
  *  The index passed as an argument refers to the N'th game controller on the system.
- *  This index is the value which will identify this controller in future controller
- *  events.
+ *  This index is not the value which will identify this controller in future
+ *  controller events.  The joystick's instance id (::SDL_JoystickID) will be
+ *  used there instead.
  *
  *  \return A controller identifier, or NULL if an error occurred.
  */
@@ -241,7 +242,8 @@ SDL_GameControllerGetBindForAxis(SDL_GameController *gamecontroller,
 /**
  *  Get the current state of an axis control on a game controller.
  *
- *  The state is a value ranging from -32768 to 32767.
+ *  The state is a value ranging from -32768 to 32767 (except for the triggers,
+ *  which range from 0 to 32767).
  *
  *  The axis indices start at index 0.
  */

+ 1 - 1
sdl.mod/SDL/include/SDL_gesture.h

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages

+ 3 - 8
sdl.mod/SDL/include/SDL_haptic.h

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages
@@ -102,11 +102,6 @@
  *    return 0; // Success
  * }
  * \endcode
- *
- * You can also find out more information on my blog:
- * http://bobbens.dyndns.org/journal/2010/sdl_haptic/
- *
- * \author Edgar Simo Serra
  */
 
 #ifndef _SDL_haptic_h
@@ -900,7 +895,7 @@ extern DECLSPEC int SDLCALL SDL_JoystickIsHaptic(SDL_Joystick * joystick);
 /**
  *  \brief Opens a Haptic device for usage from a Joystick device.
  *
- *  You must still close the haptic device seperately.  It will not be closed
+ *  You must still close the haptic device separately.  It will not be closed
  *  with the joystick.
  *
  *  When opening from a joystick you should first close the haptic device before
@@ -957,7 +952,7 @@ extern DECLSPEC int SDLCALL SDL_HapticNumEffects(SDL_Haptic * haptic);
 extern DECLSPEC int SDLCALL SDL_HapticNumEffectsPlaying(SDL_Haptic * haptic);
 
 /**
- *  \brief Gets the haptic devices supported features in bitwise matter.
+ *  \brief Gets the haptic device's supported features in bitwise manner.
  *
  *  Example:
  *  \code

+ 60 - 4
sdl.mod/SDL/include/SDL_hints.h

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages
@@ -243,6 +243,9 @@ extern "C" {
  *  this is problematic. This functionality can be disabled by setting this
  *  hint.
  *
+ *  As of SDL 2.0.4, SDL_EnableScreenSaver and SDL_DisableScreenSaver accomplish
+ *  the same thing on iOS. They should be preferred over this hint.
+ *
  *  This variable can be set to the following values:
  *    "0"       - Enable idle timer
  *    "1"       - Disable idle timer
@@ -261,8 +264,9 @@ extern "C" {
 #define SDL_HINT_ORIENTATIONS "SDL_IOS_ORIENTATIONS"
     
 /**
- *  \brief  A variable controlling whether an Android built-in accelerometer should be
- *  listed as a joystick device, rather than listing actual joysticks only.
+ *  \brief  A variable controlling whether the Android / iOS built-in
+ *  accelerometer should be listed as a joystick device, rather than listing
+ *  actual joysticks only.
  *
  *  This variable can be set to the following values:
  *    "0"       - List only real joysticks and accept input from them
@@ -344,8 +348,19 @@ extern "C" {
 #define SDL_HINT_TIMER_RESOLUTION "SDL_TIMER_RESOLUTION"
 
 
+
 /**
- *  \brief If set to 1, then do not allow high-DPI windows. ("Retina" on Mac)
+*  \brief  A string specifying SDL's threads stack size in bytes or "0" for the backend's default size
+*
+*  Use this hint in case you need to set SDL's threads stack size to other than the default.
+*  This is specially useful if you build SDL against a non glibc libc library (such as musl) which
+*  provides a relatively small default thread stack size (a few kilobytes versus the default 8MB glibc uses).
+*  Support for this hint is currently available only in the pthread backend.
+*/
+#define SDL_HINT_THREAD_STACK_SIZE              "SDL_THREAD_STACK_SIZE"
+
+/**
+ *  \brief If set to 1, then do not allow high-DPI windows. ("Retina" on Mac and iOS)
  */
 #define SDL_HINT_VIDEO_HIGHDPI_DISABLED "SDL_VIDEO_HIGHDPI_DISABLED"
 
@@ -510,6 +525,14 @@ extern "C" {
  */
 #define SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES    "SDL_VIDEO_MAC_FULLSCREEN_SPACES"
 
+/**
+*  \brief  When set don't force the SDL app to become a foreground process
+*
+*  This hint only applies to Mac OS X.
+*
+*/
+#define SDL_HINT_MAC_BACKGROUND_APP    "SDL_MAC_BACKGROUND_APP"
+    
 /**
  * \brief Android APK expansion main file version. Should be a string number like "1", "2" etc.
  */
@@ -532,6 +555,18 @@ extern "C" {
  */
 #define SDL_HINT_IME_INTERNAL_EDITING "SDL_IME_INTERNAL_EDITING"
 
+ /**
+ * \brief A variable to control whether mouse and touch events are to be treated together or separately
+ *
+ * The variable can be set to the following values:
+ *   "0"       - Mouse events will be handled as touch events, and touch will raise fake mouse
+ *               events. This is the behaviour of SDL <= 2.0.3. (default)
+ *   "1"       - Mouse events will be handled separately from pure touch events.
+ *
+ * The value of this hint is used at runtime, so it can be changed at any time.
+ */
+#define SDL_HINT_ANDROID_SEPARATE_MOUSE_AND_TOUCH "SDL_ANDROID_SEPARATE_MOUSE_AND_TOUCH"
+
 /**
  *  \brief override the binding element for keyboard inputs for Emscripten builds
  *
@@ -546,6 +581,27 @@ extern "C" {
  */
 #define SDL_HINT_EMSCRIPTEN_KEYBOARD_ELEMENT   "SDL_EMSCRIPTEN_KEYBOARD_ELEMENT"
 
+/**
+ *  \brief Tell SDL not to catch the SIGINT or SIGTERM signals.
+ *
+ * This hint only applies to Unix-like platforms.
+ *
+ * The variable can be set to the following values:
+ *   "0"       - SDL will install a SIGINT and SIGTERM handler, and when it
+ *               catches a signal, convert it into an SDL_QUIT event.
+ *   "1"       - SDL will not install a signal handler at all.
+ */
+#define SDL_HINT_NO_SIGNAL_HANDLERS   "SDL_NO_SIGNAL_HANDLERS"
+
+/**
+ *  \brief Tell SDL not to generate window-close events for Alt+F4 on Windows.
+ *
+ * The variable can be set to the following values:
+ *   "0"       - SDL will generate a window-close event when it sees Alt+F4.
+ *   "1"       - SDL will only do normal key handling for Alt+F4.
+ */
+#define SDL_HINT_WINDOWS_NO_CLOSE_ON_ALT_F4	"SDL_WINDOWS_NO_CLOSE_ON_ALT_F4"
+
 /**
  *  \brief  An enumeration of hint priorities
  */

+ 5 - 4
sdl.mod/SDL/include/SDL_joystick.h

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages
@@ -88,8 +88,9 @@ extern DECLSPEC const char *SDLCALL SDL_JoystickNameForIndex(int device_index);
 /**
  *  Open a joystick for use.
  *  The index passed as an argument refers to the N'th joystick on the system.
- *  This index is the value which will identify this joystick in future joystick
- *  events.
+ *  This index is not the value which will identify this joystick in future
+ *  joystick events.  The joystick's instance id (::SDL_JoystickID) will be used
+ *  there instead.
  *
  *  \return A joystick identifier, or NULL if an error occurred.
  */
@@ -189,7 +190,7 @@ extern DECLSPEC Sint16 SDLCALL SDL_JoystickGetAxis(SDL_Joystick * joystick,
  */
 /* @{ */
 #define SDL_HAT_CENTERED    0x00
-#define SDL_HAT_UP      0x01
+#define SDL_HAT_UP          0x01
 #define SDL_HAT_RIGHT       0x02
 #define SDL_HAT_DOWN        0x04
 #define SDL_HAT_LEFT        0x08

+ 1 - 1
sdl.mod/SDL/include/SDL_keyboard.h

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages

+ 1 - 1
sdl.mod/SDL/include/SDL_keycode.h

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages

+ 1 - 1
sdl.mod/SDL/include/SDL_loadso.h

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages

+ 1 - 1
sdl.mod/SDL/include/SDL_log.h

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages

+ 2 - 2
sdl.mod/SDL/include/SDL_main.h

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages
@@ -143,7 +143,7 @@ extern DECLSPEC void SDLCALL SDL_UnregisterApp(void);
  *
  *  \param mainFunction The SDL app's C-style main().
  *  \param reserved Reserved for future use; should be NULL
- *  \ret 0 on success, -1 on failure.  On failure, use SDL_GetError to retrieve more
+ *  \return 0 on success, -1 on failure.  On failure, use SDL_GetError to retrieve more
  *      information on the failure.
  */
 extern DECLSPEC int SDLCALL SDL_WinRTRunApp(int (*mainFunction)(int, char **), void * reserved);

+ 1 - 1
sdl.mod/SDL/include/SDL_messagebox.h

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages

+ 3 - 2
sdl.mod/SDL/include/SDL_mouse.h

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages
@@ -137,10 +137,11 @@ extern DECLSPEC void SDLCALL SDL_WarpMouseInWindow(SDL_Window * window,
  *
  *  \param x The x coordinate
  *  \param y The y coordinate
+ *  \return 0 on success, -1 on error (usually: unsupported by a platform).
  *
  *  \note This function generates a mouse motion event
  */
-extern DECLSPEC void SDLCALL SDL_WarpMouseGlobal(int x, int y);
+extern DECLSPEC int SDLCALL SDL_WarpMouseGlobal(int x, int y);
 
 /**
  *  \brief Set relative mouse mode.

+ 1 - 1
sdl.mod/SDL/include/SDL_mutex.h

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages

+ 1 - 1
sdl.mod/SDL/include/SDL_name.h

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages

+ 1 - 1
sdl.mod/SDL/include/SDL_opengl.h

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages

+ 5 - 0
sdl.mod/SDL/include/SDL_opengl_glext.h

@@ -2988,6 +2988,11 @@ GLAPI GLboolean APIENTRY glIsProgramARB (GLuint program);
 #define GL_ARB_framebuffer_sRGB 1
 #endif /* GL_ARB_framebuffer_sRGB */
 
+#ifndef GL_KHR_context_flush_control
+#define GL_CONTEXT_RELEASE_BEHAVIOR       0x82FB
+#define GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH 0x82FC
+#endif /* GL_KHR_context_flush_control */
+
 #ifndef GL_ARB_geometry_shader4
 #define GL_ARB_geometry_shader4 1
 #define GL_LINES_ADJACENCY_ARB            0x000A

+ 1 - 1
sdl.mod/SDL/include/SDL_opengles.h

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages

+ 1 - 1
sdl.mod/SDL/include/SDL_opengles2.h

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages

+ 24 - 3
sdl.mod/SDL/include/SDL_pixels.h

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages
@@ -86,6 +86,8 @@ enum
 };
 
 /** Array component order, low byte -> high byte. */
+/* !!! FIXME: in 2.1, make these not overlap differently with
+   !!! FIXME:  SDL_PACKEDORDER_*, so we can simplify SDL_ISPIXELFORMAT_ALPHA */
 enum
 {
     SDL_ARRAYORDER_NONE,
@@ -134,12 +136,31 @@ enum
       (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX4) || \
       (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX8)))
 
-#define SDL_ISPIXELFORMAT_ALPHA(format)   \
+#define SDL_ISPIXELFORMAT_PACKED(format) \
+    (!SDL_ISPIXELFORMAT_FOURCC(format) && \
+     ((SDL_PIXELTYPE(format) == SDL_PIXELTYPE_PACKED8) || \
+      (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_PACKED16) || \
+      (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_PACKED32)))
+
+#define SDL_ISPIXELFORMAT_ARRAY(format) \
     (!SDL_ISPIXELFORMAT_FOURCC(format) && \
+     ((SDL_PIXELTYPE(format) == SDL_PIXELTYPE_ARRAYU8) || \
+      (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_ARRAYU16) || \
+      (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_ARRAYU32) || \
+      (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_ARRAYF16) || \
+      (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_ARRAYF32)))
+
+#define SDL_ISPIXELFORMAT_ALPHA(format)   \
+    ((SDL_ISPIXELFORMAT_PACKED(format) && \
      ((SDL_PIXELORDER(format) == SDL_PACKEDORDER_ARGB) || \
       (SDL_PIXELORDER(format) == SDL_PACKEDORDER_RGBA) || \
       (SDL_PIXELORDER(format) == SDL_PACKEDORDER_ABGR) || \
-      (SDL_PIXELORDER(format) == SDL_PACKEDORDER_BGRA)))
+      (SDL_PIXELORDER(format) == SDL_PACKEDORDER_BGRA))) || \
+    (SDL_ISPIXELFORMAT_ARRAY(format) && \
+     ((SDL_PIXELORDER(format) == SDL_ARRAYORDER_ARGB) || \
+      (SDL_PIXELORDER(format) == SDL_ARRAYORDER_RGBA) || \
+      (SDL_PIXELORDER(format) == SDL_ARRAYORDER_ABGR) || \
+      (SDL_PIXELORDER(format) == SDL_ARRAYORDER_BGRA))))
 
 /* The flag is set to 1 because 0x1? is not in the printable ASCII range */
 #define SDL_ISPIXELFORMAT_FOURCC(format)    \

+ 1 - 1
sdl.mod/SDL/include/SDL_platform.h

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages

+ 1 - 1
sdl.mod/SDL/include/SDL_power.h

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages

+ 1 - 1
sdl.mod/SDL/include/SDL_quit.h

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages

+ 1 - 1
sdl.mod/SDL/include/SDL_rect.h

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages

+ 4 - 4
sdl.mod/SDL/include/SDL_render.h

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages
@@ -81,8 +81,8 @@ typedef struct SDL_RendererInfo
     Uint32 flags;               /**< Supported ::SDL_RendererFlags */
     Uint32 num_texture_formats; /**< The number of available texture formats */
     Uint32 texture_formats[16]; /**< The available texture formats */
-    int max_texture_width;      /**< The maximimum texture width */
-    int max_texture_height;     /**< The maximimum texture height */
+    int max_texture_width;      /**< The maximum texture width */
+    int max_texture_height;     /**< The maximum texture height */
 } SDL_RendererInfo;
 
 /**
@@ -792,7 +792,7 @@ extern DECLSPEC int SDLCALL SDL_RenderCopy(SDL_Renderer * renderer,
  *  \param dstrect   A pointer to the destination rectangle, or NULL for the
  *                   entire rendering target.
  *  \param angle    An angle in degrees that indicates the rotation that will be applied to dstrect
- *  \param center   A pointer to a point indicating the point around which dstrect will be rotated (if NULL, rotation will be done aroud dstrect.w/2, dstrect.h/2)
+ *  \param center   A pointer to a point indicating the point around which dstrect will be rotated (if NULL, rotation will be done around dstrect.w/2, dstrect.h/2).
  *  \param flip     An SDL_RendererFlip value stating which flipping actions should be performed on the texture
  *
  *  \return 0 on success, or -1 on error

+ 1 - 1
sdl.mod/SDL/include/SDL_rwops.h

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages

+ 1 - 1
sdl.mod/SDL/include/SDL_scancode.h

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages

+ 1 - 1
sdl.mod/SDL/include/SDL_shape.h

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages

+ 10 - 2
sdl.mod/SDL/include/SDL_stdinc.h

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages
@@ -173,6 +173,8 @@ typedef uint64_t Uint64;
 #define SDL_PRIs64 PRIs64
 #elif defined(__WIN32__)
 #define SDL_PRIs64 "I64d"
+#elif defined(__LINUX__) && defined(__LP64__)
+#define SDL_PRIs64 "ld"
 #else
 #define SDL_PRIs64 "lld"
 #endif
@@ -182,6 +184,8 @@ typedef uint64_t Uint64;
 #define SDL_PRIu64 PRIu64
 #elif defined(__WIN32__)
 #define SDL_PRIu64 "I64u"
+#elif defined(__LINUX__) && defined(__LP64__)
+#define SDL_PRIu64 "lu"
 #else
 #define SDL_PRIu64 "llu"
 #endif
@@ -191,6 +195,8 @@ typedef uint64_t Uint64;
 #define SDL_PRIx64 PRIx64
 #elif defined(__WIN32__)
 #define SDL_PRIx64 "I64x"
+#elif defined(__LINUX__) && defined(__LP64__)
+#define SDL_PRIx64 "lx"
 #else
 #define SDL_PRIx64 "llx"
 #endif
@@ -200,6 +206,8 @@ typedef uint64_t Uint64;
 #define SDL_PRIX64 PRIX64
 #elif defined(__WIN32__)
 #define SDL_PRIX64 "I64X"
+#elif defined(__LINUX__) && defined(__LP64__)
+#define SDL_PRIX64 "lX"
 #else
 #define SDL_PRIX64 "llX"
 #endif
@@ -218,7 +226,7 @@ typedef uint64_t Uint64;
 #define SDL_PRINTF_VARARG_FUNC( fmtargnumber )
 #define SDL_SCANF_VARARG_FUNC( fmtargnumber )
 #else
-#if _MSC_VER >= 1600 /* VS 2010 and above */
+#if defined(_MSC_VER) && (_MSC_VER >= 1600) /* VS 2010 and above */
 #include <sal.h>
 
 #define SDL_IN_BYTECAP(x) _In_bytecount_(x)

+ 1 - 1
sdl.mod/SDL/include/SDL_surface.h

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages

+ 10 - 1
sdl.mod/SDL/include/SDL_system.h

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages
@@ -42,6 +42,12 @@ extern "C" {
 
 /* Platform specific functions for Windows */
 #ifdef __WIN32__
+	
+/**
+   \brief Set a function that is called for every windows message, before TranslateMessage()
+*/
+typedef void (SDLCALL * SDL_WindowsMessageHook)(void *userdata, void *hWnd, unsigned int message, Uint64 wParam, Sint64 lParam);
+extern DECLSPEC void SDLCALL SDL_SetWindowsMessageHook(SDL_WindowsMessageHook callback, void *userdata);
 
 /**
    \brief Returns the D3D9 adapter index that matches the specified display index.
@@ -73,7 +79,10 @@ extern DECLSPEC SDL_bool SDLCALL SDL_DXGIGetOutputInfo( int displayIndex, int *a
 /* Platform specific functions for iOS */
 #if defined(__IPHONEOS__) && __IPHONEOS__
 
+#define SDL_iOSSetAnimationCallback(window, interval, callback, callbackParam) SDL_iPhoneSetAnimationCallback(window, interval, callback, callbackParam)
 extern DECLSPEC int SDLCALL SDL_iPhoneSetAnimationCallback(SDL_Window * window, int interval, void (*callback)(void*), void *callbackParam);
+
+#define SDL_iOSSetEventPump(enabled) SDL_iPhoneSetEventPump(enabled)
 extern DECLSPEC void SDLCALL SDL_iPhoneSetEventPump(SDL_bool enabled);
 
 #endif /* __IPHONEOS__ */

+ 7 - 1
sdl.mod/SDL/include/SDL_syswm.h

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages
@@ -98,6 +98,7 @@ typedef struct _NSWindow NSWindow;
 typedef struct _UIWindow UIWindow;
 typedef struct _UIViewController UIViewController;
 #endif
+typedef Uint32 GLuint;
 #endif
 
 #if defined(SDL_VIDEO_DRIVER_ANDROID)
@@ -162,6 +163,7 @@ struct SDL_SysWMmsg
 #if defined(SDL_VIDEO_DRIVER_UIKIT)
         struct
         {
+            int dummy;
             /* No UIKit window events yet */
         } uikit;
 #endif
@@ -186,6 +188,7 @@ struct SDL_SysWMinfo
         struct
         {
             HWND window;                /**< The window handle */
+            HDC hdc;                    /**< The window device context */
         } win;
 #endif
 #if defined(SDL_VIDEO_DRIVER_WINRT)
@@ -227,6 +230,9 @@ struct SDL_SysWMinfo
 #else
             UIWindow *window;                     /* The UIKit window */
 #endif
+            GLuint framebuffer; /* The GL view's Framebuffer Object. It must be bound when rendering to the screen using GL. */
+            GLuint colorbuffer; /* The GL view's color Renderbuffer Object. It must be bound when SDL_GL_SwapWindow is called. */
+            GLuint resolveFramebuffer; /* The Framebuffer Object which holds the resolve color Renderbuffer, when MSAA is used. */
         } uikit;
 #endif
 #if defined(SDL_VIDEO_DRIVER_WAYLAND)

+ 2 - 2
sdl.mod/SDL/include/SDL_test.h

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages
@@ -52,7 +52,7 @@ extern "C" {
 /* Global definitions */
 
 /*
- * Note: Maximum size of SDLTest log message is less than SDLs limit
+ * Note: Maximum size of SDLTest log message is less than SDL's limit
  * to ensure we can fit additional information such as the timestamp.
  */
 #define SDLTEST_MAX_LOGMESSAGE_LENGTH   3584

+ 1 - 1
sdl.mod/SDL/include/SDL_test_assert.h

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages

+ 1 - 1
sdl.mod/SDL/include/SDL_test_common.h

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages

+ 1 - 1
sdl.mod/SDL/include/SDL_test_compare.h

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages

+ 1 - 1
sdl.mod/SDL/include/SDL_test_crc32.h

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages

+ 1 - 1
sdl.mod/SDL/include/SDL_test_font.h

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages

+ 1 - 1
sdl.mod/SDL/include/SDL_test_fuzzer.h

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages

+ 1 - 1
sdl.mod/SDL/include/SDL_test_harness.h

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages

+ 1 - 1
sdl.mod/SDL/include/SDL_test_images.h

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages

+ 1 - 1
sdl.mod/SDL/include/SDL_test_log.h

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages

+ 1 - 1
sdl.mod/SDL/include/SDL_test_md5.h

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages

+ 1 - 1
sdl.mod/SDL/include/SDL_test_random.h

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages

+ 1 - 1
sdl.mod/SDL/include/SDL_thread.h

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages

+ 1 - 1
sdl.mod/SDL/include/SDL_timer.h

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages

+ 1 - 1
sdl.mod/SDL/include/SDL_touch.h

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages

+ 1 - 1
sdl.mod/SDL/include/SDL_types.h

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages

+ 1 - 1
sdl.mod/SDL/include/SDL_version.h

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages

+ 33 - 2
sdl.mod/SDL/include/SDL_video.h

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages
@@ -189,7 +189,8 @@ typedef enum
     SDL_GL_CONTEXT_FLAGS,
     SDL_GL_CONTEXT_PROFILE_MASK,
     SDL_GL_SHARE_WITH_CURRENT_CONTEXT,
-    SDL_GL_FRAMEBUFFER_SRGB_CAPABLE
+    SDL_GL_FRAMEBUFFER_SRGB_CAPABLE,
+    SDL_GL_CONTEXT_RELEASE_BEHAVIOR
 } SDL_GLattr;
 
 typedef enum
@@ -207,6 +208,12 @@ typedef enum
     SDL_GL_CONTEXT_RESET_ISOLATION_FLAG    = 0x0008
 } SDL_GLcontextFlag;
 
+typedef enum
+{
+    SDL_GL_CONTEXT_RELEASE_BEHAVIOR_NONE   = 0x0000,
+    SDL_GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH  = 0x0001
+} SDL_GLcontextReleaseFlag;
+
 
 /* Function prototypes */
 
@@ -289,6 +296,18 @@ extern DECLSPEC const char * SDLCALL SDL_GetDisplayName(int displayIndex);
  */
 extern DECLSPEC int SDLCALL SDL_GetDisplayBounds(int displayIndex, SDL_Rect * rect);
 
+/**
+ *  \brief Get the dots/pixels-per-inch for a display
+ *
+ *  \note Diagonal, horizontal and vertical DPI can all be optionally
+ *        returned if the parameter is non-NULL.
+ *
+ *  \return 0 on success, or -1 if no DPI information is available or the index is out of range.
+ *
+ *  \sa SDL_GetNumVideoDisplays()
+ */
+extern DECLSPEC int SDLCALL SDL_GetDisplayDPI(int displayIndex, float * ddpi, float * hdpi, float * vdpi);
+
 /**
  *  \brief Returns the number of available display modes.
  *
@@ -715,6 +734,9 @@ extern DECLSPEC int SDLCALL SDL_UpdateWindowSurfaceRects(SDL_Window * window,
  *  \param window The window for which the input grab mode should be set.
  *  \param grabbed This is SDL_TRUE to grab input, and SDL_FALSE to release input.
  *
+ *  If the caller enables a grab while another window is currently grabbed,
+ *  the other window loses its grab in favor of the caller's window.
+ *
  *  \sa SDL_GetWindowGrab()
  */
 extern DECLSPEC void SDLCALL SDL_SetWindowGrab(SDL_Window * window,
@@ -729,6 +751,15 @@ extern DECLSPEC void SDLCALL SDL_SetWindowGrab(SDL_Window * window,
  */
 extern DECLSPEC SDL_bool SDLCALL SDL_GetWindowGrab(SDL_Window * window);
 
+/**
+ *  \brief Get the window that currently has an input grab enabled.
+ *
+ *  \return This returns the window if input is grabbed, and NULL otherwise.
+ *
+ *  \sa SDL_SetWindowGrab()
+ */
+extern DECLSPEC SDL_Window * SDLCALL SDL_GetGrabbedWindow(void);
+
 /**
  *  \brief Set the brightness (gamma correction) for a window.
  *

+ 1 - 3
sdl.mod/SDL/include/begin_code.h

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages
@@ -64,8 +64,6 @@
 # else
 #  if defined(__GNUC__) && __GNUC__ >= 4
 #   define DECLSPEC __attribute__ ((visibility("default")))
-#  elif defined(__GNUC__) && __GNUC__ >= 2
-#   define DECLSPEC __declspec(dllexport)
 #  else
 #   define DECLSPEC
 #  endif

+ 1 - 1
sdl.mod/SDL/include/close_code.h

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages

+ 3 - 1
sdl.mod/SDL/src/SDL.c

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages
@@ -405,6 +405,8 @@ SDL_GetPlatform()
     return "BSDI";
 #elif __DREAMCAST__
     return "Dreamcast";
+#elif __EMSCRIPTEN__
+    return "Emscripten";
 #elif __FREEBSD__
     return "FreeBSD";
 #elif __HAIKU__

+ 1 - 1
sdl.mod/SDL/src/SDL_assert.c

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages

+ 1 - 1
sdl.mod/SDL/src/SDL_assert_c.h

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages

+ 29 - 11
sdl.mod/SDL/src/SDL_error.c

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages
@@ -111,7 +111,7 @@ SDL_SetError(SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
     va_end(ap);
 
     /* If we are in debug mode, print out an error message */
-    SDL_LogError(SDL_LOG_CATEGORY_ERROR, "%s", SDL_GetError());
+    SDL_LogDebug(SDL_LOG_CATEGORY_ERROR, "%s", SDL_GetError());
 
     return -1;
 }
@@ -120,7 +120,7 @@ SDL_SetError(SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
    so that it supports internationalization and thread-safe errors.
 */
 static char *
-SDL_GetErrorMsg(char *errstr, unsigned int maxlen)
+SDL_GetErrorMsg(char *errstr, int maxlen)
 {
     SDL_error *error;
 
@@ -163,37 +163,55 @@ SDL_GetErrorMsg(char *errstr, unsigned int maxlen)
                     len =
                         SDL_snprintf(msg, maxlen, tmp,
                                      error->args[argi++].value_i);
-                    msg += len;
-                    maxlen -= len;
+                    if (len > 0) {
+                        msg += len;
+                        maxlen -= len;
+                    }
                     break;
+
                 case 'f':
                     len =
                         SDL_snprintf(msg, maxlen, tmp,
                                      error->args[argi++].value_f);
-                    msg += len;
-                    maxlen -= len;
+                    if (len > 0) {
+                        msg += len;
+                        maxlen -= len;
+                    }
                     break;
+
                 case 'p':
                     len =
                         SDL_snprintf(msg, maxlen, tmp,
                                      error->args[argi++].value_ptr);
-                    msg += len;
-                    maxlen -= len;
+                    if (len > 0) {
+                        msg += len;
+                        maxlen -= len;
+                    }
                     break;
+
                 case 's':
                     len =
                         SDL_snprintf(msg, maxlen, tmp,
                                      SDL_LookupString(error->args[argi++].
                                                       buf));
-                    msg += len;
-                    maxlen -= len;
+                    if (len > 0) {
+                        msg += len;
+                        maxlen -= len;
+                    }
                     break;
+
                 }
             } else {
                 *msg++ = *fmt++;
                 maxlen -= 1;
             }
         }
+
+        /* slide back if we've overshot the end of our buffer. */
+        if (maxlen < 0) {
+            msg -= (-maxlen) + 1;
+        }
+
         *msg = 0;               /* NULL terminate the string */
     }
     return (errstr);

+ 1 - 1
sdl.mod/SDL/src/SDL_error_c.h

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages

+ 1 - 1
sdl.mod/SDL/src/SDL_hints.c

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages

+ 1 - 1
sdl.mod/SDL/src/SDL_internal.h

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages

+ 4 - 4
sdl.mod/SDL/src/SDL_log.c

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages
@@ -371,9 +371,9 @@ SDL_LogOutput(void *userdata, int category, SDL_LogPriority priority,
         if (consoleAttached == 1) {
                 if (!WriteConsole(stderrHandle, tstr, lstrlen(tstr), &charsWritten, NULL)) {
                     OutputDebugString(TEXT("Error calling WriteConsole\r\n"));
-                }
-                if (charsWritten == ERROR_NOT_ENOUGH_MEMORY) {
-                    OutputDebugString(TEXT("Insufficient heap memory to write message\r\n"));
+                    if (GetLastError() == ERROR_NOT_ENOUGH_MEMORY) {
+                        OutputDebugString(TEXT("Insufficient heap memory to write message\r\n"));
+                    }
                 }
         }
 #endif /* ifndef __WINRT__ */

+ 1 - 1
sdl.mod/SDL/src/atomic/SDL_atomic.c

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages

+ 1 - 1
sdl.mod/SDL/src/atomic/SDL_spinlock.c

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages

+ 308 - 379
sdl.mod/SDL/src/audio/SDL_audio.c

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages
@@ -51,9 +51,7 @@ extern AudioBootStrap QSAAUDIO_bootstrap;
 extern AudioBootStrap SUNAUDIO_bootstrap;
 extern AudioBootStrap ARTS_bootstrap;
 extern AudioBootStrap ESD_bootstrap;
-#if SDL_AUDIO_DRIVER_NACL
 extern AudioBootStrap NACLAUD_bootstrap;
-#endif
 extern AudioBootStrap NAS_bootstrap;
 extern AudioBootStrap XAUDIO2_bootstrap;
 extern AudioBootStrap DSOUND_bootstrap;
@@ -163,8 +161,16 @@ get_audio_device(SDL_AudioDeviceID id)
 
 /* stubs for audio drivers that don't need a specific entry point... */
 static void
-SDL_AudioDetectDevices_Default(int iscapture, SDL_AddAudioDevice addfn)
-{                               /* no-op. */
+SDL_AudioDetectDevices_Default(void)
+{
+    /* you have to write your own implementation if these assertions fail. */
+    SDL_assert(current_audio.impl.OnlyHasDefaultOutputDevice);
+    SDL_assert(current_audio.impl.OnlyHasDefaultInputDevice || !current_audio.impl.HasCaptureSupport);
+
+    SDL_AddAudioDevice(SDL_FALSE, DEFAULT_OUTPUT_DEVNAME, (void *) ((size_t) 0x1));
+    if (current_audio.impl.HasCaptureSupport) {
+        SDL_AddAudioDevice(SDL_TRUE, DEFAULT_INPUT_DEVNAME, (void *) ((size_t) 0x2));
+    }
 }
 
 static void
@@ -209,10 +215,16 @@ SDL_AudioDeinitialize_Default(void)
 {                               /* no-op. */
 }
 
+static void
+SDL_AudioFreeDeviceHandle_Default(void *handle)
+{                               /* no-op. */
+}
+
+
 static int
-SDL_AudioOpenDevice_Default(_THIS, const char *devname, int iscapture)
+SDL_AudioOpenDevice_Default(_THIS, void *handle, const char *devname, int iscapture)
 {
-    return -1;
+    return SDL_Unsupported();
 }
 
 static SDL_INLINE SDL_bool
@@ -269,71 +281,139 @@ finalize_audio_entry_points(void)
     FILL_STUB(CloseDevice);
     FILL_STUB(LockDevice);
     FILL_STUB(UnlockDevice);
+    FILL_STUB(FreeDeviceHandle);
     FILL_STUB(Deinitialize);
 #undef FILL_STUB
 }
 
-#if 0  /* !!! FIXME: rewrite/remove this streamer code. */
-/* Streaming functions (for when the input and output buffer sizes are different) */
-/* Write [length] bytes from buf into the streamer */
-static void
-SDL_StreamWrite(SDL_AudioStreamer * stream, Uint8 * buf, int length)
-{
-    int i;
 
-    for (i = 0; i < length; ++i) {
-        stream->buffer[stream->write_pos] = buf[i];
-        ++stream->write_pos;
+/* device hotplug support... */
+
+static int
+add_audio_device(const char *name, void *handle, SDL_AudioDeviceItem **devices, int *devCount)
+{
+    int retval = -1;
+    const size_t size = sizeof (SDL_AudioDeviceItem) + SDL_strlen(name) + 1;
+    SDL_AudioDeviceItem *item = (SDL_AudioDeviceItem *) SDL_malloc(size);
+    if (item == NULL) {
+        return -1;
     }
+
+    SDL_assert(handle != NULL);  /* we reserve NULL, audio backends can't use it. */
+
+    item->handle = handle;
+    SDL_strlcpy(item->name, name, size - sizeof (SDL_AudioDeviceItem));
+
+    SDL_LockMutex(current_audio.detectionLock);
+    item->next = *devices;
+    *devices = item;
+    retval = (*devCount)++;
+    SDL_UnlockMutex(current_audio.detectionLock);
+
+    return retval;
 }
 
-/* Read [length] bytes out of the streamer into buf */
-static void
-SDL_StreamRead(SDL_AudioStreamer * stream, Uint8 * buf, int length)
+static SDL_INLINE int
+add_capture_device(const char *name, void *handle)
 {
-    int i;
+    /* !!! FIXME: add this later. SDL_assert(current_audio.impl.HasCaptureSupport);*/
+    return add_audio_device(name, handle, &current_audio.inputDevices, &current_audio.inputDeviceCount);
+}
 
-    for (i = 0; i < length; ++i) {
-        buf[i] = stream->buffer[stream->read_pos];
-        ++stream->read_pos;
-    }
+static SDL_INLINE int
+add_output_device(const char *name, void *handle)
+{
+    return add_audio_device(name, handle, &current_audio.outputDevices, &current_audio.outputDeviceCount);
 }
 
-static int
-SDL_StreamLength(SDL_AudioStreamer * stream)
+static void
+free_device_list(SDL_AudioDeviceItem **devices, int *devCount)
 {
-    return (stream->write_pos - stream->read_pos) % stream->max_len;
+    SDL_AudioDeviceItem *item, *next;
+    for (item = *devices; item != NULL; item = next) {
+        next = item->next;
+        if (item->handle != NULL) {
+            current_audio.impl.FreeDeviceHandle(item->handle);
+        }
+        SDL_free(item);
+    }
+    *devices = NULL;
+    *devCount = 0;
 }
 
-/* Initialize the stream by allocating the buffer and setting the read/write heads to the beginning */
-#if 0
-static int
-SDL_StreamInit(SDL_AudioStreamer * stream, int max_len, Uint8 silence)
+
+/* The audio backends call this when a new device is plugged in. */
+void
+SDL_AddAudioDevice(const int iscapture, const char *name, void *handle)
 {
-    /* First try to allocate the buffer */
-    stream->buffer = (Uint8 *) SDL_malloc(max_len);
-    if (stream->buffer == NULL) {
-        return -1;
+    const int device_index = iscapture ? add_capture_device(name, handle) : add_output_device(name, handle);
+    if (device_index != -1) {
+        /* Post the event, if desired */
+        if (SDL_GetEventState(SDL_AUDIODEVICEADDED) == SDL_ENABLE) {
+            SDL_Event event;
+            SDL_zero(event);
+            event.adevice.type = SDL_AUDIODEVICEADDED;
+            event.adevice.which = device_index;
+            event.adevice.iscapture = iscapture;
+            SDL_PushEvent(&event);
+        }
     }
+}
+
+/* The audio backends call this when a currently-opened device is lost. */
+void SDL_OpenedAudioDeviceDisconnected(SDL_AudioDevice *device)
+{
+    SDL_assert(get_audio_device(device->id) == device);
 
-    stream->max_len = max_len;
-    stream->read_pos = 0;
-    stream->write_pos = 0;
+    if (!device->enabled) {
+        return;
+    }
 
-    /* Zero out the buffer */
-    SDL_memset(stream->buffer, silence, max_len);
+    /* Ends the audio callback and mark the device as STOPPED, but the
+       app still needs to close the device to free resources. */
+    current_audio.impl.LockDevice(device);
+    device->enabled = 0;
+    current_audio.impl.UnlockDevice(device);
 
-    return 0;
+    /* Post the event, if desired */
+    if (SDL_GetEventState(SDL_AUDIODEVICEREMOVED) == SDL_ENABLE) {
+        SDL_Event event;
+        SDL_zero(event);
+        event.adevice.type = SDL_AUDIODEVICEREMOVED;
+        event.adevice.which = device->id;
+        event.adevice.iscapture = device->iscapture ? 1 : 0;
+        SDL_PushEvent(&event);
+    }
 }
-#endif
 
-/* Deinitialize the stream simply by freeing the buffer */
 static void
-SDL_StreamDeinit(SDL_AudioStreamer * stream)
+mark_device_removed(void *handle, SDL_AudioDeviceItem *devices, SDL_bool *removedFlag)
 {
-    SDL_free(stream->buffer);
+    SDL_AudioDeviceItem *item;
+    SDL_assert(handle != NULL);
+    for (item = devices; item != NULL; item = item->next) {
+        if (item->handle == handle) {
+            item->handle = NULL;
+            *removedFlag = SDL_TRUE;
+            return;
+        }
+    }
 }
-#endif
+
+/* The audio backends call this when a device is removed from the system. */
+void
+SDL_RemoveAudioDevice(const int iscapture, void *handle)
+{
+    SDL_LockMutex(current_audio.detectionLock);
+    if (iscapture) {
+        mark_device_removed(handle, current_audio.inputDevices, &current_audio.captureDevicesRemoved);
+    } else {
+        mark_device_removed(handle, current_audio.outputDevices, &current_audio.outputDevicesRemoved);
+    }
+    SDL_UnlockMutex(current_audio.detectionLock);
+    current_audio.impl.FreeDeviceHandle(handle);
+}
+
 
 
 /* buffer queueing support... */
@@ -510,26 +590,17 @@ SDL_ClearQueuedAudio(SDL_AudioDeviceID devid)
 }
 
 
-#if defined(__ANDROID__)
-#include <android/log.h>
-#endif
-
 /* The general mixing thread function */
 int SDLCALL
 SDL_RunAudio(void *devicep)
 {
     SDL_AudioDevice *device = (SDL_AudioDevice *) devicep;
+    const int silence = (int) device->spec.silence;
+    const Uint32 delay = ((device->spec.samples * 1000) / device->spec.freq);
+    const int stream_len = (device->convert.needed) ? device->convert.len : device->spec.size;
     Uint8 *stream;
-    int stream_len;
-    void *udata;
-    void (SDLCALL * fill) (void *userdata, Uint8 * stream, int len);
-    Uint32 delay;
-
-#if 0  /* !!! FIXME: rewrite/remove this streamer code. */
-    /* For streaming when the buffer sizes don't match up */
-    Uint8 *istream;
-    int istream_len = 0;
-#endif
+    void *udata = device->spec.userdata;
+    void (SDLCALL *fill) (void *, Uint8 *, int) = device->spec.callback;
 
     /* The audio mixing is always a high priority thread */
     SDL_SetThreadPriority(SDL_THREAD_PRIORITY_HIGH);
@@ -538,197 +609,60 @@ SDL_RunAudio(void *devicep)
     device->threadid = SDL_ThreadID();
     current_audio.impl.ThreadInit(device);
 
-    /* Set up the mixing function */
-    fill = device->spec.callback;
-    udata = device->spec.userdata;
-
-    /* By default do not stream */
-    device->use_streamer = 0;
-
-    if (device->convert.needed) {
-#if 0                           /* !!! FIXME: I took len_div out of the structure. Use rate_incr instead? */
-        /* If the result of the conversion alters the length, i.e. resampling is being used, use the streamer */
-        if (device->convert.len_mult != 1 || device->convert.len_div != 1) {
-            /* The streamer's maximum length should be twice whichever is larger: spec.size or len_cvt */
-            stream_max_len = 2 * device->spec.size;
-            if (device->convert.len_mult > device->convert.len_div) {
-                stream_max_len *= device->convert.len_mult;
-                stream_max_len /= device->convert.len_div;
-            }
-            if (SDL_StreamInit(&device->streamer, stream_max_len, silence) <
-                0)
-                return -1;
-            device->use_streamer = 1;
-
-            /* istream_len should be the length of what we grab from the callback and feed to conversion,
-               so that we get close to spec_size. I.e. we want device.spec_size = istream_len * u / d
-             */
-            istream_len =
-                device->spec.size * device->convert.len_div /
-                device->convert.len_mult;
+    /* Loop, filling the audio buffers */
+    while (!device->shutdown) {
+        /* Fill the current buffer with sound */
+        if (device->convert.needed) {
+            stream = device->convert.buf;
+        } else if (device->enabled) {
+            stream = current_audio.impl.GetDeviceBuf(device);
+        } else {
+            /* if the device isn't enabled, we still write to the
+               fake_stream, so the app's callback will fire with
+               a regular frequency, in case they depend on that
+               for timing or progress. They can use hotplug
+               now to know if the device failed. */
+            stream = NULL;
         }
-#endif
-        stream_len = device->convert.len;
-    } else {
-        stream_len = device->spec.size;
-    }
 
-    /* Calculate the delay while paused */
-    delay = ((device->spec.samples * 1000) / device->spec.freq);
-
-    /* Determine if the streamer is necessary here */
-#if 0  /* !!! FIXME: rewrite/remove this streamer code. */
-    if (device->use_streamer == 1) {
-        /* This code is almost the same as the old code. The difference is, instead of reading
-           directly from the callback into "stream", then converting and sending the audio off,
-           we go: callback -> "istream" -> (conversion) -> streamer -> stream -> device.
-           However, reading and writing with streamer are done separately:
-           - We only call the callback and write to the streamer when the streamer does not
-           contain enough samples to output to the device.
-           - We only read from the streamer and tell the device to play when the streamer
-           does have enough samples to output.
-           This allows us to perform resampling in the conversion step, where the output of the
-           resampling process can be any number. We will have to see what a good size for the
-           stream's maximum length is, but I suspect 2*max(len_cvt, stream_len) is a good figure.
-         */
-        while (device->enabled) {
-
-            if (device->paused) {
-                SDL_Delay(delay);
-                continue;
-            }
-
-            /* Only read in audio if the streamer doesn't have enough already (if it does not have enough samples to output) */
-            if (SDL_StreamLength(&device->streamer) < stream_len) {
-                /* Set up istream */
-                if (device->convert.needed) {
-                    if (device->convert.buf) {
-                        istream = device->convert.buf;
-                    } else {
-                        continue;
-                    }
-                } else {
-/* FIXME: Ryan, this is probably wrong.  I imagine we don't want to get
- * a device buffer both here and below in the stream output.
- */
-                    istream = current_audio.impl.GetDeviceBuf(device);
-                    if (istream == NULL) {
-                        istream = device->fake_stream;
-                    }
-                }
-
-                /* Read from the callback into the _input_ stream */
-                SDL_LockMutex(device->mixer_lock);
-                (*fill) (udata, istream, istream_len);
-                SDL_UnlockMutex(device->mixer_lock);
-
-                /* Convert the audio if necessary and write to the streamer */
-                if (device->convert.needed) {
-                    SDL_ConvertAudio(&device->convert);
-                    if (istream == NULL) {
-                        istream = device->fake_stream;
-                    }
-                    /* SDL_memcpy(istream, device->convert.buf, device->convert.len_cvt); */
-                    SDL_StreamWrite(&device->streamer, device->convert.buf,
-                                    device->convert.len_cvt);
-                } else {
-                    SDL_StreamWrite(&device->streamer, istream, istream_len);
-                }
-            }
-
-            /* Only output audio if the streamer has enough to output */
-            if (SDL_StreamLength(&device->streamer) >= stream_len) {
-                /* Set up the output stream */
-                if (device->convert.needed) {
-                    if (device->convert.buf) {
-                        stream = device->convert.buf;
-                    } else {
-                        continue;
-                    }
-                } else {
-                    stream = current_audio.impl.GetDeviceBuf(device);
-                    if (stream == NULL) {
-                        stream = device->fake_stream;
-                    }
-                }
-
-                /* Now read from the streamer */
-                SDL_StreamRead(&device->streamer, stream, stream_len);
-
-                /* Ready current buffer for play and change current buffer */
-                if (stream != device->fake_stream) {
-                    current_audio.impl.PlayDevice(device);
-                    /* Wait for an audio buffer to become available */
-                    current_audio.impl.WaitDevice(device);
-                } else {
-                    SDL_Delay(delay);
-                }
-            }
+        if (stream == NULL) {
+            stream = device->fake_stream;
+        }
 
+        /* !!! FIXME: this should be LockDevice. */
+        SDL_LockMutex(device->mixer_lock);
+        if (device->paused) {
+            SDL_memset(stream, silence, stream_len);
+        } else {
+            (*fill) (udata, stream, stream_len);
         }
-    } else
-#endif
-    {
-        /* Otherwise, do not use the streamer. This is the old code. */
-        const int silence = (int) device->spec.silence;
-
-        /* Loop, filling the audio buffers */
-        while (device->enabled) {
-
-            /* Fill the current buffer with sound */
-            if (device->convert.needed) {
-                if (device->convert.buf) {
-                    stream = device->convert.buf;
-                } else {
-                    continue;
-                }
-            } else {
-                stream = current_audio.impl.GetDeviceBuf(device);
-                if (stream == NULL) {
-                    stream = device->fake_stream;
-                }
-            }
+        SDL_UnlockMutex(device->mixer_lock);
 
-            SDL_LockMutex(device->mixer_lock);
-            if (device->paused) {
-                SDL_memset(stream, silence, stream_len);
+        /* Convert the audio if necessary */
+        if (device->enabled && device->convert.needed) {
+            SDL_ConvertAudio(&device->convert);
+            stream = current_audio.impl.GetDeviceBuf(device);
+            if (stream == NULL) {
+                stream = device->fake_stream;
             } else {
-                (*fill) (udata, stream, stream_len);
-            }
-            SDL_UnlockMutex(device->mixer_lock);
-
-            /* Convert the audio if necessary */
-            if (device->convert.needed) {
-                SDL_ConvertAudio(&device->convert);
-                stream = current_audio.impl.GetDeviceBuf(device);
-                if (stream == NULL) {
-                    stream = device->fake_stream;
-                }
                 SDL_memcpy(stream, device->convert.buf,
                            device->convert.len_cvt);
             }
+        }
 
-            /* Ready current buffer for play and change current buffer */
-            if (stream != device->fake_stream) {
-                current_audio.impl.PlayDevice(device);
-                /* Wait for an audio buffer to become available */
-                current_audio.impl.WaitDevice(device);
-            } else {
-                SDL_Delay(delay);
-            }
+        /* Ready current buffer for play and change current buffer */
+        if (stream == device->fake_stream) {
+            SDL_Delay(delay);
+        } else {
+            current_audio.impl.PlayDevice(device);
+            current_audio.impl.WaitDevice(device);
         }
     }
 
-    /* Wait for the audio to drain.. */
+    /* Wait for the audio to drain. */
     current_audio.impl.WaitDone(device);
 
-    /* If necessary, deinit the streamer */
-#if 0  /* !!! FIXME: rewrite/remove this streamer code. */
-    if (device->use_streamer == 1)
-        SDL_StreamDeinit(&device->streamer);
-#endif
-
-    return (0);
+    return 0;
 }
 
 
@@ -761,16 +695,16 @@ SDL_ParseAudioFormat(const char *string)
 int
 SDL_GetNumAudioDrivers(void)
 {
-    return (SDL_arraysize(bootstrap) - 1);
+    return SDL_arraysize(bootstrap) - 1;
 }
 
 const char *
 SDL_GetAudioDriver(int index)
 {
     if (index >= 0 && index < SDL_GetNumAudioDrivers()) {
-        return (bootstrap[index]->name);
+        return bootstrap[index]->name;
     }
-    return (NULL);
+    return NULL;
 }
 
 int
@@ -784,8 +718,8 @@ SDL_AudioInit(const char *driver_name)
         SDL_AudioQuit();        /* shutdown driver if already running. */
     }
 
-    SDL_memset(&current_audio, '\0', sizeof(current_audio));
-    SDL_memset(open_devices, '\0', sizeof(open_devices));
+    SDL_zero(current_audio);
+    SDL_zero(open_devices);
 
     /* Select the proper audio driver */
     if (driver_name == NULL) {
@@ -801,7 +735,7 @@ SDL_AudioInit(const char *driver_name)
         }
 
         tried_to_init = 1;
-        SDL_memset(&current_audio, 0, sizeof(current_audio));
+        SDL_zero(current_audio);
         current_audio.name = backend->name;
         current_audio.desc = backend->desc;
         initialized = backend->init(&current_audio.impl);
@@ -817,13 +751,18 @@ SDL_AudioInit(const char *driver_name)
             }
         }
 
-        SDL_memset(&current_audio, 0, sizeof(current_audio));
-        return (-1);            /* No driver was available, so fail. */
+        SDL_zero(current_audio);
+        return -1;            /* No driver was available, so fail. */
     }
 
+    current_audio.detectionLock = SDL_CreateMutex();
+
     finalize_audio_entry_points();
 
-    return (0);
+    /* Make sure we have a list of devices available at startup. */
+    current_audio.impl.DetectDevices();
+
+    return 0;
 }
 
 /*
@@ -835,50 +774,32 @@ SDL_GetCurrentAudioDriver()
     return current_audio.name;
 }
 
+/* Clean out devices that we've removed but had to keep around for stability. */
 static void
-free_device_list(char ***devices, int *devCount)
+clean_out_device_list(SDL_AudioDeviceItem **devices, int *devCount, SDL_bool *removedFlag)
 {
-    int i = *devCount;
-    if ((i > 0) && (*devices != NULL)) {
-        while (i--) {
-            SDL_free((*devices)[i]);
+    SDL_AudioDeviceItem *item = *devices;
+    SDL_AudioDeviceItem *prev = NULL;
+    int total = 0;
+
+    while (item) {
+        SDL_AudioDeviceItem *next = item->next;
+        if (item->handle != NULL) {
+            total++;
+            prev = item;
+        } else {
+            if (prev) {
+                prev->next = next;
+            } else {
+                *devices = next;
+            }
+            SDL_free(item);
         }
+        item = next;
     }
 
-    SDL_free(*devices);
-
-    *devices = NULL;
-    *devCount = 0;
-}
-
-static
-void SDL_AddCaptureAudioDevice(const char *_name)
-{
-    char *name = NULL;
-    void *ptr = SDL_realloc(current_audio.inputDevices,
-                          (current_audio.inputDeviceCount+1) * sizeof(char*));
-    if (ptr == NULL) {
-        return;  /* oh well. */
-    }
-
-    current_audio.inputDevices = (char **) ptr;
-    name = SDL_strdup(_name);  /* if this returns NULL, that's okay. */
-    current_audio.inputDevices[current_audio.inputDeviceCount++] = name;
-}
-
-static
-void SDL_AddOutputAudioDevice(const char *_name)
-{
-    char *name = NULL;
-    void *ptr = SDL_realloc(current_audio.outputDevices,
-                          (current_audio.outputDeviceCount+1) * sizeof(char*));
-    if (ptr == NULL) {
-        return;  /* oh well. */
-    }
-
-    current_audio.outputDevices = (char **) ptr;
-    name = SDL_strdup(_name);  /* if this returns NULL, that's okay. */
-    current_audio.outputDevices[current_audio.outputDeviceCount++] = name;
+    *devCount = total;
+    *removedFlag = SDL_FALSE;
 }
 
 
@@ -891,29 +812,18 @@ SDL_GetNumAudioDevices(int iscapture)
         return -1;
     }
 
-    if ((iscapture) && (!current_audio.impl.HasCaptureSupport)) {
-        return 0;
+    SDL_LockMutex(current_audio.detectionLock);
+    if (iscapture && current_audio.captureDevicesRemoved) {
+        clean_out_device_list(&current_audio.inputDevices, &current_audio.inputDeviceCount, &current_audio.captureDevicesRemoved);
     }
 
-    if ((iscapture) && (current_audio.impl.OnlyHasDefaultInputDevice)) {
-        return 1;
+    if (!iscapture && current_audio.outputDevicesRemoved) {
+        clean_out_device_list(&current_audio.outputDevices, &current_audio.outputDeviceCount, &current_audio.outputDevicesRemoved);
+        current_audio.outputDevicesRemoved = SDL_FALSE;
     }
 
-    if ((!iscapture) && (current_audio.impl.OnlyHasDefaultOutputDevice)) {
-        return 1;
-    }
-
-    if (iscapture) {
-        free_device_list(&current_audio.inputDevices,
-                         &current_audio.inputDeviceCount);
-        current_audio.impl.DetectDevices(iscapture, SDL_AddCaptureAudioDevice);
-        retval = current_audio.inputDeviceCount;
-    } else {
-        free_device_list(&current_audio.outputDevices,
-                         &current_audio.outputDeviceCount);
-        current_audio.impl.DetectDevices(iscapture, SDL_AddOutputAudioDevice);
-        retval = current_audio.outputDeviceCount;
-    }
+    retval = iscapture ? current_audio.inputDeviceCount : current_audio.outputDeviceCount;
+    SDL_UnlockMutex(current_audio.detectionLock);
 
     return retval;
 }
@@ -922,6 +832,8 @@ SDL_GetNumAudioDevices(int iscapture)
 const char *
 SDL_GetAudioDeviceName(int index, int iscapture)
 {
+    const char *retval = NULL;
+
     if (!SDL_WasInit(SDL_INIT_AUDIO)) {
         SDL_SetError("Audio subsystem is not initialized");
         return NULL;
@@ -932,39 +844,28 @@ SDL_GetAudioDeviceName(int index, int iscapture)
         return NULL;
     }
 
-    if (index < 0) {
-        goto no_such_device;
-    }
-
-    if ((iscapture) && (current_audio.impl.OnlyHasDefaultInputDevice)) {
-        if (index > 0) {
-            goto no_such_device;
-        }
-        return DEFAULT_INPUT_DEVNAME;
-    }
+    if (index >= 0) {
+        SDL_AudioDeviceItem *item;
+        int i;
 
-    if ((!iscapture) && (current_audio.impl.OnlyHasDefaultOutputDevice)) {
-        if (index > 0) {
-            goto no_such_device;
+        SDL_LockMutex(current_audio.detectionLock);
+        item = iscapture ? current_audio.inputDevices : current_audio.outputDevices;
+        i = iscapture ? current_audio.inputDeviceCount : current_audio.outputDeviceCount;
+        if (index < i) {
+            for (i--; i > index; i--, item = item->next) {
+                SDL_assert(item != NULL);
+            }
+            SDL_assert(item != NULL);
+            retval = item->name;
         }
-        return DEFAULT_OUTPUT_DEVNAME;
+        SDL_UnlockMutex(current_audio.detectionLock);
     }
 
-    if (iscapture) {
-        if (index >= current_audio.inputDeviceCount) {
-            goto no_such_device;
-        }
-        return current_audio.inputDevices[index];
-    } else {
-        if (index >= current_audio.outputDeviceCount) {
-            goto no_such_device;
-        }
-        return current_audio.outputDevices[index];
+    if (retval == NULL) {
+        SDL_SetError("No such device");
     }
 
-no_such_device:
-    SDL_SetError("No such device");
-    return NULL;
+    return retval;
 }
 
 
@@ -972,6 +873,7 @@ static void
 close_audio_device(SDL_AudioDevice * device)
 {
     device->enabled = 0;
+    device->shutdown = 1;
     if (device->thread != NULL) {
         SDL_WaitThread(device->thread, NULL);
     }
@@ -1065,6 +967,8 @@ open_audio_device(const char *devname, int iscapture,
     SDL_AudioSpec _obtained;
     SDL_AudioDevice *device;
     SDL_bool build_cvt;
+    void *handle = NULL;
+    Uint32 stream_len;
     int i = 0;
 
     if (!SDL_WasInit(SDL_INIT_AUDIO)) {
@@ -1077,6 +981,18 @@ open_audio_device(const char *devname, int iscapture,
         return 0;
     }
 
+    /* Find an available device ID... */
+    for (id = min_id - 1; id < SDL_arraysize(open_devices); id++) {
+        if (open_devices[id] == NULL) {
+            break;
+        }
+    }
+
+    if (id == SDL_arraysize(open_devices)) {
+        SDL_SetError("Too many open audio devices");
+        return 0;
+    }
+
     if (!obtained) {
         obtained = &_obtained;
     }
@@ -1112,9 +1028,7 @@ open_audio_device(const char *devname, int iscapture,
                 return 0;
             }
         }
-    }
-
-    if ((!iscapture) && (current_audio.impl.OnlyHasDefaultOutputDevice)) {
+    } else if ((!iscapture) && (current_audio.impl.OnlyHasDefaultOutputDevice)) {
         if ((devname) && (SDL_strcmp(devname, DEFAULT_OUTPUT_DEVNAME) != 0)) {
             SDL_SetError("No such device");
             return 0;
@@ -1127,6 +1041,30 @@ open_audio_device(const char *devname, int iscapture,
                 return 0;
             }
         }
+    } else if (devname != NULL) {
+        /* if the app specifies an exact string, we can pass the backend
+           an actual device handle thingey, which saves them the effort of
+           figuring out what device this was (such as, reenumerating
+           everything again to find the matching human-readable name).
+           It might still need to open a device based on the string for,
+           say, a network audio server, but this optimizes some cases. */
+        SDL_AudioDeviceItem *item;
+        SDL_LockMutex(current_audio.detectionLock);
+        for (item = iscapture ? current_audio.inputDevices : current_audio.outputDevices; item; item = item->next) {
+            if ((item->handle != NULL) && (SDL_strcmp(item->name, devname) == 0)) {
+                handle = item->handle;
+                break;
+            }
+        }
+        SDL_UnlockMutex(current_audio.detectionLock);
+    }
+
+    if (!current_audio.impl.AllowsArbitraryDeviceNames) {
+        /* has to be in our device list, or the default device. */
+        if ((handle == NULL) && (devname != NULL)) {
+            SDL_SetError("No such device.");
+            return 0;
+        }
     }
 
     device = (SDL_AudioDevice *) SDL_AllocAudioMem(sizeof(SDL_AudioDevice));
@@ -1135,12 +1073,13 @@ open_audio_device(const char *devname, int iscapture,
         return 0;
     }
     SDL_zerop(device);
+    device->id = id + 1;
     device->spec = *obtained;
     device->enabled = 1;
     device->paused = 1;
     device->iscapture = iscapture;
 
-    /* Create a semaphore for locking the sound buffers */
+    /* Create a mutex for locking the sound buffers */
     if (!current_audio.impl.SkipMixerLock) {
         device->mixer_lock = SDL_CreateMutex();
         if (device->mixer_lock == NULL) {
@@ -1150,26 +1089,12 @@ open_audio_device(const char *devname, int iscapture,
         }
     }
 
-    /* force a device detection if we haven't done one yet. */
-    if ( ((iscapture) && (current_audio.inputDevices == NULL)) ||
-         ((!iscapture) && (current_audio.outputDevices == NULL)) ) {
-        SDL_GetNumAudioDevices(iscapture);
-    }
-
-    if (current_audio.impl.OpenDevice(device, devname, iscapture) < 0) {
+    if (current_audio.impl.OpenDevice(device, handle, devname, iscapture) < 0) {
         close_audio_device(device);
         return 0;
     }
     device->opened = 1;
 
-    /* Allocate a fake audio memory buffer */
-    device->fake_stream = (Uint8 *)SDL_AllocAudioMem(device->spec.size);
-    if (device->fake_stream == NULL) {
-        close_audio_device(device);
-        SDL_OutOfMemory();
-        return 0;
-    }
-
     /* See if we need to do any conversion */
     build_cvt = SDL_FALSE;
     if (obtained->freq != device->spec.freq) {
@@ -1228,6 +1153,19 @@ open_audio_device(const char *devname, int iscapture,
         }
     }
 
+    /* Allocate a fake audio memory buffer */
+    stream_len = (device->convert.needed) ? device->convert.len_cvt : 0;
+    if (device->spec.size > stream_len) {
+        stream_len = device->spec.size;
+    }
+    SDL_assert(stream_len > 0);
+    device->fake_stream = (Uint8 *)SDL_AllocAudioMem(stream_len);
+    if (device->fake_stream == NULL) {
+        close_audio_device(device);
+        SDL_OutOfMemory();
+        return 0;
+    }
+
     if (device->spec.callback == NULL) {  /* use buffer queueing? */
         /* pool a few packets to start. Enough for two callbacks. */
         const int packetlen = SDL_AUDIOBUFFERQUEUE_PACKETLEN;
@@ -1247,25 +1185,14 @@ open_audio_device(const char *devname, int iscapture,
         device->spec.userdata = device;
     }
 
-    /* Find an available device ID and store the structure... */
-    for (id = min_id - 1; id < SDL_arraysize(open_devices); id++) {
-        if (open_devices[id] == NULL) {
-            open_devices[id] = device;
-            break;
-        }
-    }
-
-    if (id == SDL_arraysize(open_devices)) {
-        SDL_SetError("Too many open audio devices");
-        close_audio_device(device);
-        return 0;
-    }
+    /* add it to our list of open devices. */
+    open_devices[id] = device;
 
     /* Start the audio thread if necessary */
     if (!current_audio.impl.ProvidesOwnCallbackThread) {
         /* Start the audio thread */
         char name[64];
-        SDL_snprintf(name, sizeof (name), "SDLAudioDev%d", (int) (id + 1));
+        SDL_snprintf(name, sizeof (name), "SDLAudioDev%d", (int) device->id);
 /* !!! FIXME: this is nasty. */
 #if defined(__WIN32__) && !defined(HAVE_LIBC)
 #undef SDL_CreateThread
@@ -1278,13 +1205,13 @@ open_audio_device(const char *devname, int iscapture,
         device->thread = SDL_CreateThread(SDL_RunAudio, name, device);
 #endif
         if (device->thread == NULL) {
-            SDL_CloseAudioDevice(id + 1);
+            SDL_CloseAudioDevice(device->id);
             SDL_SetError("Couldn't create audio thread");
             return 0;
         }
     }
 
-    return id + 1;
+    return device->id;
 }
 
 
@@ -1296,14 +1223,14 @@ SDL_OpenAudio(SDL_AudioSpec * desired, SDL_AudioSpec * obtained)
     /* Start up the audio driver, if necessary. This is legacy behaviour! */
     if (!SDL_WasInit(SDL_INIT_AUDIO)) {
         if (SDL_InitSubSystem(SDL_INIT_AUDIO) < 0) {
-            return (-1);
+            return -1;
         }
     }
 
     /* SDL_OpenAudio() is legacy and can only act on Device ID #1. */
     if (open_devices[0] != NULL) {
         SDL_SetError("Audio device is already opened");
-        return (-1);
+        return -1;
     }
 
     if (obtained) {
@@ -1314,7 +1241,7 @@ SDL_OpenAudio(SDL_AudioSpec * desired, SDL_AudioSpec * obtained)
     }
 
     SDL_assert((id == 0) || (id == 1));
-    return ((id == 0) ? -1 : 0);
+    return (id == 0) ? -1 : 0;
 }
 
 SDL_AudioDeviceID
@@ -1338,7 +1265,7 @@ SDL_GetAudioDeviceStatus(SDL_AudioDeviceID devid)
             status = SDL_AUDIO_PLAYING;
         }
     }
-    return (status);
+    return status;
 }
 
 
@@ -1429,14 +1356,16 @@ SDL_AudioQuit(void)
         }
     }
 
+    free_device_list(&current_audio.outputDevices, &current_audio.outputDeviceCount);
+    free_device_list(&current_audio.inputDevices, &current_audio.inputDeviceCount);
+
     /* Free the driver data */
     current_audio.impl.Deinitialize();
-    free_device_list(&current_audio.outputDevices,
-                     &current_audio.outputDeviceCount);
-    free_device_list(&current_audio.inputDevices,
-                     &current_audio.inputDeviceCount);
-    SDL_memset(&current_audio, '\0', sizeof(current_audio));
-    SDL_memset(open_devices, '\0', sizeof(open_devices));
+
+    SDL_DestroyMutex(current_audio.detectionLock);
+
+    SDL_zero(current_audio);
+    SDL_zero(open_devices);
 }
 
 #define NUM_FORMATS 10
@@ -1474,16 +1403,16 @@ SDL_FirstAudioFormat(SDL_AudioFormat format)
         }
     }
     format_idx_sub = 0;
-    return (SDL_NextAudioFormat());
+    return SDL_NextAudioFormat();
 }
 
 SDL_AudioFormat
 SDL_NextAudioFormat(void)
 {
     if ((format_idx == NUM_FORMATS) || (format_idx_sub == NUM_FORMATS)) {
-        return (0);
+        return 0;
     }
-    return (format_list[format_idx][format_idx_sub++]);
+    return format_list[format_idx][format_idx_sub++];
 }
 
 void

+ 1 - 1
sdl.mod/SDL/src/audio/SDL_audio_c.h

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages

+ 1 - 1
sdl.mod/SDL/src/audio/SDL_audiocvt.c

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages

+ 23 - 13
sdl.mod/SDL/src/audio/SDL_audiodev.c

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages
@@ -46,18 +46,21 @@
 #define _PATH_DEV_AUDIO "/dev/audio"
 #endif
 
-static SDL_INLINE void
-test_device(const char *fname, int flags, int (*test) (int fd),
-            SDL_AddAudioDevice addfn)
+static void
+test_device(const int iscapture, const char *fname, int flags, int (*test) (int fd))
 {
     struct stat sb;
     if ((stat(fname, &sb) == 0) && (S_ISCHR(sb.st_mode))) {
         const int audio_fd = open(fname, flags, 0);
         if (audio_fd >= 0) {
-            if (test(audio_fd)) {
-                addfn(fname);
-            }
+            const int okay = test(audio_fd);
             close(audio_fd);
+            if (okay) {
+                static size_t dummyhandle = 0;
+                dummyhandle++;
+                SDL_assert(dummyhandle != 0);
+                SDL_AddAudioDevice(iscapture, fname, (void *) dummyhandle);
+            }
         }
     }
 }
@@ -68,11 +71,10 @@ test_stub(int fd)
     return 1;
 }
 
-void
-SDL_EnumUnixAudioDevices(int iscapture, int classic, int (*test)(int fd),
-                         SDL_AddAudioDevice addfn)
+static void
+SDL_EnumUnixAudioDevices_Internal(const int iscapture, const int classic, int (*test)(int))
 {
-    const int flags = ((iscapture) ? OPEN_FLAGS_INPUT : OPEN_FLAGS_OUTPUT);
+    const int flags = iscapture ? OPEN_FLAGS_INPUT : OPEN_FLAGS_OUTPUT;
     const char *audiodev;
     char audiopath[1024];
 
@@ -97,17 +99,25 @@ SDL_EnumUnixAudioDevices(int iscapture, int classic, int (*test)(int fd),
             }
         }
     }
-    test_device(audiodev, flags, test, addfn);
+    test_device(iscapture, audiodev, flags, test);
 
     if (SDL_strlen(audiodev) < (sizeof(audiopath) - 3)) {
         int instance = 0;
         while (instance++ <= 64) {
             SDL_snprintf(audiopath, SDL_arraysize(audiopath),
                          "%s%d", audiodev, instance);
-            test_device(audiopath, flags, test, addfn);
+            test_device(iscapture, audiopath, flags, test);
         }
     }
 }
 
+void
+SDL_EnumUnixAudioDevices(const int classic, int (*test)(int))
+{
+    SDL_EnumUnixAudioDevices_Internal(SDL_TRUE, classic, test);
+    SDL_EnumUnixAudioDevices_Internal(SDL_FALSE, classic, test);
+}
+
 #endif /* Audio driver selection */
+
 /* vi: set ts=4 sw=4 expandtab: */

+ 2 - 3
sdl.mod/SDL/src/audio/SDL_audiodev_c.h

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages
@@ -33,7 +33,6 @@
 #define OPEN_FLAGS_INPUT (O_RDONLY|O_NONBLOCK)
 #endif
 
-void SDL_EnumUnixAudioDevices(int iscapture, int classic,
-                              int (*test) (int fd), SDL_AddAudioDevice addfn);
+extern void SDL_EnumUnixAudioDevices(const int classic, int (*test)(int));
 
 /* vi: set ts=4 sw=4 expandtab: */

+ 1 - 1
sdl.mod/SDL/src/audio/SDL_audiomem.h

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages

+ 1 - 1
sdl.mod/SDL/src/audio/SDL_audiotypecvt.c

@@ -1,7 +1,7 @@
 /* DO NOT EDIT!  This file is generated by sdlgenaudiocvt.pl */
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages

+ 1 - 1
sdl.mod/SDL/src/audio/SDL_mixer.c

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages

+ 44 - 10
sdl.mod/SDL/src/audio/SDL_sysaudio.h

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages
@@ -30,8 +30,21 @@
 typedef struct SDL_AudioDevice SDL_AudioDevice;
 #define _THIS   SDL_AudioDevice *_this
 
-/* Used by audio targets during DetectDevices() */
-typedef void (*SDL_AddAudioDevice)(const char *name);
+/* Audio targets should call this as devices are added to the system (such as
+   a USB headset being plugged in), and should also be called for
+   for every device found during DetectDevices(). */
+extern void SDL_AddAudioDevice(const int iscapture, const char *name, void *handle);
+
+/* Audio targets should call this as devices are removed, so SDL can update
+   its list of available devices. */
+extern void SDL_RemoveAudioDevice(const int iscapture, void *handle);
+
+/* Audio targets should call this if an opened audio device is lost while
+   being used. This can happen due to i/o errors, or a device being unplugged,
+   etc. If the device is totally gone, please also call SDL_RemoveAudioDevice()
+   as appropriate so SDL's list of devices is accurate. */
+extern void SDL_OpenedAudioDeviceDisconnected(SDL_AudioDevice *device);
+
 
 /* This is the size of a packet when using SDL_QueueAudio(). We allocate
    these as necessary and pool them, under the assumption that we'll
@@ -55,8 +68,8 @@ typedef struct SDL_AudioBufferQueue
 
 typedef struct SDL_AudioDriverImpl
 {
-    void (*DetectDevices) (int iscapture, SDL_AddAudioDevice addfn);
-    int (*OpenDevice) (_THIS, const char *devname, int iscapture);
+    void (*DetectDevices) (void);
+    int (*OpenDevice) (_THIS, void *handle, const char *devname, int iscapture);
     void (*ThreadInit) (_THIS); /* Called by audio thread at start */
     void (*WaitDevice) (_THIS);
     void (*PlayDevice) (_THIS);
@@ -66,19 +79,34 @@ typedef struct SDL_AudioDriverImpl
     void (*CloseDevice) (_THIS);
     void (*LockDevice) (_THIS);
     void (*UnlockDevice) (_THIS);
+    void (*FreeDeviceHandle) (void *handle);  /**< SDL is done with handle from SDL_AddAudioDevice() */
     void (*Deinitialize) (void);
 
     /* !!! FIXME: add pause(), so we can optimize instead of mixing silence. */
 
     /* Some flags to push duplicate code into the core and reduce #ifdefs. */
+    /* !!! FIXME: these should be SDL_bool */
     int ProvidesOwnCallbackThread;
     int SkipMixerLock;  /* !!! FIXME: do we need this anymore? */
     int HasCaptureSupport;
     int OnlyHasDefaultOutputDevice;
     int OnlyHasDefaultInputDevice;
+    int AllowsArbitraryDeviceNames;
 } SDL_AudioDriverImpl;
 
 
+typedef struct SDL_AudioDeviceItem
+{
+    void *handle;
+    struct SDL_AudioDeviceItem *next;
+    #if (defined(__GNUC__) && (__GNUC__ <= 2))
+    char name[1];  /* actually variable length. */
+    #else
+    char name[];
+    #endif
+} SDL_AudioDeviceItem;
+
+
 typedef struct SDL_AudioDriver
 {
     /* * * */
@@ -91,11 +119,14 @@ typedef struct SDL_AudioDriver
 
     SDL_AudioDriverImpl impl;
 
-    char **outputDevices;
+    /* A mutex for device detection */
+    SDL_mutex *detectionLock;
+    SDL_bool captureDevicesRemoved;
+    SDL_bool outputDevicesRemoved;
     int outputDeviceCount;
-
-    char **inputDevices;
     int inputDeviceCount;
+    SDL_AudioDeviceItem *outputDevices;
+    SDL_AudioDeviceItem *inputDevices;
 } SDL_AudioDriver;
 
 
@@ -113,6 +144,7 @@ struct SDL_AudioDevice
 {
     /* * * */
     /* Data common to all devices */
+    SDL_AudioDeviceID id;
 
     /* The current audio specification (shared with audio thread) */
     SDL_AudioSpec spec;
@@ -125,15 +157,17 @@ struct SDL_AudioDevice
     SDL_AudioStreamer streamer;
 
     /* Current state flags */
+    /* !!! FIXME: should be SDL_bool */
     int iscapture;
-    int enabled;
+    int enabled;  /* true if device is functioning and connected. */
+    int shutdown; /* true if we are signaling the play thread to end. */
     int paused;
     int opened;
 
     /* Fake audio buffer for when the audio hardware is busy */
     Uint8 *fake_stream;
 
-    /* A semaphore for locking the mixing buffers */
+    /* A mutex for locking the mixing buffers */
     SDL_mutex *mixer_lock;
 
     /* A thread to feed the audio device */

+ 1 - 1
sdl.mod/SDL/src/audio/SDL_wave.c

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages

+ 1 - 1
sdl.mod/SDL/src/audio/SDL_wave.h

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages

+ 3 - 3
sdl.mod/SDL/src/audio/alsa/SDL_alsa_audio.c

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages
@@ -320,7 +320,7 @@ ALSA_PlayDevice(_THIS)
                 /* Hmm, not much we can do - abort */
                 fprintf(stderr, "ALSA write failed (unrecoverable): %s\n",
                         ALSA_snd_strerror(status));
-                this->enabled = 0;
+                SDL_OpenedAudioDeviceDisconnected(this);
                 return;
             }
             continue;
@@ -465,7 +465,7 @@ ALSA_set_buffer_size(_THIS, snd_pcm_hw_params_t *params, int override)
 }
 
 static int
-ALSA_OpenDevice(_THIS, const char *devname, int iscapture)
+ALSA_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
 {
     int status = 0;
     snd_pcm_t *pcm_handle = NULL;

+ 1 - 1
sdl.mod/SDL/src/audio/alsa/SDL_alsa_audio.h

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages

+ 2 - 2
sdl.mod/SDL/src/audio/android/SDL_androidaudio.c

@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
+  Copyright (C) 1997-2015 Sam Lantinga <[email protected]>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages
@@ -35,7 +35,7 @@
 static SDL_AudioDevice* audioDevice = NULL;
 
 static int
-AndroidAUD_OpenDevice(_THIS, const char *devname, int iscapture)
+AndroidAUD_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
 {
     SDL_AudioFormat test_format;
 

Some files were not shown because too many files changed in this diff